Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp @ 1642:5cc589bfb385
lazy computation of DicomInstanceParameters::GetImageInformation()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Nov 2020 17:21:23 +0100 |
parents | 5cdc5b98f14d |
children | 4e14735e98f8 |
comparison
equal
deleted
inserted
replaced
1641:df4fd96c5706 | 1642:5cc589bfb385 |
---|---|
66 target.resize(0); | 66 target.resize(0); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 DicomInstanceParameters::Data::Data(const Orthanc::DicomMap& dicom) : | 71 DicomInstanceParameters::Data::Data(const Orthanc::DicomMap& dicom) |
72 imageInformation_(dicom) | |
73 { | 72 { |
74 if (!dicom.LookupStringValue(studyInstanceUid_, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) || | 73 if (!dicom.LookupStringValue(studyInstanceUid_, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) || |
75 !dicom.LookupStringValue(seriesInstanceUid_, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) || | 74 !dicom.LookupStringValue(seriesInstanceUid_, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) || |
76 !dicom.LookupStringValue(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false)) | 75 !dicom.LookupStringValue(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false)) |
77 { | 76 { |
204 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_INSTANCE_NUMBER) || | 203 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_INSTANCE_NUMBER) || |
205 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_IMAGE_INDEX)); | 204 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_IMAGE_INDEX)); |
206 } | 205 } |
207 | 206 |
208 | 207 |
208 const Orthanc::DicomImageInformation& DicomInstanceParameters::GetImageInformation() const | |
209 { | |
210 assert(tags_.get() != NULL); | |
211 | |
212 if (imageInformation_.get() == NULL) | |
213 { | |
214 const_cast<DicomInstanceParameters&>(*this).imageInformation_. | |
215 reset(new Orthanc::DicomImageInformation(GetTags())); | |
216 | |
217 assert(imageInformation_->GetWidth() == GetWidth()); | |
218 assert(imageInformation_->GetHeight() == GetHeight()); | |
219 assert(imageInformation_->GetNumberOfFrames() == GetNumberOfFrames()); | |
220 } | |
221 | |
222 assert(imageInformation_.get() != NULL); | |
223 return *imageInformation_; | |
224 } | |
225 | |
226 | |
209 CoordinateSystem3D DicomInstanceParameters::GetFrameGeometry(unsigned int frame) const | 227 CoordinateSystem3D DicomInstanceParameters::GetFrameGeometry(unsigned int frame) const |
210 { | 228 { |
211 if (frame >= data_.numberOfFrames_) | 229 if (frame >= data_.numberOfFrames_) |
212 { | 230 { |
213 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 231 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
251 | 269 |
252 | 270 |
253 bool DicomInstanceParameters::IsColor() const | 271 bool DicomInstanceParameters::IsColor() const |
254 { | 272 { |
255 Orthanc::PhotometricInterpretation photometric = | 273 Orthanc::PhotometricInterpretation photometric = |
256 data_.imageInformation_.GetPhotometricInterpretation(); | 274 GetImageInformation().GetPhotometricInterpretation(); |
257 | 275 |
258 return (photometric != Orthanc::PhotometricInterpretation_Monochrome1 && | 276 return (photometric != Orthanc::PhotometricInterpretation_Monochrome1 && |
259 photometric != Orthanc::PhotometricInterpretation_Monochrome2); | 277 photometric != Orthanc::PhotometricInterpretation_Monochrome2); |
260 } | 278 } |
261 | 279 |
463 { | 481 { |
464 texture->SetCustomWindowing(data_.defaultWindowingCenter_, | 482 texture->SetCustomWindowing(data_.defaultWindowingCenter_, |
465 data_.defaultWindowingWidth_); | 483 data_.defaultWindowingWidth_); |
466 } | 484 } |
467 | 485 |
468 switch (data_.imageInformation_.GetPhotometricInterpretation()) | 486 switch (GetImageInformation().GetPhotometricInterpretation()) |
469 { | 487 { |
470 case Orthanc::PhotometricInterpretation_Monochrome1: | 488 case Orthanc::PhotometricInterpretation_Monochrome1: |
471 texture->SetInverted(true); | 489 texture->SetInverted(true); |
472 break; | 490 break; |
473 | 491 |