Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/IDicomTranscoder.h @ 5527:93dcc555b655 Orthanc-1.12.3
Orthanc-1.12.3
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 31 Jan 2024 12:33:17 +0100 |
parents | 48b8dae6dc77 |
children | f7adfb22e20e |
rev | line source |
---|---|
3893 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3893 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
11 * the License, or (at your option) any later version. |
3893 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
16 * Lesser General Public License for more details. |
3893 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
3893 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
3906
f0dd5ded8927
refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3904
diff
changeset
|
26 #include "../Compatibility.h" |
3893 | 27 #include "../Enumerations.h" |
28 | |
29 #include <boost/noncopyable.hpp> | |
30 #include <set> | |
31 | |
32 class DcmFileFormat; | |
33 | |
34 namespace Orthanc | |
35 { | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
36 class ParsedDicomFile; |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
37 |
3893 | 38 /** |
39 * WARNING: This class might be called from several threads at | |
40 * once. Make sure to implement proper locking. | |
41 **/ | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
42 class ORTHANC_PUBLIC IDicomTranscoder : public boost::noncopyable |
3893 | 43 { |
44 public: | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
45 class ORTHANC_PUBLIC DicomImage : public boost::noncopyable |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
46 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
47 private: |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
48 std::unique_ptr<DcmFileFormat> parsed_; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
49 std::unique_ptr<std::string> buffer_; |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
50 bool isExternalBuffer_; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
51 const void* externalBuffer_; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
52 size_t externalSize_; |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
53 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
54 void Parse(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
55 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
56 void Serialize(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
57 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
58 DcmFileFormat* ReleaseParsed(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
59 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
60 public: |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
61 DicomImage(); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
62 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
63 void Clear(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
64 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
65 // Calling this method will invalidate the "ParsedDicomFile" object |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
66 void AcquireParsed(ParsedDicomFile& parsed); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
67 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
68 void AcquireParsed(DcmFileFormat* parsed); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
69 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
70 void AcquireParsed(DicomImage& other); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
71 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
72 void AcquireBuffer(std::string& buffer /* will be swapped */); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
73 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
74 void AcquireBuffer(DicomImage& other); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
75 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
76 void SetExternalBuffer(const void* buffer, |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
77 size_t size); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
78 |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
79 void SetExternalBuffer(const std::string& buffer); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
80 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
81 DcmFileFormat& GetParsed(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
82 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
83 ParsedDicomFile* ReleaseAsParsedDicomFile(); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3944
diff
changeset
|
84 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
85 const void* GetBufferData(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
86 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
87 size_t GetBufferSize(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
88 }; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
89 |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
90 |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
91 protected: |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
92 enum TranscodingType |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
93 { |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
94 TranscodingType_Lossy, |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
95 TranscodingType_Lossless, |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
96 TranscodingType_Unknown |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
97 }; |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
98 |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
99 static TranscodingType GetTranscodingType(DicomTransferSyntax target, |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
100 DicomTransferSyntax source); |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
101 |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
102 static void CheckTranscoding(DicomImage& transcoded, |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
103 DicomTransferSyntax sourceSyntax, |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
104 const std::string& sourceSopInstanceUid, |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
105 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
106 bool allowNewSopInstanceUid); |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
107 |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
108 public: |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
109 virtual ~IDicomTranscoder() |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
110 { |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
111 } |
3893 | 112 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
113 virtual bool Transcode(DicomImage& target, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
114 DicomImage& source /* in, "GetParsed()" possibly modified */, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
115 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
116 bool allowNewSopInstanceUid) = 0; |
3948
3d2fc1b5cc8c
ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3946
diff
changeset
|
117 |
3d2fc1b5cc8c
ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3946
diff
changeset
|
118 static std::string GetSopInstanceUid(DcmFileFormat& dicom); |
3893 | 119 }; |
120 } |