annotate OrthancFramework/Sources/DicomParsing/IDicomTranscoder.cpp @ 5141:023569e7155b

moved DicomModification thread safety into ResourceModificationJob (trying to avoid mutex in OrthancFramework as much as possible)
author Alain Mazy <am@osimis.io>
date Fri, 20 Jan 2023 18:10:42 +0100
parents 60cb4b379485
children 0ea402b4d901
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
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: 4044
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: 4044
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: 4044
diff changeset
11 * the License, or (at your option) any later version.
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
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: 4044
diff changeset
16 * Lesser General Public License for more details.
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
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: 4044
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: 4044
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: 4044
diff changeset
20 * <http://www.gnu.org/licenses/>.
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../PrecompiledHeaders.h"
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "IDicomTranscoder.h"
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../OrthancException.h"
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
28 #include "FromDcmtkBridge.h"
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
29 #include "ParsedDicomFile.h"
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <dcmtk/dcmdata/dcfilefo.h>
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
32 #include <dcmtk/dcmdata/dcdeftag.h>
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace Orthanc
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
36 IDicomTranscoder::TranscodingType IDicomTranscoder::GetTranscodingType(DicomTransferSyntax target,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
37 DicomTransferSyntax source)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
38 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
39 if (target == source)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
40 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
41 return TranscodingType_Lossless;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
42 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
43 else if (target == DicomTransferSyntax_LittleEndianImplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
44 target == DicomTransferSyntax_LittleEndianExplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
45 target == DicomTransferSyntax_BigEndianExplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
46 target == DicomTransferSyntax_DeflatedLittleEndianExplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
47 target == DicomTransferSyntax_JPEGProcess14 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
48 target == DicomTransferSyntax_JPEGProcess14SV1 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
49 target == DicomTransferSyntax_JPEGLSLossless ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
50 target == DicomTransferSyntax_JPEG2000LosslessOnly ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
51 target == DicomTransferSyntax_JPEG2000MulticomponentLosslessOnly)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
52 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
53 return TranscodingType_Lossless;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
54 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
55 else if (target == DicomTransferSyntax_JPEGProcess1 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
56 target == DicomTransferSyntax_JPEGProcess2_4 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
57 target == DicomTransferSyntax_JPEGLSLossy ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
58 target == DicomTransferSyntax_JPEG2000 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
59 target == DicomTransferSyntax_JPEG2000Multicomponent)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
60 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
61 return TranscodingType_Lossy;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
62 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
63 else
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
64 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
65 return TranscodingType_Unknown;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
66 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
67 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
68
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
69
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
70 std::string IDicomTranscoder::GetSopInstanceUid(DcmFileFormat& dicom)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
71 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
72 if (dicom.getDataset() == NULL)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
73 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
74 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
75 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
76
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
77 DcmDataset& dataset = *dicom.getDataset();
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
78
4953
60cb4b379485 added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
79 std::string s;
60cb4b379485 added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
80 if (FromDcmtkBridge::LookupStringValue(s, dataset, DICOM_TAG_SOP_INSTANCE_UID))
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
81 {
4953
60cb4b379485 added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
82 return s;
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
83 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
84 else
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
85 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
86 throw OrthancException(ErrorCode_BadFileFormat, "File without SOP instance UID");
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
87 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
88 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
89
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 void IDicomTranscoder::CheckTranscoding(IDicomTranscoder::DicomImage& transcoded,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
92 DicomTransferSyntax sourceSyntax,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
93 const std::string& sourceSopInstanceUid,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
94 const std::set<DicomTransferSyntax>& allowedSyntaxes,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
95 bool allowNewSopInstanceUid)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
96 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
97 DcmFileFormat& parsed = transcoded.GetParsed();
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 if (parsed.getDataset() == NULL)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
100 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
101 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
102 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
103
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
104 std::string targetSopInstanceUid = GetSopInstanceUid(parsed);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
105
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
106 if (parsed.getDataset()->tagExists(DCM_PixelData))
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
107 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
108 if (!allowNewSopInstanceUid && (targetSopInstanceUid != sourceSopInstanceUid))
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
109 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
110 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
111 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
112 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
113 else
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
114 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
115 if (targetSopInstanceUid != sourceSopInstanceUid)
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
116 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
117 throw OrthancException(ErrorCode_InternalError,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
118 "No pixel data: Transcoding must not change the SOP instance UID");
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
119 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
120 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
121
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
122 DicomTransferSyntax targetSyntax;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
123 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(targetSyntax, parsed))
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
124 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
125 return; // Unknown transfer syntax, cannot do further test
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
126 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
127
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
128 if (allowedSyntaxes.find(sourceSyntax) != allowedSyntaxes.end())
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
129 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
130 // No transcoding should have happened
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
131 if (targetSopInstanceUid != sourceSopInstanceUid)
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
132 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
133 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
134 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
135 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
136
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
137 if (allowedSyntaxes.find(targetSyntax) == allowedSyntaxes.end())
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
138 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
139 throw OrthancException(ErrorCode_InternalError, "An incorrect output transfer syntax was chosen");
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
140 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
141
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
142 if (parsed.getDataset()->tagExists(DCM_PixelData))
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
143 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
144 switch (GetTranscodingType(targetSyntax, sourceSyntax))
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
145 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
146 case TranscodingType_Lossy:
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
147 if (targetSopInstanceUid == sourceSopInstanceUid)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
148 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
149 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
150 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
151 break;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
152
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
153 case TranscodingType_Lossless:
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
154 if (targetSopInstanceUid != sourceSopInstanceUid)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
155 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
156 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
157 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
158 break;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
159
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
160 default:
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
161 break;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
162 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
163 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
164 }
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
165
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
166
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
167 void IDicomTranscoder::DicomImage::Parse()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
168 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
169 if (parsed_.get() != NULL)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
170 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
171 // Already parsed
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
172 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
173 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
174 else if (buffer_.get() != NULL)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
175 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
176 if (isExternalBuffer_)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
177 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
178 throw OrthancException(ErrorCode_InternalError);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
179 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
180 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
181 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
182 parsed_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
183 buffer_->empty() ? NULL : buffer_->c_str(), buffer_->size()));
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
184
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
185 if (parsed_.get() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
186 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
187 throw OrthancException(ErrorCode_BadFileFormat);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
188 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
189 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
190 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
191 else if (isExternalBuffer_)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
192 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
193 parsed_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(externalBuffer_, externalSize_));
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
194
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
195 if (parsed_.get() == NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
196 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
197 throw OrthancException(ErrorCode_BadFileFormat);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
198 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
199 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
200 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
201 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
202 // No buffer is available
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
203 throw OrthancException(ErrorCode_BadSequenceOfCalls);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
204 }
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
205 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
206
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
207
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
208 void IDicomTranscoder::DicomImage::Serialize()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
209 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
210 if (parsed_.get() == NULL ||
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
211 buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
212 isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
213 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
214 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
215 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
216 else if (parsed_->getDataset() == NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
217 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
218 throw OrthancException(ErrorCode_InternalError);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
219 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
220 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
221 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
222 buffer_.reset(new std::string);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
223 FromDcmtkBridge::SaveToMemoryBuffer(*buffer_, *parsed_->getDataset());
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
224 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
225 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
226
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
227
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
228 IDicomTranscoder::DicomImage::DicomImage() :
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
229 isExternalBuffer_(false),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
230 externalBuffer_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
231 externalSize_(0)
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
232 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
233 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
234
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
235
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
236 void IDicomTranscoder::DicomImage::Clear()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
237 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
238 parsed_.reset(NULL);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
239 buffer_.reset(NULL);
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
240 isExternalBuffer_ = false;
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
241 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
242
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
243
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
244 void IDicomTranscoder::DicomImage::AcquireParsed(ParsedDicomFile& parsed)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
245 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
246 AcquireParsed(parsed.ReleaseDcmtkObject());
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
247 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
248
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
249
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
250 void IDicomTranscoder::DicomImage::AcquireParsed(DcmFileFormat* parsed)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
251 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
252 if (parsed == NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
253 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
254 throw OrthancException(ErrorCode_NullPointer);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
255 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
256 else if (parsed->getDataset() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
257 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
258 throw OrthancException(ErrorCode_InternalError);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
259 }
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
260 else if (parsed_.get() != NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
261 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
262 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
263 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
264 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
265 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
266 parsed_.reset(parsed);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
267 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
268 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
269
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
270
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
271 void IDicomTranscoder::DicomImage::AcquireParsed(DicomImage& other)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
272 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
273 AcquireParsed(other.ReleaseParsed());
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
274 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
275
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
276
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
277 void IDicomTranscoder::DicomImage::AcquireBuffer(std::string& buffer /* will be swapped */)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
278 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
279 if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
280 isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
281 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
282 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
283 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
284 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
285 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
286 buffer_.reset(new std::string);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
287 buffer_->swap(buffer);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
288 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
289 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
290
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
291
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
292 void IDicomTranscoder::DicomImage::AcquireBuffer(DicomImage& other)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
293 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
294 if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
295 isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
296 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
297 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
298 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
299 else if (other.isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
300 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
301 assert(other.buffer_.get() == NULL);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
302 isExternalBuffer_ = true;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
303 externalBuffer_ = other.externalBuffer_;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
304 externalSize_ = other.externalSize_;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
305 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
306 else if (other.buffer_.get() != NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
307 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
308 buffer_.reset(other.buffer_.release());
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
309 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
310 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
311 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
312 buffer_.reset(NULL);
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
313 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
314 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
315
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
316
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
317 void IDicomTranscoder::DicomImage::SetExternalBuffer(const void* buffer,
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
318 size_t size)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
319 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
320 if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
321 isExternalBuffer_)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
322 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
323 throw OrthancException(ErrorCode_BadSequenceOfCalls);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
324 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
325 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
326 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
327 isExternalBuffer_ = true;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
328 externalBuffer_ = buffer;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
329 externalSize_ = size;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
330 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
331 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
332
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
333
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
334 void IDicomTranscoder::DicomImage::SetExternalBuffer(const std::string& buffer)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
335 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
336 SetExternalBuffer(buffer.empty() ? NULL : buffer.c_str(), buffer.size());
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
337 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
338
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
339
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
340 DcmFileFormat& IDicomTranscoder::DicomImage::GetParsed()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
341 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
342 if (parsed_.get() != NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
343 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
344 return *parsed_;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
345 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
346 else if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
347 isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
348 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
349 Parse();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
350 return *parsed_;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
351 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
352 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
353 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
354 throw OrthancException(
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
355 ErrorCode_BadSequenceOfCalls,
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
356 "AcquireParsed(), AcquireBuffer() or SetExternalBuffer() should have been called");
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
357 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
358 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
359
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
360
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
361 DcmFileFormat* IDicomTranscoder::DicomImage::ReleaseParsed()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
362 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
363 if (parsed_.get() != NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
364 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
365 buffer_.reset(NULL);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
366 return parsed_.release();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
367 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
368 else if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
369 isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
370 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
371 Parse();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
372 buffer_.reset(NULL);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
373 return parsed_.release();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
374 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
375 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
376 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
377 throw OrthancException(
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
378 ErrorCode_BadSequenceOfCalls,
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
379 "AcquireParsed(), AcquireBuffer() or SetExternalBuffer() should have been called");
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
380 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
381 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
382
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
383
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
384 ParsedDicomFile* IDicomTranscoder::DicomImage::ReleaseAsParsedDicomFile()
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
385 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
386 return ParsedDicomFile::AcquireDcmtkObject(ReleaseParsed());
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
387 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
388
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
389
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
390 const void* IDicomTranscoder::DicomImage::GetBufferData()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
391 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
392 if (isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
393 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
394 assert(buffer_.get() == NULL);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
395 return externalBuffer_;
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
396 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
397 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
398 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
399 if (buffer_.get() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
400 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
401 Serialize();
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
402 }
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
403
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
404 assert(buffer_.get() != NULL);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
405 return buffer_->empty() ? NULL : buffer_->c_str();
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
406 }
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
407 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
408
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
409
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
410 size_t IDicomTranscoder::DicomImage::GetBufferSize()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
411 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
412 if (isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
413 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
414 assert(buffer_.get() == NULL);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
415 return externalSize_;
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 }
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 else
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
418 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
419 if (buffer_.get() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
420 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
421 Serialize();
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
422 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
423
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
424 assert(buffer_.get() != NULL);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
425 return buffer_->size();
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 }
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 }
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 }