comparison Framework/Toolbox/Slice.cpp @ 118:a4d0b6c82b29 wasm

using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Oct 2017 14:31:26 +0200
parents 42c05a3baee3
children ba83e38cf3ff
comparison
equal deleted inserted replaced
117:42c05a3baee3 118:a4d0b6c82b29
43 { 43 {
44 return false; 44 return false;
45 } 45 }
46 } 46 }
47 47
48 bool Slice::ComputeRTDoseGeometry(const OrthancPlugins::DicomDatasetReader& reader, 48 bool Slice::ComputeRTDoseGeometry(const Orthanc::DicomMap& dataset,
49 unsigned int frame) 49 unsigned int frame)
50 { 50 {
51 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html 51 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html
52 static const OrthancPlugins::DicomTag DICOM_TAG_GRID_FRAME_OFFSET_VECTOR(0x3004, 0x000c); 52
53 static const OrthancPlugins::DicomTag DICOM_TAG_FRAME_INCREMENT_POINTER(0x0028, 0x0009); 53 std::string increment, offsetTag;
54 54
55 std::string increment = reader.GetStringValue(DICOM_TAG_FRAME_INCREMENT_POINTER, ""); 55 if (!dataset.CopyToString(increment, Orthanc::DICOM_TAG_FRAME_INCREMENT_POINTER, false) ||
56 std::string offsetTag; 56 !dataset.CopyToString(offsetTag, Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR, false))
57
58 bool ok = reader.GetDataset().GetStringValue(offsetTag, DICOM_TAG_GRID_FRAME_OFFSET_VECTOR);
59 if (!ok)
60 { 57 {
61 LOG(ERROR) << "Cannot read the \"GridFrameOffsetVector\" tag, check you are using Orthanc >= 1.3.1"; 58 LOG(ERROR) << "Cannot read the \"GridFrameOffsetVector\" tag, check you are using Orthanc >= 1.3.1";
62 return false; 59 return false;
63 } 60 }
64 61
101 98
102 return true; 99 return true;
103 } 100 }
104 101
105 102
106 bool Slice::ParseOrthancFrame(const OrthancPlugins::IDicomDataset& dataset, 103 bool Slice::ParseOrthancFrame(const Orthanc::DicomMap& dataset,
107 const std::string& instanceId, 104 const std::string& instanceId,
108 unsigned int frame) 105 unsigned int frame)
109 { 106 {
110 orthancInstanceId_ = instanceId; 107 orthancInstanceId_ = instanceId;
111 frame_ = frame; 108 frame_ = frame;
112 type_ = Type_OrthancDecodableFrame; 109 type_ = Type_OrthancDecodableFrame;
113 110
114 OrthancPlugins::DicomDatasetReader reader(dataset); 111 if (!dataset.CopyToString(sopClassUid_, Orthanc::DICOM_TAG_SOP_CLASS_UID, false) ||
115 112 sopClassUid_.empty())
116 sopClassUid_ = reader.GetStringValue(OrthancPlugins::DICOM_TAG_SOP_CLASS_UID, "");
117 if (sopClassUid_.empty())
118 { 113 {
119 LOG(ERROR) << "Instance without a SOP class UID"; 114 LOG(ERROR) << "Instance without a SOP class UID";
120 return false; 115 return false;
121 } 116 }
122 117
123 if (!reader.GetUnsignedIntegerValue(frameCount_, OrthancPlugins::DICOM_TAG_NUMBER_OF_FRAMES)) 118 if (!dataset.ParseUnsignedInteger32(frameCount_, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES))
124 { 119 {
125 frameCount_ = 1; // Assume instance with one frame 120 frameCount_ = 1; // Assume instance with one frame
126 } 121 }
127 122
128 if (frame >= frameCount_) 123 if (frame >= frameCount_)
129 { 124 {
130 return false; 125 return false;
131 } 126 }
132 127
133 if (!reader.GetUnsignedIntegerValue(width_, OrthancPlugins::DICOM_TAG_COLUMNS) || 128 if (!dataset.ParseUnsignedInteger32(width_, Orthanc::DICOM_TAG_COLUMNS) ||
134 !reader.GetUnsignedIntegerValue(height_, OrthancPlugins::DICOM_TAG_ROWS)) 129 !dataset.ParseUnsignedInteger32(height_, Orthanc::DICOM_TAG_ROWS))
135 { 130 {
136 return false; 131 return false;
137 } 132 }
138 133
139 thickness_ = 100.0 * std::numeric_limits<double>::epsilon(); 134 thickness_ = 100.0 * std::numeric_limits<double>::epsilon();
140 135
141 std::string tmp; 136 std::string tmp;
142 if (dataset.GetStringValue(tmp, OrthancPlugins::DICOM_TAG_SLICE_THICKNESS)) 137 if (dataset.CopyToString(tmp, Orthanc::DICOM_TAG_SLICE_THICKNESS, false))
143 { 138 {
144 if (!tmp.empty() && 139 if (!tmp.empty() &&
145 !ParseDouble(thickness_, tmp)) 140 !ParseDouble(thickness_, tmp))
146 { 141 {
147 return false; // Syntax error 142 return false; // Syntax error
151 converter_.ReadParameters(dataset); 146 converter_.ReadParameters(dataset);
152 147
153 GeometryToolbox::GetPixelSpacing(pixelSpacingX_, pixelSpacingY_, dataset); 148 GeometryToolbox::GetPixelSpacing(pixelSpacingX_, pixelSpacingY_, dataset);
154 149
155 std::string position, orientation; 150 std::string position, orientation;
156 if (dataset.GetStringValue(position, OrthancPlugins::DICOM_TAG_IMAGE_POSITION_PATIENT) && 151 if (dataset.CopyToString(position, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT, false) &&
157 dataset.GetStringValue(orientation, OrthancPlugins::DICOM_TAG_IMAGE_ORIENTATION_PATIENT)) 152 dataset.CopyToString(orientation, Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false))
158 { 153 {
159 geometry_ = CoordinateSystem3D(position, orientation); 154 geometry_ = CoordinateSystem3D(position, orientation);
160 155
161 bool ok = true; 156 bool ok = true;
162 SopClassUid tmp; 157 SopClassUid tmp;
165 { 160 {
166 switch (tmp) 161 switch (tmp)
167 { 162 {
168 case SopClassUid_RTDose: 163 case SopClassUid_RTDose:
169 type_ = Type_OrthancRawFrame; 164 type_ = Type_OrthancRawFrame;
170 ok = ComputeRTDoseGeometry(reader, frame); 165 ok = ComputeRTDoseGeometry(dataset, frame);
171 break; 166 break;
172 167
173 default: 168 default:
174 break; 169 break;
175 } 170 }