Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/DicomInstanceParameters.cpp @ 1054:3c9529edf5fd
fixing WebAssemblyViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Oct 2019 15:55:54 +0200 |
parents | dd8ff977aaf2 |
children | 5a18e6a395bc |
rev | line source |
---|---|
746 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "DicomInstanceParameters.h" | |
23 | |
24 #include "../Scene2D/ColorTextureSceneLayer.h" | |
25 #include "../Scene2D/FloatTextureSceneLayer.h" | |
26 #include "../Toolbox/GeometryToolbox.h" | |
27 | |
28 #include <Core/Images/Image.h> | |
29 #include <Core/Images/ImageProcessing.h> | |
30 #include <Core/Logging.h> | |
31 #include <Core/OrthancException.h> | |
32 #include <Core/Toolbox.h> | |
33 | |
34 | |
35 namespace OrthancStone | |
36 { | |
37 void DicomInstanceParameters::Data::ComputeDoseOffsets(const Orthanc::DicomMap& dicom) | |
38 { | |
39 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html | |
40 | |
41 { | |
42 std::string increment; | |
43 | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
44 if (dicom.LookupStringValue(increment, Orthanc::DICOM_TAG_FRAME_INCREMENT_POINTER, false)) |
746 | 45 { |
46 Orthanc::Toolbox::ToUpperCase(increment); | |
949
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
768
diff
changeset
|
47 if (increment != "3004,000C") // This is the "Grid Frame Offset Vector" tag (DICOM_TAG_GRID_FRAME_OFFSET_VECTOR) |
746 | 48 { |
49 LOG(ERROR) << "RT-DOSE: Bad value for the \"FrameIncrementPointer\" tag"; | |
50 return; | |
51 } | |
52 } | |
53 } | |
54 | |
55 if (!LinearAlgebra::ParseVector(frameOffsets_, dicom, Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR) || | |
56 frameOffsets_.size() < imageInformation_.GetNumberOfFrames()) | |
57 { | |
58 LOG(ERROR) << "RT-DOSE: No information about the 3D location of some slice(s)"; | |
59 frameOffsets_.clear(); | |
60 } | |
61 else | |
62 { | |
63 if (frameOffsets_.size() >= 2) | |
64 { | |
762
26f4345e771e
creation of OrthancMultiframeVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
757
diff
changeset
|
65 thickness_ = std::abs(frameOffsets_[1] - frameOffsets_[0]); |
746 | 66 } |
67 } | |
68 } | |
69 | |
70 | |
71 DicomInstanceParameters::Data::Data(const Orthanc::DicomMap& dicom) : | |
72 imageInformation_(dicom) | |
73 { | |
74 if (imageInformation_.GetNumberOfFrames() <= 0) | |
75 { | |
76 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
77 } | |
78 | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
79 if (!dicom.LookupStringValue(studyInstanceUid_, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) || |
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
80 !dicom.LookupStringValue(seriesInstanceUid_, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) || |
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
81 !dicom.LookupStringValue(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false)) |
746 | 82 { |
83 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
84 } | |
85 | |
86 std::string s; | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
87 if (!dicom.LookupStringValue(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false)) |
746 | 88 { |
89 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
90 } | |
91 else | |
92 { | |
93 sopClassUid_ = StringToSopClassUid(s); | |
94 } | |
95 | |
96 if (!dicom.ParseDouble(thickness_, Orthanc::DICOM_TAG_SLICE_THICKNESS)) | |
97 { | |
98 thickness_ = 100.0 * std::numeric_limits<double>::epsilon(); | |
99 } | |
100 | |
101 GeometryToolbox::GetPixelSpacing(pixelSpacingX_, pixelSpacingY_, dicom); | |
102 | |
103 std::string position, orientation; | |
994
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
104 if (dicom.LookupStringValue(position, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT, false) && |
1f74bc3459ba
fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
980
diff
changeset
|
105 dicom.LookupStringValue(orientation, Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false)) |
746 | 106 { |
107 geometry_ = CoordinateSystem3D(position, orientation); | |
108 } | |
109 | |
110 if (sopClassUid_ == SopClassUid_RTDose) | |
111 { | |
112 ComputeDoseOffsets(dicom); | |
113 } | |
114 | |
115 isColor_ = (imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome1 && | |
116 imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome2); | |
117 | |
118 double doseGridScaling; | |
119 | |
120 if (dicom.ParseDouble(rescaleIntercept_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) && | |
121 dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE)) | |
122 { | |
123 hasRescale_ = true; | |
124 } | |
125 else if (dicom.ParseDouble(doseGridScaling, Orthanc::DICOM_TAG_DOSE_GRID_SCALING)) | |
126 { | |
127 hasRescale_ = true; | |
128 rescaleIntercept_ = 0; | |
129 rescaleSlope_ = doseGridScaling; | |
130 } | |
131 else | |
132 { | |
133 hasRescale_ = false; | |
134 } | |
135 | |
136 Vector c, w; | |
137 if (LinearAlgebra::ParseVector(c, dicom, Orthanc::DICOM_TAG_WINDOW_CENTER) && | |
138 LinearAlgebra::ParseVector(w, dicom, Orthanc::DICOM_TAG_WINDOW_WIDTH) && | |
139 c.size() > 0 && | |
140 w.size() > 0) | |
141 { | |
142 hasDefaultWindowing_ = true; | |
143 defaultWindowingCenter_ = static_cast<float>(c[0]); | |
144 defaultWindowingWidth_ = static_cast<float>(w[0]); | |
145 } | |
146 else | |
147 { | |
148 hasDefaultWindowing_ = false; | |
149 } | |
150 | |
151 if (sopClassUid_ == SopClassUid_RTDose) | |
152 { | |
153 switch (imageInformation_.GetBitsStored()) | |
154 { | |
155 case 16: | |
156 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16; | |
157 break; | |
158 | |
159 case 32: | |
160 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale32; | |
161 break; | |
162 | |
163 default: | |
164 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
165 } | |
166 } | |
167 else if (isColor_) | |
168 { | |
169 expectedPixelFormat_ = Orthanc::PixelFormat_RGB24; | |
170 } | |
171 else if (imageInformation_.IsSigned()) | |
172 { | |
173 expectedPixelFormat_ = Orthanc::PixelFormat_SignedGrayscale16; | |
174 } | |
175 else | |
176 { | |
177 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16; | |
178 } | |
980
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
179 |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
180 // This computes the "IndexInSeries" metadata from Orthanc (check |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
181 // out "Orthanc::ServerIndex::Store()") |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
182 hasIndexInSeries_ = ( |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
183 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_INSTANCE_NUMBER) || |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
184 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_IMAGE_INDEX)); |
746 | 185 } |
186 | |
187 | |
188 CoordinateSystem3D DicomInstanceParameters::Data::GetFrameGeometry(unsigned int frame) const | |
189 { | |
190 if (frame == 0) | |
191 { | |
192 return geometry_; | |
193 } | |
194 else if (frame >= imageInformation_.GetNumberOfFrames()) | |
195 { | |
196 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
197 } | |
198 else if (sopClassUid_ == SopClassUid_RTDose) | |
199 { | |
200 if (frame >= frameOffsets_.size()) | |
201 { | |
202 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
203 } | |
204 | |
205 return CoordinateSystem3D( | |
206 geometry_.GetOrigin() + frameOffsets_[frame] * geometry_.GetNormal(), | |
207 geometry_.GetAxisX(), | |
208 geometry_.GetAxisY()); | |
209 } | |
210 else | |
211 { | |
212 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
213 } | |
214 } | |
215 | |
216 | |
217 bool DicomInstanceParameters::Data::IsPlaneWithinSlice(unsigned int frame, | |
218 const CoordinateSystem3D& plane) const | |
219 { | |
220 if (frame >= imageInformation_.GetNumberOfFrames()) | |
221 { | |
222 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
223 } | |
224 | |
225 CoordinateSystem3D tmp = geometry_; | |
226 | |
227 if (frame != 0) | |
228 { | |
229 tmp = GetFrameGeometry(frame); | |
230 } | |
231 | |
232 double distance; | |
233 | |
757 | 234 return (CoordinateSystem3D::ComputeDistance(distance, tmp, plane) && |
746 | 235 distance <= thickness_ / 2.0); |
236 } | |
237 | |
238 | |
239 void DicomInstanceParameters::Data::ApplyRescale(Orthanc::ImageAccessor& image, | |
240 bool useDouble) const | |
241 { | |
242 if (image.GetFormat() != Orthanc::PixelFormat_Float32) | |
243 { | |
244 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); | |
245 } | |
246 | |
247 if (hasRescale_) | |
248 { | |
249 const unsigned int width = image.GetWidth(); | |
250 const unsigned int height = image.GetHeight(); | |
251 | |
252 for (unsigned int y = 0; y < height; y++) | |
253 { | |
254 float* p = reinterpret_cast<float*>(image.GetRow(y)); | |
255 | |
256 if (useDouble) | |
257 { | |
258 // Slower, accurate implementation using double | |
259 for (unsigned int x = 0; x < width; x++, p++) | |
260 { | |
261 double value = static_cast<double>(*p); | |
262 *p = static_cast<float>(value * rescaleSlope_ + rescaleIntercept_); | |
263 } | |
264 } | |
265 else | |
266 { | |
267 // Fast, approximate implementation using float | |
268 for (unsigned int x = 0; x < width; x++, p++) | |
269 { | |
270 *p = (*p) * static_cast<float>(rescaleSlope_) + static_cast<float>(rescaleIntercept_); | |
271 } | |
272 } | |
273 } | |
274 } | |
275 } | |
276 | |
277 double DicomInstanceParameters::GetRescaleIntercept() const | |
278 { | |
279 if (data_.hasRescale_) | |
280 { | |
281 return data_.rescaleIntercept_; | |
282 } | |
283 else | |
284 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
285 LOG(ERROR) << "DicomInstanceParameters::GetRescaleIntercept(): !data_.hasRescale_"; |
746 | 286 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
287 } | |
288 } | |
289 | |
290 | |
291 double DicomInstanceParameters::GetRescaleSlope() const | |
292 { | |
293 if (data_.hasRescale_) | |
294 { | |
295 return data_.rescaleSlope_; | |
296 } | |
297 else | |
298 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
299 LOG(ERROR) << "DicomInstanceParameters::GetRescaleSlope(): !data_.hasRescale_"; |
746 | 300 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
301 } | |
302 } | |
303 | |
304 | |
305 float DicomInstanceParameters::GetDefaultWindowingCenter() const | |
306 { | |
307 if (data_.hasDefaultWindowing_) | |
308 { | |
309 return data_.defaultWindowingCenter_; | |
310 } | |
311 else | |
312 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
313 LOG(ERROR) << "DicomInstanceParameters::GetDefaultWindowingCenter(): !data_.hasRescale_"; |
746 | 314 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
315 } | |
316 } | |
317 | |
318 | |
319 float DicomInstanceParameters::GetDefaultWindowingWidth() const | |
320 { | |
321 if (data_.hasDefaultWindowing_) | |
322 { | |
323 return data_.defaultWindowingWidth_; | |
324 } | |
325 else | |
326 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
327 LOG(ERROR) << "DicomInstanceParameters::GetDefaultWindowingWidth(): !data_.hasRescale_"; |
746 | 328 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
329 } | |
330 } | |
331 | |
332 | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
333 Orthanc::ImageAccessor* DicomInstanceParameters::ConvertToFloat(const Orthanc::ImageAccessor& pixelData) const |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
334 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
335 std::auto_ptr<Orthanc::Image> converted(new Orthanc::Image(Orthanc::PixelFormat_Float32, |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
336 pixelData.GetWidth(), |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
337 pixelData.GetHeight(), |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
338 false)); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
339 Orthanc::ImageProcessing::Convert(*converted, pixelData); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
340 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
341 // Correct rescale slope/intercept if need be |
1026 | 342 //data_.ApplyRescale(*converted, (pixelData.GetFormat() == Orthanc::PixelFormat_Grayscale32)); |
1027
dd8ff977aaf2
remove wrong comment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1026
diff
changeset
|
343 data_.ApplyRescale(*converted, false); |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
344 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
345 return converted.release(); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
346 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
347 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
348 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
349 TextureBaseSceneLayer* DicomInstanceParameters::CreateTexture |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
350 (const Orthanc::ImageAccessor& pixelData) const |
746 | 351 { |
352 assert(sizeof(float) == 4); | |
353 | |
354 Orthanc::PixelFormat sourceFormat = pixelData.GetFormat(); | |
355 | |
356 if (sourceFormat != GetExpectedPixelFormat()) | |
357 { | |
358 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); | |
359 } | |
360 | |
361 if (sourceFormat == Orthanc::PixelFormat_RGB24) | |
362 { | |
363 // This is the case of a color image. No conversion has to be done. | |
364 return new ColorTextureSceneLayer(pixelData); | |
365 } | |
366 else | |
367 { | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
368 // This is the case of a grayscale frame. Convert it to Float32. |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
369 std::auto_ptr<FloatTextureSceneLayer> texture; |
746 | 370 |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
371 if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) |
746 | 372 { |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
373 texture.reset(new FloatTextureSceneLayer(pixelData)); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
374 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
375 else |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
376 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
377 std::auto_ptr<Orthanc::ImageAccessor> converted(ConvertToFloat(pixelData)); |
746 | 378 texture.reset(new FloatTextureSceneLayer(*converted)); |
379 } | |
380 | |
381 if (data_.hasDefaultWindowing_) | |
382 { | |
383 texture->SetCustomWindowing(data_.defaultWindowingCenter_, | |
384 data_.defaultWindowingWidth_); | |
385 } | |
386 | |
387 return texture.release(); | |
388 } | |
389 } | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
390 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
391 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
392 LookupTableTextureSceneLayer* DicomInstanceParameters::CreateLookupTableTexture |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
393 (const Orthanc::ImageAccessor& pixelData) const |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
394 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
395 std::auto_ptr<FloatTextureSceneLayer> texture; |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
396 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
397 if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
398 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
399 return new LookupTableTextureSceneLayer(pixelData); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
400 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
401 else |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
402 { |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
403 std::auto_ptr<Orthanc::ImageAccessor> converted(ConvertToFloat(pixelData)); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
404 return new LookupTableTextureSceneLayer(*converted); |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
405 } |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
762
diff
changeset
|
406 } |
980
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
407 |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
408 |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
409 unsigned int DicomInstanceParameters::GetIndexInSeries() const |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
410 { |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
411 if (data_.hasIndexInSeries_) |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
412 { |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
413 return data_.indexInSeries_; |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
414 } |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
415 else |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
416 { |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
417 LOG(ERROR) << "DicomInstanceParameters::GetIndexInSeries(): !data_.hasIndexInSeries_"; |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
418 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
419 } |
8e497a4e3d96
DicomInstanceParameters::GetIndexInSeries()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
420 } |
746 | 421 } |