comparison OrthancStone/Sources/Toolbox/DicomInstanceParameters.h @ 1642:5cc589bfb385

lazy computation of DicomInstanceParameters::GetImageInformation()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Nov 2020 17:21:23 +0100
parents d569effcd433
children 4e14735e98f8
comparison
equal deleted inserted replaced
1641:df4fd96c5706 1642:5cc589bfb385
20 **/ 20 **/
21 21
22 22
23 #pragma once 23 #pragma once
24 24
25 #include "../Scene2D/LookupTableTextureSceneLayer.h"
25 #include "../StoneEnumerations.h" 26 #include "../StoneEnumerations.h"
26 #include "../Scene2D/LookupTableTextureSceneLayer.h"
27 #include "../Toolbox/CoordinateSystem3D.h" 27 #include "../Toolbox/CoordinateSystem3D.h"
28 28
29 #include <IDynamicObject.h> 29 #include <IDynamicObject.h>
30 #include <DicomFormat/DicomImageInformation.h> 30 #include <DicomFormat/DicomImageInformation.h>
31 31
37 // This class supersedes the deprecated "DicomFrameConverter" 37 // This class supersedes the deprecated "DicomFrameConverter"
38 38
39 private: 39 private:
40 struct Data // Plain old struct to ease the copy constructor 40 struct Data // Plain old struct to ease the copy constructor
41 { 41 {
42 std::string orthancInstanceId_; 42 std::string orthancInstanceId_;
43 std::string studyInstanceUid_; 43 std::string studyInstanceUid_;
44 std::string seriesInstanceUid_; 44 std::string seriesInstanceUid_;
45 std::string sopInstanceUid_; 45 std::string sopInstanceUid_;
46 Orthanc::DicomImageInformation imageInformation_; // TODO REMOVE 46 SopClassUid sopClassUid_;
47 SopClassUid sopClassUid_; 47 unsigned int numberOfFrames_;
48 unsigned int numberOfFrames_; 48 unsigned int width_;
49 unsigned int width_; 49 unsigned int height_;
50 unsigned int height_; 50 double sliceThickness_;
51 double sliceThickness_; 51 double pixelSpacingX_;
52 double pixelSpacingX_; 52 double pixelSpacingY_;
53 double pixelSpacingY_; 53 CoordinateSystem3D geometry_;
54 CoordinateSystem3D geometry_; 54 Vector frameOffsets_;
55 Vector frameOffsets_; 55 bool hasRescale_;
56 bool hasRescale_; 56 double rescaleIntercept_;
57 double rescaleIntercept_; 57 double rescaleSlope_;
58 double rescaleSlope_; 58 bool hasDefaultWindowing_;
59 bool hasDefaultWindowing_; 59 float defaultWindowingCenter_;
60 float defaultWindowingCenter_; 60 float defaultWindowingWidth_;
61 float defaultWindowingWidth_; 61 bool hasIndexInSeries_;
62 bool hasIndexInSeries_; 62 unsigned int indexInSeries_;
63 unsigned int indexInSeries_; 63 std::string doseUnits_;
64 std::string doseUnits_; 64 double doseGridScaling_;
65 double doseGridScaling_;
66 65
67 explicit Data(const Orthanc::DicomMap& dicom); 66 explicit Data(const Orthanc::DicomMap& dicom);
68 }; 67 };
69 68
70 69
71 Data data_; 70 Data data_;
71 std::unique_ptr<Orthanc::DicomMap> tags_;
72 std::unique_ptr<Orthanc::DicomImageInformation> imageInformation_; // Lazy evaluation
72 73
73 void ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image, 74 void ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image,
74 bool useDouble) const; 75 bool useDouble) const;
75 76
76 public: 77 public:
77 explicit DicomInstanceParameters(const DicomInstanceParameters& other) : 78 explicit DicomInstanceParameters(const DicomInstanceParameters& other) :
78 data_(other.data_) 79 data_(other.data_),
80 tags_(other.tags_->Clone())
79 { 81 {
80 } 82 }
81 83
82 explicit DicomInstanceParameters(const Orthanc::DicomMap& dicom) : 84 explicit DicomInstanceParameters(const Orthanc::DicomMap& dicom) :
83 data_(dicom) 85 data_(dicom),
86 tags_(dicom.Clone())
84 { 87 {
85 } 88 }
86 89
87 DicomInstanceParameters* Clone() const 90 DicomInstanceParameters* Clone() const
88 { 91 {
97 const std::string& GetOrthancInstanceIdentifier() const 100 const std::string& GetOrthancInstanceIdentifier() const
98 { 101 {
99 return data_.orthancInstanceId_; 102 return data_.orthancInstanceId_;
100 } 103 }
101 104
102 const Orthanc::DicomImageInformation& GetImageInformation() const 105 const Orthanc::DicomMap& GetTags() const
103 { 106 {
104 return data_.imageInformation_; 107 return *tags_;
105 } 108 }
106 109
107 const std::string& GetStudyInstanceUid() const 110 const std::string& GetStudyInstanceUid() const
108 { 111 {
109 return data_.studyInstanceUid_; 112 return data_.studyInstanceUid_;
156 159
157 const CoordinateSystem3D& GetGeometry() const 160 const CoordinateSystem3D& GetGeometry() const
158 { 161 {
159 return data_.geometry_; 162 return data_.geometry_;
160 } 163 }
164
165 // WARNING - Calling this method can throw exception
166 const Orthanc::DicomImageInformation& GetImageInformation() const;
161 167
162 CoordinateSystem3D GetFrameGeometry(unsigned int frame) const; 168 CoordinateSystem3D GetFrameGeometry(unsigned int frame) const;
163 169
164 bool IsPlaneWithinSlice(unsigned int frame, 170 bool IsPlaneWithinSlice(unsigned int frame,
165 const CoordinateSystem3D& plane) const; 171 const CoordinateSystem3D& plane) const;