annotate OrthancFramework/Sources/DicomParsing/IDicomTranscoder.h @ 4831:7053502fbf97

added copyright UCLouvain
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Nov 2021 19:01:11 +0100
parents d9473bd5ed43
children 43e613a7756b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4303
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
4831
7053502fbf97 added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3904
diff changeset
26 #include "../Compatibility.h"
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../Enumerations.h"
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <boost/noncopyable.hpp>
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <set>
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class DcmFileFormat;
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace Orthanc
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 /**
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 * WARNING: This class might be called from several threads at
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 * once. Make sure to implement proper locking.
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 };
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }