Mercurial > hg > orthanc
annotate Core/DicomFormat/DicomMap.cpp @ 1841:5d8134e54c03
DICOM_TAG_SERIES_TYPE
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Nov 2015 12:05:55 +0100 |
parents | 39c37a994b2f |
children | e39716f71d67 |
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> | |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
38 #include "DicomArray.h" |
59 | 39 #include "../OrthancException.h" |
0 | 40 |
41 | |
59 | 42 namespace Orthanc |
0 | 43 { |
44 static DicomTag patientTags[] = | |
45 { | |
38 | 46 //DicomTag(0x0010, 0x1010), // PatientAge |
47 //DicomTag(0x0010, 0x1040) // PatientAddress | |
77 | 48 DicomTag(0x0010, 0x0010), // PatientName |
49 DicomTag(0x0010, 0x0030), // PatientBirthDate | |
50 DicomTag(0x0010, 0x0040), // PatientSex | |
51 DicomTag(0x0010, 0x1000), // OtherPatientIDs | |
80 | 52 DICOM_TAG_PATIENT_ID |
0 | 53 }; |
54 | |
55 static DicomTag studyTags[] = | |
56 { | |
38 | 57 //DicomTag(0x0010, 0x1020), // PatientSize |
58 //DicomTag(0x0010, 0x1030) // PatientWeight | |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1706
diff
changeset
|
59 DICOM_TAG_STUDY_DATE, |
77 | 60 DicomTag(0x0008, 0x0030), // StudyTime |
61 DicomTag(0x0020, 0x0010), // StudyID | |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1706
diff
changeset
|
62 DICOM_TAG_STUDY_DESCRIPTION, |
80 | 63 DICOM_TAG_ACCESSION_NUMBER, |
64 DICOM_TAG_STUDY_INSTANCE_UID | |
0 | 65 }; |
66 | |
67 static DicomTag seriesTags[] = | |
68 { | |
38 | 69 //DicomTag(0x0010, 0x1080), // MilitaryRank |
77 | 70 DicomTag(0x0008, 0x0021), // SeriesDate |
71 DicomTag(0x0008, 0x0031), // SeriesTime | |
1755
39c37a994b2f
handling of DICOM_TAG_MODALITIES_IN_STUDY
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
72 DICOM_TAG_MODALITY, |
77 | 73 DicomTag(0x0008, 0x0070), // Manufacturer |
74 DicomTag(0x0008, 0x1010), // StationName | |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1706
diff
changeset
|
75 DICOM_TAG_SERIES_DESCRIPTION, |
77 | 76 DicomTag(0x0018, 0x0015), // BodyPartExamined |
77 DicomTag(0x0018, 0x0024), // SequenceName | |
78 DicomTag(0x0018, 0x1030), // ProtocolName | |
79 DicomTag(0x0020, 0x0011), // SeriesNumber | |
433 | 80 DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES, |
80 | 81 DICOM_TAG_IMAGES_IN_ACQUISITION, |
433 | 82 DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, |
80 | 83 DICOM_TAG_NUMBER_OF_SLICES, |
433 | 84 DICOM_TAG_NUMBER_OF_TIME_SLICES, |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1372
diff
changeset
|
85 DICOM_TAG_SERIES_INSTANCE_UID, |
1841
5d8134e54c03
DICOM_TAG_SERIES_TYPE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1755
diff
changeset
|
86 DICOM_TAG_IMAGE_ORIENTATION_PATIENT, // New in db v6 |
5d8134e54c03
DICOM_TAG_SERIES_TYPE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1755
diff
changeset
|
87 DICOM_TAG_SERIES_TYPE // 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 | |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
104 void DicomMap::LoadMainDicomTags(const DicomTag*& tags, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
105 size_t& size, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
106 ResourceType level) |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
107 { |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
108 switch (level) |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
109 { |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
110 case ResourceType_Patient: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
111 tags = patientTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
112 size = sizeof(patientTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
113 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
114 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
115 case ResourceType_Study: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
116 tags = studyTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
117 size = sizeof(studyTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
118 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
119 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
120 case ResourceType_Series: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
121 tags = seriesTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
122 size = sizeof(seriesTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
123 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
124 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
125 case ResourceType_Instance: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
126 tags = instanceTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
127 size = sizeof(instanceTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
128 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
129 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
130 default: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
131 throw OrthancException(ErrorCode_ParameterOutOfRange); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
132 } |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
133 } |
0 | 134 |
135 | |
136 void DicomMap::SetValue(uint16_t group, | |
137 uint16_t element, | |
138 DicomValue* value) | |
139 { | |
140 DicomTag tag(group, element); | |
141 Map::iterator it = map_.find(tag); | |
142 | |
143 if (it != map_.end()) | |
144 { | |
145 delete it->second; | |
146 it->second = value; | |
147 } | |
148 else | |
149 { | |
150 map_.insert(std::make_pair(tag, value)); | |
151 } | |
152 } | |
153 | |
154 void DicomMap::SetValue(DicomTag tag, | |
155 DicomValue* value) | |
156 { | |
157 SetValue(tag.GetGroup(), tag.GetElement(), value); | |
158 } | |
159 | |
160 | |
161 | |
162 | |
163 void DicomMap::Clear() | |
164 { | |
656 | 165 for (Map::iterator it = map_.begin(); it != map_.end(); ++it) |
0 | 166 { |
167 delete it->second; | |
168 } | |
169 | |
170 map_.clear(); | |
171 } | |
172 | |
173 | |
174 void DicomMap::ExtractTags(DicomMap& result, | |
175 const DicomTag* tags, | |
176 size_t count) const | |
177 { | |
178 result.Clear(); | |
179 | |
180 for (unsigned int i = 0; i < count; i++) | |
181 { | |
182 Map::const_iterator it = map_.find(tags[i]); | |
183 if (it != map_.end()) | |
184 { | |
185 result.SetValue(it->first, it->second->Clone()); | |
186 } | |
187 } | |
188 } | |
189 | |
190 | |
191 void DicomMap::ExtractPatientInformation(DicomMap& result) const | |
192 { | |
193 ExtractTags(result, patientTags, sizeof(patientTags) / sizeof(DicomTag)); | |
194 } | |
195 | |
196 void DicomMap::ExtractStudyInformation(DicomMap& result) const | |
197 { | |
198 ExtractTags(result, studyTags, sizeof(studyTags) / sizeof(DicomTag)); | |
199 } | |
200 | |
201 void DicomMap::ExtractSeriesInformation(DicomMap& result) const | |
202 { | |
203 ExtractTags(result, seriesTags, sizeof(seriesTags) / sizeof(DicomTag)); | |
204 } | |
205 | |
206 void DicomMap::ExtractInstanceInformation(DicomMap& result) const | |
207 { | |
208 ExtractTags(result, instanceTags, sizeof(instanceTags) / sizeof(DicomTag)); | |
209 } | |
210 | |
211 | |
80 | 212 |
0 | 213 DicomMap* DicomMap::Clone() const |
214 { | |
215 std::auto_ptr<DicomMap> result(new DicomMap); | |
216 | |
656 | 217 for (Map::const_iterator it = map_.begin(); it != map_.end(); ++it) |
0 | 218 { |
219 result->map_.insert(std::make_pair(it->first, it->second->Clone())); | |
220 } | |
221 | |
222 return result.release(); | |
223 } | |
224 | |
225 | |
1310
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
226 void DicomMap::Assign(const DicomMap& other) |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
227 { |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
228 Clear(); |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
229 |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
230 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
|
231 { |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
232 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
|
233 } |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
234 } |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
235 |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
236 |
0 | 237 const DicomValue& DicomMap::GetValue(const DicomTag& tag) const |
238 { | |
80 | 239 const DicomValue* value = TestAndGetValue(tag); |
240 | |
241 if (value) | |
242 { | |
243 return *value; | |
244 } | |
245 else | |
246 { | |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
247 throw OrthancException(ErrorCode_InexistentTag); |
80 | 248 } |
249 } | |
250 | |
251 | |
252 const DicomValue* DicomMap::TestAndGetValue(const DicomTag& tag) const | |
253 { | |
0 | 254 Map::const_iterator it = map_.find(tag); |
255 | |
256 if (it == map_.end()) | |
257 { | |
80 | 258 return NULL; |
0 | 259 } |
260 else | |
261 { | |
80 | 262 return it->second; |
0 | 263 } |
264 } | |
265 | |
266 | |
267 void DicomMap::Remove(const DicomTag& tag) | |
268 { | |
269 Map::iterator it = map_.find(tag); | |
270 if (it != map_.end()) | |
271 { | |
272 delete it->second; | |
273 map_.erase(it); | |
274 } | |
275 } | |
276 | |
277 | |
278 static void SetupFindTemplate(DicomMap& result, | |
279 const DicomTag* tags, | |
280 size_t count) | |
281 { | |
282 result.Clear(); | |
283 | |
284 for (size_t i = 0; i < count; i++) | |
285 { | |
286 result.SetValue(tags[i], ""); | |
287 } | |
288 } | |
289 | |
290 void DicomMap::SetupFindPatientTemplate(DicomMap& result) | |
291 { | |
292 SetupFindTemplate(result, patientTags, sizeof(patientTags) / sizeof(DicomTag)); | |
293 } | |
294 | |
295 void DicomMap::SetupFindStudyTemplate(DicomMap& result) | |
296 { | |
297 SetupFindTemplate(result, studyTags, sizeof(studyTags) / sizeof(DicomTag)); | |
80 | 298 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
299 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
0 | 300 } |
301 | |
302 void DicomMap::SetupFindSeriesTemplate(DicomMap& result) | |
303 { | |
304 SetupFindTemplate(result, seriesTags, sizeof(seriesTags) / sizeof(DicomTag)); | |
80 | 305 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
306 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
307 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, ""); | |
1372 | 308 |
309 // These tags are considered as "main" by Orthanc, but are not in the Series module | |
310 result.Remove(DicomTag(0x0008, 0x0070)); // Manufacturer | |
311 result.Remove(DicomTag(0x0008, 0x1010)); // Station name | |
312 result.Remove(DicomTag(0x0018, 0x0024)); // Sequence name | |
313 result.Remove(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES); | |
314 result.Remove(DICOM_TAG_IMAGES_IN_ACQUISITION); | |
315 result.Remove(DICOM_TAG_NUMBER_OF_SLICES); | |
316 result.Remove(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS); | |
317 result.Remove(DICOM_TAG_NUMBER_OF_TIME_SLICES); | |
1706 | 318 result.Remove(DICOM_TAG_IMAGE_ORIENTATION_PATIENT); |
0 | 319 } |
320 | |
321 void DicomMap::SetupFindInstanceTemplate(DicomMap& result) | |
322 { | |
323 SetupFindTemplate(result, instanceTags, sizeof(instanceTags) / sizeof(DicomTag)); | |
80 | 324 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
325 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
326 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, ""); | |
327 result.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, ""); | |
0 | 328 } |
329 | |
330 | |
331 void DicomMap::CopyTagIfExists(const DicomMap& source, | |
332 const DicomTag& tag) | |
333 { | |
334 if (source.HasTag(tag)) | |
335 { | |
336 SetValue(tag, source.GetValue(tag)); | |
337 } | |
338 } | |
562
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
339 |
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 bool DicomMap::IsMainDicomTag(const DicomTag& tag, ResourceType level) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
342 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
343 DicomTag *tags = NULL; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
344 size_t size; |
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 switch (level) |
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 case ResourceType_Patient: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
349 tags = patientTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
350 size = sizeof(patientTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
351 break; |
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 case ResourceType_Study: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
354 tags = studyTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
355 size = sizeof(studyTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
356 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
357 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
358 case ResourceType_Series: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
359 tags = seriesTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
360 size = sizeof(seriesTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
361 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
362 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
363 case ResourceType_Instance: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
364 tags = instanceTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
365 size = sizeof(instanceTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
366 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
367 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
368 default: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
369 throw OrthancException(ErrorCode_ParameterOutOfRange); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
370 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
371 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
372 for (size_t i = 0; i < size; i++) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
373 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
374 if (tags[i] == tag) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
375 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
376 return true; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
377 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
378 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
379 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
380 return false; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
381 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
382 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
383 bool DicomMap::IsMainDicomTag(const DicomTag& tag) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
384 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
385 return (IsMainDicomTag(tag, ResourceType_Patient) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
386 IsMainDicomTag(tag, ResourceType_Study) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
387 IsMainDicomTag(tag, ResourceType_Series) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
388 IsMainDicomTag(tag, ResourceType_Instance)); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
389 } |
567 | 390 |
391 | |
392 void DicomMap::GetMainDicomTagsInternal(std::set<DicomTag>& result, ResourceType level) | |
393 { | |
394 DicomTag *tags = NULL; | |
395 size_t size; | |
396 | |
397 switch (level) | |
398 { | |
399 case ResourceType_Patient: | |
400 tags = patientTags; | |
401 size = sizeof(patientTags) / sizeof(DicomTag); | |
402 break; | |
403 | |
404 case ResourceType_Study: | |
405 tags = studyTags; | |
406 size = sizeof(studyTags) / sizeof(DicomTag); | |
407 break; | |
408 | |
409 case ResourceType_Series: | |
410 tags = seriesTags; | |
411 size = sizeof(seriesTags) / sizeof(DicomTag); | |
412 break; | |
413 | |
414 case ResourceType_Instance: | |
415 tags = instanceTags; | |
416 size = sizeof(instanceTags) / sizeof(DicomTag); | |
417 break; | |
418 | |
419 default: | |
420 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
421 } | |
422 | |
423 for (size_t i = 0; i < size; i++) | |
424 { | |
425 result.insert(tags[i]); | |
426 } | |
427 } | |
428 | |
429 | |
430 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result, ResourceType level) | |
431 { | |
432 result.clear(); | |
433 GetMainDicomTagsInternal(result, level); | |
434 } | |
435 | |
436 | |
437 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result) | |
438 { | |
439 result.clear(); | |
440 GetMainDicomTagsInternal(result, ResourceType_Patient); | |
441 GetMainDicomTagsInternal(result, ResourceType_Study); | |
442 GetMainDicomTagsInternal(result, ResourceType_Series); | |
443 GetMainDicomTagsInternal(result, ResourceType_Instance); | |
444 } | |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
445 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
446 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
447 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
|
448 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
449 DicomArray a(*this); |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
450 a.Print(fp); |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
451 } |
1360 | 452 |
453 | |
454 void DicomMap::GetTags(std::set<DicomTag>& tags) const | |
455 { | |
456 tags.clear(); | |
457 | |
458 for (Map::const_iterator it = map_.begin(); | |
459 it != map_.end(); ++it) | |
460 { | |
461 tags.insert(it->first); | |
462 } | |
463 } | |
0 | 464 } |