Mercurial > hg > orthanc
annotate Core/DicomFormat/DicomMap.cpp @ 1706:e8a7512a1e40
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 13 Oct 2015 16:48:02 +0200 |
parents | 9980875edc7c |
children | 2ca7888f8600 |
rev | line source |
---|---|
0 | 1 /** |
59 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1206
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1206
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
0 | 5 * |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
136 | 10 * |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
0 | 22 * |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
730
diff
changeset
|
33 #include "../PrecompiledHeaders.h" |
0 | 34 #include "DicomMap.h" |
35 | |
36 #include <stdio.h> | |
37 #include <memory> | |
38 #include "DicomString.h" | |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
39 #include "DicomArray.h" |
59 | 40 #include "../OrthancException.h" |
0 | 41 |
42 | |
59 | 43 namespace Orthanc |
0 | 44 { |
45 static DicomTag patientTags[] = | |
46 { | |
38 | 47 //DicomTag(0x0010, 0x1010), // PatientAge |
48 //DicomTag(0x0010, 0x1040) // PatientAddress | |
77 | 49 DicomTag(0x0010, 0x0010), // PatientName |
50 DicomTag(0x0010, 0x0030), // PatientBirthDate | |
51 DicomTag(0x0010, 0x0040), // PatientSex | |
52 DicomTag(0x0010, 0x1000), // OtherPatientIDs | |
80 | 53 DICOM_TAG_PATIENT_ID |
0 | 54 }; |
55 | |
56 static DicomTag studyTags[] = | |
57 { | |
38 | 58 //DicomTag(0x0010, 0x1020), // PatientSize |
59 //DicomTag(0x0010, 0x1030) // PatientWeight | |
77 | 60 DicomTag(0x0008, 0x0020), // StudyDate |
61 DicomTag(0x0008, 0x0030), // StudyTime | |
62 DicomTag(0x0008, 0x1030), // StudyDescription | |
63 DicomTag(0x0020, 0x0010), // StudyID | |
80 | 64 DICOM_TAG_ACCESSION_NUMBER, |
65 DICOM_TAG_STUDY_INSTANCE_UID | |
0 | 66 }; |
67 | |
68 static DicomTag seriesTags[] = | |
69 { | |
38 | 70 //DicomTag(0x0010, 0x1080), // MilitaryRank |
77 | 71 DicomTag(0x0008, 0x0021), // SeriesDate |
72 DicomTag(0x0008, 0x0031), // SeriesTime | |
73 DicomTag(0x0008, 0x0060), // Modality | |
74 DicomTag(0x0008, 0x0070), // Manufacturer | |
75 DicomTag(0x0008, 0x1010), // StationName | |
76 DicomTag(0x0008, 0x103e), // SeriesDescription | |
77 DicomTag(0x0018, 0x0015), // BodyPartExamined | |
78 DicomTag(0x0018, 0x0024), // SequenceName | |
79 DicomTag(0x0018, 0x1030), // ProtocolName | |
80 DicomTag(0x0020, 0x0011), // SeriesNumber | |
433 | 81 DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES, |
80 | 82 DICOM_TAG_IMAGES_IN_ACQUISITION, |
433 | 83 DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, |
80 | 84 DICOM_TAG_NUMBER_OF_SLICES, |
433 | 85 DICOM_TAG_NUMBER_OF_TIME_SLICES, |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1372
diff
changeset
|
86 DICOM_TAG_SERIES_INSTANCE_UID, |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1372
diff
changeset
|
87 DICOM_TAG_IMAGE_ORIENTATION_PATIENT // New in db v6 |
0 | 88 }; |
89 | |
90 static DicomTag instanceTags[] = | |
91 { | |
77 | 92 DicomTag(0x0008, 0x0012), // InstanceCreationDate |
93 DicomTag(0x0008, 0x0013), // InstanceCreationTime | |
94 DicomTag(0x0020, 0x0012), // AcquisitionNumber | |
80 | 95 DICOM_TAG_IMAGE_INDEX, |
96 DICOM_TAG_INSTANCE_NUMBER, | |
84 | 97 DICOM_TAG_NUMBER_OF_FRAMES, |
433 | 98 DICOM_TAG_TEMPORAL_POSITION_IDENTIFIER, |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1372
diff
changeset
|
99 DICOM_TAG_SOP_INSTANCE_UID, |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1372
diff
changeset
|
100 DICOM_TAG_IMAGE_POSITION_PATIENT // New in db v6 |
0 | 101 }; |
102 | |
103 | |
104 | |
105 | |
106 void DicomMap::SetValue(uint16_t group, | |
107 uint16_t element, | |
108 DicomValue* value) | |
109 { | |
110 DicomTag tag(group, element); | |
111 Map::iterator it = map_.find(tag); | |
112 | |
113 if (it != map_.end()) | |
114 { | |
115 delete it->second; | |
116 it->second = value; | |
117 } | |
118 else | |
119 { | |
120 map_.insert(std::make_pair(tag, value)); | |
121 } | |
122 } | |
123 | |
124 void DicomMap::SetValue(DicomTag tag, | |
125 DicomValue* value) | |
126 { | |
127 SetValue(tag.GetGroup(), tag.GetElement(), value); | |
128 } | |
129 | |
130 | |
131 | |
132 | |
133 void DicomMap::Clear() | |
134 { | |
656 | 135 for (Map::iterator it = map_.begin(); it != map_.end(); ++it) |
0 | 136 { |
137 delete it->second; | |
138 } | |
139 | |
140 map_.clear(); | |
141 } | |
142 | |
143 | |
144 void DicomMap::ExtractTags(DicomMap& result, | |
145 const DicomTag* tags, | |
146 size_t count) const | |
147 { | |
148 result.Clear(); | |
149 | |
150 for (unsigned int i = 0; i < count; i++) | |
151 { | |
152 Map::const_iterator it = map_.find(tags[i]); | |
153 if (it != map_.end()) | |
154 { | |
155 result.SetValue(it->first, it->second->Clone()); | |
156 } | |
157 } | |
158 } | |
159 | |
160 | |
161 void DicomMap::ExtractPatientInformation(DicomMap& result) const | |
162 { | |
163 ExtractTags(result, patientTags, sizeof(patientTags) / sizeof(DicomTag)); | |
164 } | |
165 | |
166 void DicomMap::ExtractStudyInformation(DicomMap& result) const | |
167 { | |
168 ExtractTags(result, studyTags, sizeof(studyTags) / sizeof(DicomTag)); | |
169 } | |
170 | |
171 void DicomMap::ExtractSeriesInformation(DicomMap& result) const | |
172 { | |
173 ExtractTags(result, seriesTags, sizeof(seriesTags) / sizeof(DicomTag)); | |
174 } | |
175 | |
176 void DicomMap::ExtractInstanceInformation(DicomMap& result) const | |
177 { | |
178 ExtractTags(result, instanceTags, sizeof(instanceTags) / sizeof(DicomTag)); | |
179 } | |
180 | |
181 | |
80 | 182 |
0 | 183 DicomMap* DicomMap::Clone() const |
184 { | |
185 std::auto_ptr<DicomMap> result(new DicomMap); | |
186 | |
656 | 187 for (Map::const_iterator it = map_.begin(); it != map_.end(); ++it) |
0 | 188 { |
189 result->map_.insert(std::make_pair(it->first, it->second->Clone())); | |
190 } | |
191 | |
192 return result.release(); | |
193 } | |
194 | |
195 | |
1310
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
196 void DicomMap::Assign(const DicomMap& other) |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
197 { |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
198 Clear(); |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
199 |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
200 for (Map::const_iterator it = other.map_.begin(); it != other.map_.end(); ++it) |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
201 { |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
202 map_.insert(std::make_pair(it->first, it->second->Clone())); |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
203 } |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
204 } |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
205 |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
206 |
0 | 207 const DicomValue& DicomMap::GetValue(const DicomTag& tag) const |
208 { | |
80 | 209 const DicomValue* value = TestAndGetValue(tag); |
210 | |
211 if (value) | |
212 { | |
213 return *value; | |
214 } | |
215 else | |
216 { | |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
217 throw OrthancException(ErrorCode_InexistentTag); |
80 | 218 } |
219 } | |
220 | |
221 | |
222 const DicomValue* DicomMap::TestAndGetValue(const DicomTag& tag) const | |
223 { | |
0 | 224 Map::const_iterator it = map_.find(tag); |
225 | |
226 if (it == map_.end()) | |
227 { | |
80 | 228 return NULL; |
0 | 229 } |
230 else | |
231 { | |
80 | 232 return it->second; |
0 | 233 } |
234 } | |
235 | |
236 | |
237 void DicomMap::Remove(const DicomTag& tag) | |
238 { | |
239 Map::iterator it = map_.find(tag); | |
240 if (it != map_.end()) | |
241 { | |
242 delete it->second; | |
243 map_.erase(it); | |
244 } | |
245 } | |
246 | |
247 | |
248 static void SetupFindTemplate(DicomMap& result, | |
249 const DicomTag* tags, | |
250 size_t count) | |
251 { | |
252 result.Clear(); | |
253 | |
254 for (size_t i = 0; i < count; i++) | |
255 { | |
256 result.SetValue(tags[i], ""); | |
257 } | |
258 } | |
259 | |
260 void DicomMap::SetupFindPatientTemplate(DicomMap& result) | |
261 { | |
262 SetupFindTemplate(result, patientTags, sizeof(patientTags) / sizeof(DicomTag)); | |
263 } | |
264 | |
265 void DicomMap::SetupFindStudyTemplate(DicomMap& result) | |
266 { | |
267 SetupFindTemplate(result, studyTags, sizeof(studyTags) / sizeof(DicomTag)); | |
80 | 268 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
269 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
0 | 270 } |
271 | |
272 void DicomMap::SetupFindSeriesTemplate(DicomMap& result) | |
273 { | |
274 SetupFindTemplate(result, seriesTags, sizeof(seriesTags) / sizeof(DicomTag)); | |
80 | 275 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
276 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
277 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, ""); | |
1372 | 278 |
279 // These tags are considered as "main" by Orthanc, but are not in the Series module | |
280 result.Remove(DicomTag(0x0008, 0x0070)); // Manufacturer | |
281 result.Remove(DicomTag(0x0008, 0x1010)); // Station name | |
282 result.Remove(DicomTag(0x0018, 0x0024)); // Sequence name | |
283 result.Remove(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES); | |
284 result.Remove(DICOM_TAG_IMAGES_IN_ACQUISITION); | |
285 result.Remove(DICOM_TAG_NUMBER_OF_SLICES); | |
286 result.Remove(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS); | |
287 result.Remove(DICOM_TAG_NUMBER_OF_TIME_SLICES); | |
1706 | 288 result.Remove(DICOM_TAG_IMAGE_ORIENTATION_PATIENT); |
0 | 289 } |
290 | |
291 void DicomMap::SetupFindInstanceTemplate(DicomMap& result) | |
292 { | |
293 SetupFindTemplate(result, instanceTags, sizeof(instanceTags) / sizeof(DicomTag)); | |
80 | 294 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
295 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
296 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, ""); | |
297 result.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, ""); | |
0 | 298 } |
299 | |
300 | |
301 void DicomMap::CopyTagIfExists(const DicomMap& source, | |
302 const DicomTag& tag) | |
303 { | |
304 if (source.HasTag(tag)) | |
305 { | |
306 SetValue(tag, source.GetValue(tag)); | |
307 } | |
308 } | |
562
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
309 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
310 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
311 bool DicomMap::IsMainDicomTag(const DicomTag& tag, ResourceType level) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
312 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
313 DicomTag *tags = NULL; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
314 size_t size; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
315 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
316 switch (level) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
317 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
318 case ResourceType_Patient: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
319 tags = patientTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
320 size = sizeof(patientTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
321 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
322 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
323 case ResourceType_Study: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
324 tags = studyTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
325 size = sizeof(studyTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
326 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
327 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
328 case ResourceType_Series: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
329 tags = seriesTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
330 size = sizeof(seriesTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
331 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
332 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
333 case ResourceType_Instance: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
334 tags = instanceTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
335 size = sizeof(instanceTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
336 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
337 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
338 default: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
339 throw OrthancException(ErrorCode_ParameterOutOfRange); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
340 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
341 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
342 for (size_t i = 0; i < size; i++) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
343 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
344 if (tags[i] == tag) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
345 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
346 return true; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
347 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
348 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
349 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
350 return false; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
351 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
352 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
353 bool DicomMap::IsMainDicomTag(const DicomTag& tag) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
354 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
355 return (IsMainDicomTag(tag, ResourceType_Patient) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
356 IsMainDicomTag(tag, ResourceType_Study) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
357 IsMainDicomTag(tag, ResourceType_Series) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
358 IsMainDicomTag(tag, ResourceType_Instance)); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
359 } |
567 | 360 |
361 | |
362 void DicomMap::GetMainDicomTagsInternal(std::set<DicomTag>& result, ResourceType level) | |
363 { | |
364 DicomTag *tags = NULL; | |
365 size_t size; | |
366 | |
367 switch (level) | |
368 { | |
369 case ResourceType_Patient: | |
370 tags = patientTags; | |
371 size = sizeof(patientTags) / sizeof(DicomTag); | |
372 break; | |
373 | |
374 case ResourceType_Study: | |
375 tags = studyTags; | |
376 size = sizeof(studyTags) / sizeof(DicomTag); | |
377 break; | |
378 | |
379 case ResourceType_Series: | |
380 tags = seriesTags; | |
381 size = sizeof(seriesTags) / sizeof(DicomTag); | |
382 break; | |
383 | |
384 case ResourceType_Instance: | |
385 tags = instanceTags; | |
386 size = sizeof(instanceTags) / sizeof(DicomTag); | |
387 break; | |
388 | |
389 default: | |
390 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
391 } | |
392 | |
393 for (size_t i = 0; i < size; i++) | |
394 { | |
395 result.insert(tags[i]); | |
396 } | |
397 } | |
398 | |
399 | |
400 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result, ResourceType level) | |
401 { | |
402 result.clear(); | |
403 GetMainDicomTagsInternal(result, level); | |
404 } | |
405 | |
406 | |
407 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result) | |
408 { | |
409 result.clear(); | |
410 GetMainDicomTagsInternal(result, ResourceType_Patient); | |
411 GetMainDicomTagsInternal(result, ResourceType_Study); | |
412 GetMainDicomTagsInternal(result, ResourceType_Series); | |
413 GetMainDicomTagsInternal(result, ResourceType_Instance); | |
414 } | |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
415 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
416 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
417 void DicomMap::Print(FILE* fp) const |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
418 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
419 DicomArray a(*this); |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
420 a.Print(fp); |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
421 } |
1360 | 422 |
423 | |
424 void DicomMap::GetTags(std::set<DicomTag>& tags) const | |
425 { | |
426 tags.clear(); | |
427 | |
428 for (Map::const_iterator it = map_.begin(); | |
429 it != map_.end(); ++it) | |
430 { | |
431 tags.insert(it->first); | |
432 } | |
433 } | |
0 | 434 } |