Mercurial > hg > orthanc
annotate Core/DicomFormat/DicomMap.cpp @ 1905:8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Jan 2016 17:25:01 +0100 |
parents | b1291df2f780 |
children | 655489d9165d |
rev | line source |
---|---|
0 | 1 /** |
59 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
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, |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
64 DICOM_TAG_STUDY_INSTANCE_UID, |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
65 DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION, // New in db v6 |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
66 DICOM_TAG_INSTITUTION_NAME, // New in db v6 |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
67 DICOM_TAG_REQUESTING_PHYSICIAN, // New in db v6 |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
68 DICOM_TAG_REFERRING_PHYSICIAN_NAME // New in db v6 |
0 | 69 }; |
70 | |
71 static DicomTag seriesTags[] = | |
72 { | |
38 | 73 //DicomTag(0x0010, 0x1080), // MilitaryRank |
77 | 74 DicomTag(0x0008, 0x0021), // SeriesDate |
75 DicomTag(0x0008, 0x0031), // SeriesTime | |
1755
39c37a994b2f
handling of DICOM_TAG_MODALITIES_IN_STUDY
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1749
diff
changeset
|
76 DICOM_TAG_MODALITY, |
77 | 77 DicomTag(0x0008, 0x0070), // Manufacturer |
78 DicomTag(0x0008, 0x1010), // StationName | |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1706
diff
changeset
|
79 DICOM_TAG_SERIES_DESCRIPTION, |
77 | 80 DicomTag(0x0018, 0x0015), // BodyPartExamined |
81 DicomTag(0x0018, 0x0024), // SequenceName | |
82 DicomTag(0x0018, 0x1030), // ProtocolName | |
83 DicomTag(0x0020, 0x0011), // SeriesNumber | |
433 | 84 DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES, |
80 | 85 DICOM_TAG_IMAGES_IN_ACQUISITION, |
433 | 86 DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS, |
80 | 87 DICOM_TAG_NUMBER_OF_SLICES, |
433 | 88 DICOM_TAG_NUMBER_OF_TIME_SLICES, |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1372
diff
changeset
|
89 DICOM_TAG_SERIES_INSTANCE_UID, |
1850
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
90 DICOM_TAG_IMAGE_ORIENTATION_PATIENT, // New in db v6 |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
91 DICOM_TAG_SERIES_TYPE, // New in db v6 |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
92 DICOM_TAG_OPERATOR_NAME, // New in db v6 |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
93 DICOM_TAG_PERFORMED_PROCEDURE_STEP_DESCRIPTION, // New in db v6 |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
94 DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION, // New in db v6 |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
95 DICOM_TAG_CONTRAST_BOLUS_AGENT // New in db v6 |
0 | 96 }; |
97 | |
98 static DicomTag instanceTags[] = | |
99 { | |
77 | 100 DicomTag(0x0008, 0x0012), // InstanceCreationDate |
101 DicomTag(0x0008, 0x0013), // InstanceCreationTime | |
102 DicomTag(0x0020, 0x0012), // AcquisitionNumber | |
80 | 103 DICOM_TAG_IMAGE_INDEX, |
104 DICOM_TAG_INSTANCE_NUMBER, | |
84 | 105 DICOM_TAG_NUMBER_OF_FRAMES, |
433 | 106 DICOM_TAG_TEMPORAL_POSITION_IDENTIFIER, |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1372
diff
changeset
|
107 DICOM_TAG_SOP_INSTANCE_UID, |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
108 DICOM_TAG_IMAGE_POSITION_PATIENT, // New in db v6 |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
109 DICOM_TAG_IMAGE_COMMENTS // New in db v6 |
0 | 110 }; |
111 | |
112 | |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
113 void DicomMap::LoadMainDicomTags(const DicomTag*& tags, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
114 size_t& size, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
115 ResourceType level) |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
116 { |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
117 switch (level) |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
118 { |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
119 case ResourceType_Patient: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
120 tags = patientTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
121 size = sizeof(patientTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
122 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
123 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
124 case ResourceType_Study: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
125 tags = studyTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
126 size = sizeof(studyTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
127 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
128 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
129 case ResourceType_Series: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
130 tags = seriesTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
131 size = sizeof(seriesTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
132 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
133 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
134 case ResourceType_Instance: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
135 tags = instanceTags; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
136 size = sizeof(instanceTags) / sizeof(DicomTag); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
137 break; |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
138 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
139 default: |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
140 throw OrthancException(ErrorCode_ParameterOutOfRange); |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
141 } |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
142 } |
0 | 143 |
144 | |
145 void DicomMap::SetValue(uint16_t group, | |
146 uint16_t element, | |
147 DicomValue* value) | |
148 { | |
149 DicomTag tag(group, element); | |
150 Map::iterator it = map_.find(tag); | |
151 | |
152 if (it != map_.end()) | |
153 { | |
154 delete it->second; | |
155 it->second = value; | |
156 } | |
157 else | |
158 { | |
159 map_.insert(std::make_pair(tag, value)); | |
160 } | |
161 } | |
162 | |
163 void DicomMap::SetValue(DicomTag tag, | |
164 DicomValue* value) | |
165 { | |
166 SetValue(tag.GetGroup(), tag.GetElement(), value); | |
167 } | |
168 | |
169 | |
170 | |
171 | |
172 void DicomMap::Clear() | |
173 { | |
656 | 174 for (Map::iterator it = map_.begin(); it != map_.end(); ++it) |
0 | 175 { |
176 delete it->second; | |
177 } | |
178 | |
179 map_.clear(); | |
180 } | |
181 | |
182 | |
183 void DicomMap::ExtractTags(DicomMap& result, | |
184 const DicomTag* tags, | |
185 size_t count) const | |
186 { | |
187 result.Clear(); | |
188 | |
189 for (unsigned int i = 0; i < count; i++) | |
190 { | |
191 Map::const_iterator it = map_.find(tags[i]); | |
192 if (it != map_.end()) | |
193 { | |
194 result.SetValue(it->first, it->second->Clone()); | |
195 } | |
196 } | |
197 } | |
198 | |
199 | |
200 void DicomMap::ExtractPatientInformation(DicomMap& result) const | |
201 { | |
202 ExtractTags(result, patientTags, sizeof(patientTags) / sizeof(DicomTag)); | |
203 } | |
204 | |
205 void DicomMap::ExtractStudyInformation(DicomMap& result) const | |
206 { | |
207 ExtractTags(result, studyTags, sizeof(studyTags) / sizeof(DicomTag)); | |
208 } | |
209 | |
210 void DicomMap::ExtractSeriesInformation(DicomMap& result) const | |
211 { | |
212 ExtractTags(result, seriesTags, sizeof(seriesTags) / sizeof(DicomTag)); | |
213 } | |
214 | |
215 void DicomMap::ExtractInstanceInformation(DicomMap& result) const | |
216 { | |
217 ExtractTags(result, instanceTags, sizeof(instanceTags) / sizeof(DicomTag)); | |
218 } | |
219 | |
220 | |
80 | 221 |
0 | 222 DicomMap* DicomMap::Clone() const |
223 { | |
224 std::auto_ptr<DicomMap> result(new DicomMap); | |
225 | |
656 | 226 for (Map::const_iterator it = map_.begin(); it != map_.end(); ++it) |
0 | 227 { |
228 result->map_.insert(std::make_pair(it->first, it->second->Clone())); | |
229 } | |
230 | |
231 return result.release(); | |
232 } | |
233 | |
234 | |
1310
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
235 void DicomMap::Assign(const DicomMap& other) |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
236 { |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
237 Clear(); |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
238 |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
239 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
|
240 { |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
241 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
|
242 } |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
243 } |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
244 |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
245 |
0 | 246 const DicomValue& DicomMap::GetValue(const DicomTag& tag) const |
247 { | |
80 | 248 const DicomValue* value = TestAndGetValue(tag); |
249 | |
250 if (value) | |
251 { | |
252 return *value; | |
253 } | |
254 else | |
255 { | |
730
309e686b41e7
better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
256 throw OrthancException(ErrorCode_InexistentTag); |
80 | 257 } |
258 } | |
259 | |
260 | |
261 const DicomValue* DicomMap::TestAndGetValue(const DicomTag& tag) const | |
262 { | |
0 | 263 Map::const_iterator it = map_.find(tag); |
264 | |
265 if (it == map_.end()) | |
266 { | |
80 | 267 return NULL; |
0 | 268 } |
269 else | |
270 { | |
80 | 271 return it->second; |
0 | 272 } |
273 } | |
274 | |
275 | |
276 void DicomMap::Remove(const DicomTag& tag) | |
277 { | |
278 Map::iterator it = map_.find(tag); | |
279 if (it != map_.end()) | |
280 { | |
281 delete it->second; | |
282 map_.erase(it); | |
283 } | |
284 } | |
285 | |
286 | |
287 static void SetupFindTemplate(DicomMap& result, | |
288 const DicomTag* tags, | |
289 size_t count) | |
290 { | |
291 result.Clear(); | |
292 | |
293 for (size_t i = 0; i < count; i++) | |
294 { | |
295 result.SetValue(tags[i], ""); | |
296 } | |
297 } | |
298 | |
299 void DicomMap::SetupFindPatientTemplate(DicomMap& result) | |
300 { | |
301 SetupFindTemplate(result, patientTags, sizeof(patientTags) / sizeof(DicomTag)); | |
302 } | |
303 | |
304 void DicomMap::SetupFindStudyTemplate(DicomMap& result) | |
305 { | |
306 SetupFindTemplate(result, studyTags, sizeof(studyTags) / sizeof(DicomTag)); | |
80 | 307 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
308 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
309 |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
310 // These main DICOM tags are only indirectly related to the |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
311 // General Study Module, remove them |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
312 result.Remove(DICOM_TAG_INSTITUTION_NAME); |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
313 result.Remove(DICOM_TAG_REQUESTING_PHYSICIAN); |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
314 result.Remove(DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION); |
0 | 315 } |
316 | |
317 void DicomMap::SetupFindSeriesTemplate(DicomMap& result) | |
318 { | |
319 SetupFindTemplate(result, seriesTags, sizeof(seriesTags) / sizeof(DicomTag)); | |
80 | 320 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
321 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
322 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, ""); | |
1372 | 323 |
324 // These tags are considered as "main" by Orthanc, but are not in the Series module | |
325 result.Remove(DicomTag(0x0008, 0x0070)); // Manufacturer | |
326 result.Remove(DicomTag(0x0008, 0x1010)); // Station name | |
327 result.Remove(DicomTag(0x0018, 0x0024)); // Sequence name | |
328 result.Remove(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES); | |
329 result.Remove(DICOM_TAG_IMAGES_IN_ACQUISITION); | |
330 result.Remove(DICOM_TAG_NUMBER_OF_SLICES); | |
331 result.Remove(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS); | |
332 result.Remove(DICOM_TAG_NUMBER_OF_TIME_SLICES); | |
1706 | 333 result.Remove(DICOM_TAG_IMAGE_ORIENTATION_PATIENT); |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1841
diff
changeset
|
334 result.Remove(DICOM_TAG_SERIES_TYPE); |
1850
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
335 result.Remove(DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION); |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
336 result.Remove(DICOM_TAG_CONTRAST_BOLUS_AGENT); |
0 | 337 } |
338 | |
339 void DicomMap::SetupFindInstanceTemplate(DicomMap& result) | |
340 { | |
341 SetupFindTemplate(result, instanceTags, sizeof(instanceTags) / sizeof(DicomTag)); | |
80 | 342 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, ""); |
343 result.SetValue(DICOM_TAG_PATIENT_ID, ""); | |
344 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, ""); | |
345 result.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, ""); | |
0 | 346 } |
347 | |
348 | |
349 void DicomMap::CopyTagIfExists(const DicomMap& source, | |
350 const DicomTag& tag) | |
351 { | |
352 if (source.HasTag(tag)) | |
353 { | |
354 SetValue(tag, source.GetValue(tag)); | |
355 } | |
356 } | |
562
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 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
359 bool DicomMap::IsMainDicomTag(const DicomTag& tag, ResourceType level) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
360 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
361 DicomTag *tags = NULL; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
362 size_t size; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
363 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
364 switch (level) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
365 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
366 case ResourceType_Patient: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
367 tags = patientTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
368 size = sizeof(patientTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
369 break; |
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 case ResourceType_Study: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
372 tags = studyTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
373 size = sizeof(studyTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
374 break; |
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 case ResourceType_Series: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
377 tags = seriesTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
378 size = sizeof(seriesTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
379 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
380 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
381 case ResourceType_Instance: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
382 tags = instanceTags; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
383 size = sizeof(instanceTags) / sizeof(DicomTag); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
384 break; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
385 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
386 default: |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
387 throw OrthancException(ErrorCode_ParameterOutOfRange); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
388 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
389 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
390 for (size_t i = 0; i < size; i++) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
391 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
392 if (tags[i] == tag) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
393 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
394 return true; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
395 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
396 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
397 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
398 return false; |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
399 } |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
400 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
401 bool DicomMap::IsMainDicomTag(const DicomTag& tag) |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
402 { |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
403 return (IsMainDicomTag(tag, ResourceType_Patient) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
404 IsMainDicomTag(tag, ResourceType_Study) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
405 IsMainDicomTag(tag, ResourceType_Series) || |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
406 IsMainDicomTag(tag, ResourceType_Instance)); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
433
diff
changeset
|
407 } |
567 | 408 |
409 | |
410 void DicomMap::GetMainDicomTagsInternal(std::set<DicomTag>& result, ResourceType level) | |
411 { | |
412 DicomTag *tags = NULL; | |
413 size_t size; | |
414 | |
415 switch (level) | |
416 { | |
417 case ResourceType_Patient: | |
418 tags = patientTags; | |
419 size = sizeof(patientTags) / sizeof(DicomTag); | |
420 break; | |
421 | |
422 case ResourceType_Study: | |
423 tags = studyTags; | |
424 size = sizeof(studyTags) / sizeof(DicomTag); | |
425 break; | |
426 | |
427 case ResourceType_Series: | |
428 tags = seriesTags; | |
429 size = sizeof(seriesTags) / sizeof(DicomTag); | |
430 break; | |
431 | |
432 case ResourceType_Instance: | |
433 tags = instanceTags; | |
434 size = sizeof(instanceTags) / sizeof(DicomTag); | |
435 break; | |
436 | |
437 default: | |
438 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
439 } | |
440 | |
441 for (size_t i = 0; i < size; i++) | |
442 { | |
443 result.insert(tags[i]); | |
444 } | |
445 } | |
446 | |
447 | |
448 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result, ResourceType level) | |
449 { | |
450 result.clear(); | |
451 GetMainDicomTagsInternal(result, level); | |
452 } | |
453 | |
454 | |
455 void DicomMap::GetMainDicomTags(std::set<DicomTag>& result) | |
456 { | |
457 result.clear(); | |
458 GetMainDicomTagsInternal(result, ResourceType_Patient); | |
459 GetMainDicomTagsInternal(result, ResourceType_Study); | |
460 GetMainDicomTagsInternal(result, ResourceType_Series); | |
461 GetMainDicomTagsInternal(result, ResourceType_Instance); | |
462 } | |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
463 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
464 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
465 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
|
466 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
467 DicomArray a(*this); |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
468 a.Print(fp); |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
469 } |
1360 | 470 |
471 | |
472 void DicomMap::GetTags(std::set<DicomTag>& tags) const | |
473 { | |
474 tags.clear(); | |
475 | |
476 for (Map::const_iterator it = map_.begin(); | |
477 it != map_.end(); ++it) | |
478 { | |
479 tags.insert(it->first); | |
480 } | |
481 } | |
0 | 482 } |