annotate Framework/Inputs/DicomPyramidInstance.cpp @ 216:c35a3a0627b9

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 12 Jan 2021 10:21:36 +0100
parents 02cb86d07966
children 20bc074ec19a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
214
1e864138f0da upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
16
7a88c614be04 preparing for precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
22 #include "../PrecompiledHeadersWSI.h"
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "DicomPyramidInstance.h"
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
194
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
25 #include "../DicomToolbox.h"
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
26 #include "../../Resources/Orthanc/Stone/DicomDatasetReader.h"
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
27 #include "../../Resources/Orthanc/Stone/FullOrthancDataset.h"
194
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
28
192
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
29 #include <Logging.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
30 #include <OrthancException.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
31 #include <Toolbox.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
32
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include <cassert>
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
35 #define SERIALIZED_METADATA "4200"
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
36
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
37
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 namespace OrthancWSI
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
40 static const Orthanc::DicomTag DICOM_TAG_COLUMN_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX(0x0048, 0x021e);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
41 static const Orthanc::DicomTag DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE(0x5200, 0x9230);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
42 static const Orthanc::DicomTag DICOM_TAG_PLANE_POSITION_SLIDE_SEQUENCE(0x0048, 0x021a);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
43 static const Orthanc::DicomTag DICOM_TAG_ROW_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX(0x0048, 0x021f);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
44 static const Orthanc::DicomTag DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS(0x0048, 0x0006);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
45 static const Orthanc::DicomTag DICOM_TAG_TOTAL_PIXEL_MATRIX_ROWS(0x0048, 0x0007);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
46
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
47 static ImageCompression DetectImageCompression(OrthancStone::IOrthancConnection& orthanc,
62
f45cec2c32e2 Speed-up in the Web viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 61
diff changeset
48 const std::string& instanceId)
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
50 using namespace OrthancStone;
62
f45cec2c32e2 Speed-up in the Web viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 61
diff changeset
51
87
3d83d34cd4db sync, optimizations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 70
diff changeset
52 FullOrthancDataset dataset(orthanc, "/instances/" + instanceId + "/header");
3d83d34cd4db sync, optimizations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 70
diff changeset
53 DicomDatasetReader header(dataset);
62
f45cec2c32e2 Speed-up in the Web viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 61
diff changeset
54
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 std::string s = Orthanc::Toolbox::StripSpaces
213
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
56 (header.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_TRANSFER_SYNTAX_UID)));
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 if (s == "1.2.840.10008.1.2" ||
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 s == "1.2.840.10008.1.2.1")
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 return ImageCompression_None;
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 else if (s == "1.2.840.10008.1.2.4.50")
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 return ImageCompression_Jpeg;
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 else if (s == "1.2.840.10008.1.2.4.90" ||
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 s == "1.2.840.10008.1.2.4.91")
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 return ImageCompression_Jpeg2000;
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 else
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 LOG(ERROR) << "Unsupported transfer syntax: " << s;
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
80 static void DetectPixelFormat(Orthanc::PixelFormat& format,
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
81 Orthanc::PhotometricInterpretation& photometric,
216
c35a3a0627b9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 215
diff changeset
82 const OrthancStone::DicomDatasetReader& reader)
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
84 using namespace OrthancStone;
62
f45cec2c32e2 Speed-up in the Web viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 61
diff changeset
85
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
86 std::string p = Orthanc::Toolbox::StripSpaces
213
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
87 (reader.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_PHOTOMETRIC_INTERPRETATION)));
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
88
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
89 photometric = Orthanc::StringToPhotometricInterpretation(p.c_str());
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
91 if (photometric == Orthanc::PhotometricInterpretation_Palette)
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
93 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented,
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
94 "Unsupported photometric interpretation: " + p);
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
89
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
97 unsigned int bitsStored, samplesPerPixel, tmp;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
98
213
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
99 if (!reader.GetUnsignedIntegerValue(bitsStored, OrthancStone::DicomPath(Orthanc::DICOM_TAG_BITS_STORED)) ||
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
100 !reader.GetUnsignedIntegerValue(samplesPerPixel, OrthancStone::DicomPath(Orthanc::DICOM_TAG_SAMPLES_PER_PIXEL)) ||
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
101 !reader.GetUnsignedIntegerValue(tmp, OrthancStone::DicomPath(Orthanc::DICOM_TAG_PIXEL_REPRESENTATION)))
89
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
102 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
103 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
104 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
105
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
106 bool isSigned = (tmp != 0);
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 if (bitsStored == 8 &&
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 samplesPerPixel == 1 &&
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 !isSigned)
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 {
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
112 format = Orthanc::PixelFormat_Grayscale8;
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 else if (bitsStored == 8 &&
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 samplesPerPixel == 3 &&
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 !isSigned)
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
118 format = Orthanc::PixelFormat_RGB24;
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 else
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
122 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Unsupported pixel format");
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
56
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
126
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
127 ImageCompression DicomPyramidInstance::GetImageCompression(OrthancStone::IOrthancConnection& orthanc)
56
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
128 {
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
129 /**
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
130 * Lazy detection of the image compression using the transfer
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
131 * syntax stored inside the DICOM header. Given the fact that
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
132 * reading the header is a time-consuming operation (it implies
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
133 * the decoding of the DICOM image by Orthanc, whereas the "/tags"
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
134 * endpoint only reads the "DICOM-as-JSON" attachment), the
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
135 * "/header" REST call is delayed until it is really required.
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
136 **/
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
137
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
138 if (!hasCompression_)
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
139 {
62
f45cec2c32e2 Speed-up in the Web viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 61
diff changeset
140 compression_ = DetectImageCompression(orthanc, instanceId_);
56
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
141 hasCompression_ = true;
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
142 }
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
143
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
144 return compression_;
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
145 }
83cd735c885d speedup the loading of DICOM sources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
146
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
148 void DicomPyramidInstance::Load(OrthancStone::IOrthancConnection& orthanc,
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
149 const std::string& instanceId)
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
151 using namespace OrthancStone;
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
87
3d83d34cd4db sync, optimizations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 70
diff changeset
153 FullOrthancDataset dataset(orthanc, "/instances/" + instanceId + "/tags");
3d83d34cd4db sync, optimizations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 70
diff changeset
154 DicomDatasetReader reader(dataset);
62
f45cec2c32e2 Speed-up in the Web viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 61
diff changeset
155
213
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
156 if (reader.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_SOP_CLASS_UID)) != "1.2.840.10008.5.1.4.1.1.77.1.6" ||
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
157 reader.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_MODALITY)) != "SM")
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
162 hasCompression_ = false;
166
f0dac1e8f736 access to photometric interpretation of source pyramids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 157
diff changeset
163 DetectPixelFormat(format_, photometric_, reader);
89
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
165 unsigned int tmp;
213
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
166 if (!reader.GetUnsignedIntegerValue(tileWidth_, OrthancStone::DicomPath(Orthanc::DICOM_TAG_COLUMNS)) ||
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
167 !reader.GetUnsignedIntegerValue(tileHeight_, OrthancStone::DicomPath(Orthanc::DICOM_TAG_ROWS)) ||
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
168 !reader.GetUnsignedIntegerValue(totalWidth_, OrthancStone::DicomPath(DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS)) ||
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
169 !reader.GetUnsignedIntegerValue(totalHeight_, OrthancStone::DicomPath(DICOM_TAG_TOTAL_PIXEL_MATRIX_ROWS)) ||
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
170 !reader.GetUnsignedIntegerValue(tmp, OrthancStone::DicomPath(Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)))
89
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
171 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
172 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
173 }
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
62
f45cec2c32e2 Speed-up in the Web viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 61
diff changeset
175 size_t countFrames;
215
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
176 if (reader.GetDataset().GetSequenceSize(countFrames, OrthancStone::DicomPath(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE)))
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
215
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
178 if (countFrames != tmp)
89
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
179 {
215
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
180 LOG(ERROR) << "Mismatch between the number of frames in instance: " << instanceId;
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
215
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
184 frames_.resize(countFrames);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
185
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
186 for (size_t i = 0; i < countFrames; i++)
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
187 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
188 DicomPath pathX(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE, i,
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
189 DICOM_TAG_PLANE_POSITION_SLIDE_SEQUENCE, 0,
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
190 DICOM_TAG_COLUMN_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
191
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
192 DicomPath pathY(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE, i,
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
193 DICOM_TAG_PLANE_POSITION_SLIDE_SEQUENCE, 0,
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
194 DICOM_TAG_ROW_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
195
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
196 int xx, yy;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
197 if (!reader.GetIntegerValue(xx, pathX) ||
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
198 !reader.GetIntegerValue(yy, pathY))
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
199 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
200 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
201 }
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
202
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
203 // "-1", because coordinates are shifted by 1 in DICOM
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
204 xx -= 1;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
205 yy -= 1;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
206
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
207 unsigned int x = static_cast<unsigned int>(xx);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
208 unsigned int y = static_cast<unsigned int>(yy);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
209
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
210 if (xx < 0 ||
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
211 yy < 0 ||
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
212 x % tileWidth_ != 0 ||
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
213 y % tileHeight_ != 0 ||
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
214 x >= totalWidth_ ||
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
215 y >= totalHeight_)
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
216 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
217 LOG(ERROR) << "Frame " << i << " with unexpected tile location ("
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
218 << x << "," << y << ") in instance: " << instanceId;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
219 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
220 }
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
221
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
222 frames_[i].first = x / tileWidth_;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
223 frames_[i].second = y / tileHeight_;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
224 }
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
225 }
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
226 else
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
227 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
228 // No "Per frame functional groups sequence" tag. Assume regular grid.
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
229 frames_.resize(tmp);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
230
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
231 // Compute "ceiling(totalWidth_ / tileWidth_)
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
232 unsigned int w = totalWidth_ / tileWidth_;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
233 if (totalWidth_ % tileWidth_ != 0)
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
234 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
235 w += 1;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
236 }
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
237
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
238 unsigned int h = totalHeight_ / tileHeight_;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
239 if (totalHeight_ % tileHeight_ != 0)
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
240 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
241 h += 1;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
242 }
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
243
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
244 if (w * h != tmp)
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
245 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
246 LOG(ERROR) << "Mismatch between the number of frames in instance: " << instanceId;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
247 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
248 }
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
249
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
250 for (size_t i = 0; i < frames_.size(); i++)
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
251 {
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
252 frames_[i].first = i % w;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
253 frames_[i].second = i / w;
02cb86d07966 Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
254 }
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
259 DicomPyramidInstance::DicomPyramidInstance(OrthancStone::IOrthancConnection& orthanc,
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
260 const std::string& instanceId,
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
261 bool useCache) :
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
262 instanceId_(instanceId),
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
263 hasCompression_(false)
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
264 {
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
265 if (useCache)
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
266 {
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
267 try
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
268 {
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
269 // Try and deserialized the cached information about this instance
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
270 std::string serialized;
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
271 orthanc.RestApiGet(serialized, "/instances/" + instanceId + "/metadata/" + SERIALIZED_METADATA);
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
272 Deserialize(serialized);
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
273 return; // Success
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
274 }
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
275 catch (Orthanc::OrthancException&)
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
276 {
70
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
277 // No cached information yet
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
278 }
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
279 }
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
280
70
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
281 // Compute information about this instance from scratch
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
282 Load(orthanc, instanceId);
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
283
70
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
284 if (useCache)
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
285 {
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
286 // Serialize the computed information and cache it as a metadata
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
287 std::string serialized, tmp;
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
288 Serialize(serialized);
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
289 orthanc.RestApiPut(tmp, "/instances/" + instanceId + "/metadata/" + SERIALIZED_METADATA, serialized);
f2c179294382 improvement
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 69
diff changeset
290 }
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
291 }
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
292
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
293
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 unsigned int DicomPyramidInstance::GetFrameLocationX(size_t frame) const
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 {
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 assert(frame < frames_.size());
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 return frames_[frame].first;
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 }
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 unsigned int DicomPyramidInstance::GetFrameLocationY(size_t frame) const
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 {
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 assert(frame < frames_.size());
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 return frames_[frame].second;
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 }
64
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
306
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
307
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
308 void DicomPyramidInstance::Serialize(std::string& result) const
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
309 {
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
310 Json::Value frames = Json::arrayValue;
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
311 for (size_t i = 0; i < frames_.size(); i++)
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
312 {
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
313 Json::Value frame = Json::arrayValue;
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
314 frame.append(frames_[i].first);
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
315 frame.append(frames_[i].second);
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
316
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
317 frames.append(frame);
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
318 }
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
319
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
320 Json::Value content;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
321 content["Frames"] = frames;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
322 content["TileHeight"] = tileHeight_;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
323 content["TileWidth"] = tileWidth_;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
324 content["TotalHeight"] = totalHeight_;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
325 content["TotalWidth"] = totalWidth_;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
326
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
327 switch (format_)
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
328 {
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
329 case Orthanc::PixelFormat_RGB24:
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
330 content["PixelFormat"] = 0;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
331 break;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
332
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
333 case Orthanc::PixelFormat_Grayscale8:
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
334 content["PixelFormat"] = 1;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
335 break;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
336
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
337 default:
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
338 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
339 }
64
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
340
213
2a4e1f7de5ab remove calls to deprecated classes of JsonCpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
341 Orthanc::Toolbox::WriteFastJson(result, content);
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
342 }
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
343
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
344
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
345 void DicomPyramidInstance::Deserialize(const std::string& s)
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
346 {
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
347 hasCompression_ = false;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
348
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
349 Json::Value content;
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
350 OrthancStone::IOrthancConnection::ParseJson(content, s);
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
351
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
352 if (content.type() != Json::objectValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
353 !content.isMember("Frames") ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
354 !content.isMember("PixelFormat") ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
355 !content.isMember("TileHeight") ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
356 !content.isMember("TileWidth") ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
357 !content.isMember("TotalHeight") ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
358 !content.isMember("TotalWidth") ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
359 content["Frames"].type() != Json::arrayValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
360 content["PixelFormat"].type() != Json::intValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
361 content["TileHeight"].type() != Json::intValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
362 content["TileWidth"].type() != Json::intValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
363 content["TotalHeight"].type() != Json::intValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
364 content["TotalWidth"].type() != Json::intValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
365 content["TileHeight"].asInt() < 0 ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
366 content["TileWidth"].asInt() < 0 ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
367 content["TotalHeight"].asInt() < 0 ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
368 content["TotalWidth"].asInt() < 0)
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
369 {
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
370 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
371 }
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
372
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
373 switch (content["PixelFormat"].asInt())
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
374 {
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
375 case 0:
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
376 format_ = Orthanc::PixelFormat_RGB24;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
377 break;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
378
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
379 case 1:
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
380 format_ = Orthanc::PixelFormat_Grayscale8;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
381 break;
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
382
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
383 default:
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
384 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
385 }
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
386
69
d529d9ce3c7e cache for DicomPyramidInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 68
diff changeset
387 hasCompression_ = false;
68
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
388 tileHeight_ = static_cast<unsigned int>(content["TileHeight"].asInt());
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
389 tileWidth_ = static_cast<unsigned int>(content["TileWidth"].asInt());
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
390 totalHeight_ = static_cast<unsigned int>(content["TotalHeight"].asInt());
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
391 totalWidth_ = static_cast<unsigned int>(content["TotalWidth"].asInt());
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
392
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
393 const Json::Value f = content["Frames"];
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
394 frames_.resize(f.size());
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
395
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
396 for (Json::Value::ArrayIndex i = 0; i < f.size(); i++)
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
397 {
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
398 if (f[i].type() != Json::arrayValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
399 f[i].size() != 2 ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
400 f[i][0].type() != Json::intValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
401 f[i][1].type() != Json::intValue ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
402 f[i][0].asInt() < 0 ||
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
403 f[i][1].asInt() < 0)
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
404 {
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
405 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
406 }
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
407
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
408 frames_[i].first = f[i][0].asInt();
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
409 frames_[i].second = f[i][1].asInt();
c619c8bd72ed DicomPyramidInstance::Deserialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
410 }
64
63d0a5c74460 DicomPyramidInstance::Serialize
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
411 }
0
4a7a53257c7d initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 }