annotate Core/DicomParsing/IDicomTranscoder.cpp @ 3992:f9863630ec7f

working on the shared library for Orthanc framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Jun 2020 16:07:01 +0200
parents 5fe8c6d3212e
children
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
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
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 * 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
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
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 #include "../PrecompiledHeaders.h"
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "IDicomTranscoder.h"
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../OrthancException.h"
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
38 #include "FromDcmtkBridge.h"
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
39 #include "ParsedDicomFile.h"
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <dcmtk/dcmdata/dcfilefo.h>
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
42 #include <dcmtk/dcmdata/dcdeftag.h>
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace Orthanc
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
46 IDicomTranscoder::TranscodingType IDicomTranscoder::GetTranscodingType(DicomTransferSyntax target,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
47 DicomTransferSyntax source)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
48 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
49 if (target == source)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
50 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
51 return TranscodingType_Lossless;
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 else if (target == DicomTransferSyntax_LittleEndianImplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
54 target == DicomTransferSyntax_LittleEndianExplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
55 target == DicomTransferSyntax_BigEndianExplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
56 target == DicomTransferSyntax_DeflatedLittleEndianExplicit ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
57 target == DicomTransferSyntax_JPEGProcess14 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
58 target == DicomTransferSyntax_JPEGProcess14SV1 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
59 target == DicomTransferSyntax_JPEGLSLossless ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
60 target == DicomTransferSyntax_JPEG2000LosslessOnly ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
61 target == DicomTransferSyntax_JPEG2000MulticomponentLosslessOnly)
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 return TranscodingType_Lossless;
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 else if (target == DicomTransferSyntax_JPEGProcess1 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
66 target == DicomTransferSyntax_JPEGProcess2_4 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
67 target == DicomTransferSyntax_JPEGLSLossy ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
68 target == DicomTransferSyntax_JPEG2000 ||
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
69 target == DicomTransferSyntax_JPEG2000Multicomponent)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
70 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
71 return TranscodingType_Lossy;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
72 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
73 else
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
74 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
75 return TranscodingType_Unknown;
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 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
78
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
79
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
80 std::string IDicomTranscoder::GetSopInstanceUid(DcmFileFormat& dicom)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
81 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
82 if (dicom.getDataset() == NULL)
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 throw OrthancException(ErrorCode_InternalError);
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
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
87 DcmDataset& dataset = *dicom.getDataset();
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 const char* v = NULL;
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 if (dataset.findAndGetString(DCM_SOPInstanceUID, v).good() &&
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
92 v != NULL)
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 return std::string(v);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
95 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
96 else
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 throw OrthancException(ErrorCode_BadFileFormat, "File without SOP instance UID");
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
99 }
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
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 void IDicomTranscoder::CheckTranscoding(IDicomTranscoder::DicomImage& transcoded,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
104 DicomTransferSyntax sourceSyntax,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
105 const std::string& sourceSopInstanceUid,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
106 const std::set<DicomTransferSyntax>& allowedSyntaxes,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
107 bool allowNewSopInstanceUid)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
108 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
109 DcmFileFormat& parsed = transcoded.GetParsed();
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
110
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
111 if (parsed.getDataset() == NULL)
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 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
114 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
115
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
116 std::string targetSopInstanceUid = GetSopInstanceUid(parsed);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
117
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
118 if (parsed.getDataset()->tagExists(DCM_PixelData))
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 if (!allowNewSopInstanceUid && (targetSopInstanceUid != sourceSopInstanceUid))
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 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
123 }
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 else
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
126 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
127 if (targetSopInstanceUid != sourceSopInstanceUid)
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
128 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
129 throw OrthancException(ErrorCode_InternalError,
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
130 "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
131 }
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
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
134 DicomTransferSyntax targetSyntax;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
135 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(targetSyntax, parsed))
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 return; // Unknown transfer syntax, cannot do further test
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
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
140 if (allowedSyntaxes.find(sourceSyntax) != allowedSyntaxes.end())
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 // No transcoding should have happened
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3946
diff changeset
143 if (targetSopInstanceUid != sourceSopInstanceUid)
3946
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
144 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
145 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
146 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
147 }
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 if (allowedSyntaxes.find(targetSyntax) == allowedSyntaxes.end())
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 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
152 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
153
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
154 if (parsed.getDataset()->tagExists(DCM_PixelData))
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 switch (GetTranscodingType(targetSyntax, sourceSyntax))
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 case TranscodingType_Lossy:
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
159 if (targetSopInstanceUid == sourceSopInstanceUid)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
160 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
161 throw OrthancException(ErrorCode_InternalError);
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 break;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
164
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
165 case TranscodingType_Lossless:
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
166 if (targetSopInstanceUid != sourceSopInstanceUid)
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
167 {
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
168 throw OrthancException(ErrorCode_InternalError);
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
169 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
170 break;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
171
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
172 default:
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
173 break;
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
174 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
175 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
176 }
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
177
1f33ed7f82e6 automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
178
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
179 void IDicomTranscoder::DicomImage::Parse()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
180 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
181 if (parsed_.get() != NULL)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
182 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
183 // Already parsed
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
184 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
185 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
186 else if (buffer_.get() != NULL)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
187 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
188 if (isExternalBuffer_)
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 throw OrthancException(ErrorCode_InternalError);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
191 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
192 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
193 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
194 parsed_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
195 buffer_->empty() ? NULL : buffer_->c_str(), buffer_->size()));
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
196
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
197 if (parsed_.get() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
198 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
199 throw OrthancException(ErrorCode_BadFileFormat);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
200 }
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 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
203 else if (isExternalBuffer_)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
204 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
205 parsed_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(externalBuffer_, externalSize_));
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
206
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
207 if (parsed_.get() == NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
208 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
209 throw OrthancException(ErrorCode_BadFileFormat);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
210 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
211 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
212 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
213 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
214 // No buffer is available
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
215 throw OrthancException(ErrorCode_BadSequenceOfCalls);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
216 }
3944
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
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 void IDicomTranscoder::DicomImage::Serialize()
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 if (parsed_.get() == NULL ||
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
223 buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
224 isExternalBuffer_)
3944
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 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
227 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
228 else if (parsed_->getDataset() == NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
229 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
230 throw OrthancException(ErrorCode_InternalError);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
231 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
232 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
233 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
234 buffer_.reset(new std::string);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
235 FromDcmtkBridge::SaveToMemoryBuffer(*buffer_, *parsed_->getDataset());
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
236 }
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
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
239
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
240 IDicomTranscoder::DicomImage::DicomImage() :
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
241 isExternalBuffer_(false)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
242 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
243 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
244
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
245
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
246 void IDicomTranscoder::DicomImage::Clear()
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 parsed_.reset(NULL);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
249 buffer_.reset(NULL);
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
250 isExternalBuffer_ = false;
3944
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
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 void IDicomTranscoder::DicomImage::AcquireParsed(ParsedDicomFile& parsed)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
255 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
256 AcquireParsed(parsed.ReleaseDcmtkObject());
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
257 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
258
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
259
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
260 void IDicomTranscoder::DicomImage::AcquireParsed(DcmFileFormat* parsed)
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 if (parsed == NULL)
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 throw OrthancException(ErrorCode_NullPointer);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
265 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
266 else if (parsed->getDataset() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
267 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
268 throw OrthancException(ErrorCode_InternalError);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
269 }
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
270 else if (parsed_.get() != NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
271 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
272 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
273 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
274 else
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 parsed_.reset(parsed);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
277 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
278 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
279
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
280
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
281 void IDicomTranscoder::DicomImage::AcquireParsed(DicomImage& other)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
282 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
283 AcquireParsed(other.ReleaseParsed());
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
284 }
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
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
287 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
288 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
289 if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
290 isExternalBuffer_)
3944
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 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
293 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
294 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
295 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
296 buffer_.reset(new std::string);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
297 buffer_->swap(buffer);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
298 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
299 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
300
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
301
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
302 void IDicomTranscoder::DicomImage::AcquireBuffer(DicomImage& other)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
303 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
304 if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
305 isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
306 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
307 throw OrthancException(ErrorCode_BadSequenceOfCalls);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
308 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
309 else if (other.isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
310 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
311 assert(other.buffer_.get() == NULL);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
312 isExternalBuffer_ = true;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
313 externalBuffer_ = other.externalBuffer_;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
314 externalSize_ = other.externalSize_;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
315 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
316 else if (other.buffer_.get() != NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
317 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
318 buffer_.reset(other.buffer_.release());
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
319 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
320 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
321 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
322 buffer_.reset(NULL);
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
323 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
324 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
325
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
326
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
327 void IDicomTranscoder::DicomImage::SetExternalBuffer(const void* buffer,
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
328 size_t size)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
329 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
330 if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
331 isExternalBuffer_)
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 throw OrthancException(ErrorCode_BadSequenceOfCalls);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
334 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
335 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
336 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
337 isExternalBuffer_ = true;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
338 externalBuffer_ = buffer;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
339 externalSize_ = size;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
340 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
341 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
342
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
343
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
344 void IDicomTranscoder::DicomImage::SetExternalBuffer(const std::string& buffer)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
345 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
346 SetExternalBuffer(buffer.empty() ? NULL : buffer.c_str(), buffer.size());
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
347 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
348
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
349
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
350 DcmFileFormat& IDicomTranscoder::DicomImage::GetParsed()
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 if (parsed_.get() != NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
353 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
354 return *parsed_;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
355 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
356 else if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
357 isExternalBuffer_)
3944
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 Parse();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
360 return *parsed_;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
361 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
362 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
363 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
364 throw OrthancException(
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
365 ErrorCode_BadSequenceOfCalls,
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
366 "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
367 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
368 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
369
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 DcmFileFormat* IDicomTranscoder::DicomImage::ReleaseParsed()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
372 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
373 if (parsed_.get() != NULL)
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 buffer_.reset(NULL);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
376 return parsed_.release();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
377 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
378 else if (buffer_.get() != NULL ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
379 isExternalBuffer_)
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 Parse();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
382 buffer_.reset(NULL);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
383 return parsed_.release();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
384 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
385 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
386 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
387 throw OrthancException(
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
388 ErrorCode_BadSequenceOfCalls,
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
389 "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
390 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
391 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
392
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
393
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
394 ParsedDicomFile* IDicomTranscoder::DicomImage::ReleaseAsParsedDicomFile()
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
395 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
396 return ParsedDicomFile::AcquireDcmtkObject(ReleaseParsed());
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
397 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
398
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
399
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
400 const void* IDicomTranscoder::DicomImage::GetBufferData()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
401 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
402 if (isExternalBuffer_)
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 externalBuffer_;
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
406 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
407 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
408 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
409 if (buffer_.get() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
410 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
411 Serialize();
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
412 }
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 buffer_->empty() ? NULL : buffer_->c_str();
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
416 }
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
417 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
418
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
419
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
420 size_t IDicomTranscoder::DicomImage::GetBufferSize()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
421 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
422 if (isExternalBuffer_)
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
423 {
3945
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 externalSize_;
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 else
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
428 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
429 if (buffer_.get() == NULL)
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
430 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
431 Serialize();
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
432 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
433
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
434 assert(buffer_.get() != NULL);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
435 return buffer_->size();
3906
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 }
f0dd5ded8927 refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 }