Mercurial > hg > orthanc
annotate Core/DicomFormat/DicomMap.h @ 2909:a9a1554932a1
updated API doc
author | am@osimis.io |
---|---|
date | Tue, 30 Oct 2018 17:35:13 +0100 |
parents | da12ba232119 |
children | 8265a6b56100 |
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:
1228
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
136 | 11 * |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
0 | 23 * |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
36 #include "DicomTag.h" | |
37 #include "DicomValue.h" | |
562
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
38 #include "../Enumerations.h" |
0 | 39 |
567 | 40 #include <set> |
0 | 41 #include <map> |
42 #include <json/json.h> | |
43 | |
59 | 44 namespace Orthanc |
0 | 45 { |
46 class DicomMap : public boost::noncopyable | |
47 { | |
48 private: | |
49 friend class DicomArray; | |
50 friend class FromDcmtkBridge; | |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2008
diff
changeset
|
51 friend class ParsedDicomFile; |
0 | 52 |
53 typedef std::map<DicomTag, DicomValue*> Map; | |
54 | |
55 Map map_; | |
56 | |
57 // Warning: This takes the ownership of "value" | |
58 void SetValue(uint16_t group, | |
59 uint16_t element, | |
60 DicomValue* value); | |
61 | |
62 void SetValue(DicomTag tag, | |
63 DicomValue* value); | |
64 | |
65 void ExtractTags(DicomMap& source, | |
66 const DicomTag* tags, | |
67 size_t count) const; | |
567 | 68 |
69 static void GetMainDicomTagsInternal(std::set<DicomTag>& result, ResourceType level); | |
0 | 70 |
71 public: | |
72 DicomMap() | |
73 { | |
74 } | |
75 | |
76 ~DicomMap() | |
77 { | |
78 Clear(); | |
79 } | |
1331
77e129ba64e4
Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1310
diff
changeset
|
80 |
77e129ba64e4
Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1310
diff
changeset
|
81 size_t GetSize() const |
77e129ba64e4
Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1310
diff
changeset
|
82 { |
77e129ba64e4
Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1310
diff
changeset
|
83 return map_.size(); |
77e129ba64e4
Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1310
diff
changeset
|
84 } |
1310
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
85 |
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
86 DicomMap* Clone() const; |
0 | 87 |
1310
61ce8147f30d
custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
88 void Assign(const DicomMap& other); |
0 | 89 |
90 void Clear(); | |
91 | |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
92 void SetNullValue(uint16_t group, |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
93 uint16_t element) |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
94 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
95 SetValue(group, element, new DicomValue); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
96 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
97 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
98 void SetNullValue(const DicomTag& tag) |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
99 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
100 SetValue(tag, new DicomValue); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
101 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
102 |
0 | 103 void SetValue(uint16_t group, |
104 uint16_t element, | |
105 const DicomValue& value) | |
106 { | |
107 SetValue(group, element, value.Clone()); | |
108 } | |
109 | |
110 void SetValue(const DicomTag& tag, | |
111 const DicomValue& value) | |
112 { | |
113 SetValue(tag, value.Clone()); | |
114 } | |
115 | |
116 void SetValue(const DicomTag& tag, | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
117 const std::string& str, |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
118 bool isBinary) |
0 | 119 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
120 SetValue(tag, new DicomValue(str, isBinary)); |
0 | 121 } |
122 | |
123 void SetValue(uint16_t group, | |
124 uint16_t element, | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
125 const std::string& str, |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
126 bool isBinary) |
0 | 127 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
128 SetValue(group, element, new DicomValue(str, isBinary)); |
0 | 129 } |
130 | |
131 bool HasTag(uint16_t group, uint16_t element) const | |
132 { | |
133 return HasTag(DicomTag(group, element)); | |
134 } | |
135 | |
136 bool HasTag(const DicomTag& tag) const | |
137 { | |
138 return map_.find(tag) != map_.end(); | |
139 } | |
140 | |
141 const DicomValue& GetValue(uint16_t group, uint16_t element) const | |
142 { | |
143 return GetValue(DicomTag(group, element)); | |
144 } | |
145 | |
146 const DicomValue& GetValue(const DicomTag& tag) const; | |
147 | |
1228
e0f7014d39a4
Instances without PatientID are now allowed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1206
diff
changeset
|
148 // DO NOT delete the returned value! |
80 | 149 const DicomValue* TestAndGetValue(uint16_t group, uint16_t element) const |
150 { | |
151 return TestAndGetValue(DicomTag(group, element)); | |
152 } | |
153 | |
1228
e0f7014d39a4
Instances without PatientID are now allowed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1206
diff
changeset
|
154 // DO NOT delete the returned value! |
80 | 155 const DicomValue* TestAndGetValue(const DicomTag& tag) const; |
156 | |
0 | 157 void Remove(const DicomTag& tag); |
158 | |
159 void ExtractPatientInformation(DicomMap& result) const; | |
160 | |
161 void ExtractStudyInformation(DicomMap& result) const; | |
162 | |
163 void ExtractSeriesInformation(DicomMap& result) const; | |
164 | |
165 void ExtractInstanceInformation(DicomMap& result) const; | |
166 | |
167 static void SetupFindPatientTemplate(DicomMap& result); | |
168 | |
169 static void SetupFindStudyTemplate(DicomMap& result); | |
170 | |
171 static void SetupFindSeriesTemplate(DicomMap& result); | |
172 | |
173 static void SetupFindInstanceTemplate(DicomMap& result); | |
174 | |
175 void CopyTagIfExists(const DicomMap& source, | |
176 const DicomTag& tag); | |
562
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
177 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
178 static bool IsMainDicomTag(const DicomTag& tag, ResourceType level); |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
179 |
f64e3838d6e1
refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
180 static bool IsMainDicomTag(const DicomTag& tag); |
567 | 181 |
182 static void GetMainDicomTags(std::set<DicomTag>& result, ResourceType level); | |
183 | |
184 static void GetMainDicomTags(std::set<DicomTag>& result); | |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
185 |
1360 | 186 void GetTags(std::set<DicomTag>& tags) const; |
1749
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
187 |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
188 static void LoadMainDicomTags(const DicomTag*& tags, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
189 size_t& size, |
99f4a05f39fa
various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
190 ResourceType level); |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
191 |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
192 static bool ParseDicomMetaInformation(DicomMap& result, |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
193 const char* dicom, |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
194 size_t size); |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
195 |
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
196 void LogMissingTagsForStore() const; |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
197 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
198 bool CopyToString(std::string& result, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
199 const DicomTag& tag, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
200 bool allowBinary) const; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
201 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
202 bool ParseInteger32(int32_t& result, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
203 const DicomTag& tag) const; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
204 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
205 bool ParseInteger64(int64_t& result, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
206 const DicomTag& tag) const; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
207 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
208 bool ParseUnsignedInteger32(uint32_t& result, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
209 const DicomTag& tag) const; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
210 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
211 bool ParseUnsignedInteger64(uint64_t& result, |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
212 const DicomTag& tag) const; |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
213 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
214 bool ParseFloat(float& result, |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
215 const DicomTag& tag) const; |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
216 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
217 bool ParseDouble(double& result, |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
218 const DicomTag& tag) const; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
219 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
220 void Serialize(Json::Value& target) const; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
221 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
222 void Unserialize(const Json::Value& source); |
0 | 223 }; |
224 } |