Mercurial > hg > orthanc-wsi
comparison Resources/Orthanc/OrthancServer/FromDcmtkBridge.h @ 59:7a3853d51c45
Move "Framework/Orthanc/" as "Resources/Orthanc/"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Nov 2016 16:34:34 +0100 |
parents | Framework/Orthanc/OrthancServer/FromDcmtkBridge.h@2789d34cb993 |
children | 5b127ab0080b |
comparison
equal
deleted
inserted
replaced
58:35468714a38e | 59:7a3853d51c45 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
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. | |
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. | |
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 | |
33 #pragma once | |
34 | |
35 #include "ServerEnumerations.h" | |
36 | |
37 #include "../Core/DicomFormat/DicomElement.h" | |
38 #include "../Core/DicomFormat/DicomMap.h" | |
39 | |
40 #include <dcmtk/dcmdata/dcdatset.h> | |
41 #include <dcmtk/dcmdata/dcmetinf.h> | |
42 #include <dcmtk/dcmdata/dcpixseq.h> | |
43 #include <dcmtk/dcmdata/dcfilefo.h> | |
44 #include <json/json.h> | |
45 | |
46 #if ORTHANC_BUILD_UNIT_TESTS == 1 | |
47 # include <gtest/gtest_prod.h> | |
48 #endif | |
49 | |
50 | |
51 namespace Orthanc | |
52 { | |
53 class FromDcmtkBridge : public boost::noncopyable | |
54 { | |
55 #if ORTHANC_BUILD_UNIT_TESTS == 1 | |
56 FRIEND_TEST(FromDcmtkBridge, FromJson); | |
57 #endif | |
58 | |
59 friend class ParsedDicomFile; | |
60 friend class Configuration; | |
61 | |
62 private: | |
63 FromDcmtkBridge(); // Pure static class | |
64 | |
65 static void ExtractDicomSummary(DicomMap& target, | |
66 DcmItem& dataset, | |
67 unsigned int maxStringLength, | |
68 Encoding defaultEncoding); | |
69 | |
70 static void DatasetToJson(Json::Value& parent, | |
71 DcmItem& item, | |
72 DicomToJsonFormat format, | |
73 DicomToJsonFlags flags, | |
74 unsigned int maxStringLength, | |
75 Encoding encoding); | |
76 | |
77 static void ElementToJson(Json::Value& parent, | |
78 DcmElement& element, | |
79 DicomToJsonFormat format, | |
80 DicomToJsonFlags flags, | |
81 unsigned int maxStringLength, | |
82 Encoding dicomEncoding); | |
83 | |
84 static void ExtractDicomAsJson(Json::Value& target, | |
85 DcmDataset& dataset, | |
86 DicomToJsonFormat format, | |
87 DicomToJsonFlags flags, | |
88 unsigned int maxStringLength, | |
89 Encoding defaultEncoding); | |
90 | |
91 public: | |
92 static void InitializeDictionary(bool loadPrivateDictionary); | |
93 | |
94 static void RegisterDictionaryTag(const DicomTag& tag, | |
95 ValueRepresentation vr, | |
96 const std::string& name, | |
97 unsigned int minMultiplicity, | |
98 unsigned int maxMultiplicity, | |
99 const std::string& privateCreator); | |
100 | |
101 static Encoding DetectEncoding(DcmItem& dataset, | |
102 Encoding defaultEncoding); | |
103 | |
104 static DicomTag Convert(const DcmTag& tag); | |
105 | |
106 static DicomTag GetTag(const DcmElement& element); | |
107 | |
108 static bool IsUnknownTag(const DicomTag& tag); | |
109 | |
110 static DicomValue* ConvertLeafElement(DcmElement& element, | |
111 DicomToJsonFlags flags, | |
112 unsigned int maxStringLength, | |
113 Encoding encoding); | |
114 | |
115 static void ExtractHeaderAsJson(Json::Value& target, | |
116 DcmMetaInfo& header, | |
117 DicomToJsonFormat format, | |
118 DicomToJsonFlags flags, | |
119 unsigned int maxStringLength); | |
120 | |
121 static std::string GetTagName(const DicomTag& tag, | |
122 const std::string& privateCreator); | |
123 | |
124 static std::string GetTagName(const DcmElement& element); | |
125 | |
126 static std::string GetTagName(const DicomElement& element) | |
127 { | |
128 return GetTagName(element.GetTag(), ""); | |
129 } | |
130 | |
131 static DicomTag ParseTag(const char* name); | |
132 | |
133 static DicomTag ParseTag(const std::string& name) | |
134 { | |
135 return ParseTag(name.c_str()); | |
136 } | |
137 | |
138 static bool HasTag(const DicomMap& fields, | |
139 const std::string& tagName) | |
140 { | |
141 return fields.HasTag(ParseTag(tagName)); | |
142 } | |
143 | |
144 static const DicomValue& GetValue(const DicomMap& fields, | |
145 const std::string& tagName) | |
146 { | |
147 return fields.GetValue(ParseTag(tagName)); | |
148 } | |
149 | |
150 static void SetValue(DicomMap& target, | |
151 const std::string& tagName, | |
152 DicomValue* value) | |
153 { | |
154 target.SetValue(ParseTag(tagName), value); | |
155 } | |
156 | |
157 static void ToJson(Json::Value& result, | |
158 const DicomMap& values, | |
159 bool simplify); | |
160 | |
161 static std::string GenerateUniqueIdentifier(ResourceType level); | |
162 | |
163 static bool SaveToMemoryBuffer(std::string& buffer, | |
164 DcmDataset& dataSet); | |
165 | |
166 static ValueRepresentation Convert(DcmEVR vr); | |
167 | |
168 static ValueRepresentation LookupValueRepresentation(const DicomTag& tag); | |
169 | |
170 static DcmElement* CreateElementForTag(const DicomTag& tag); | |
171 | |
172 static void FillElementWithString(DcmElement& element, | |
173 const DicomTag& tag, | |
174 const std::string& utf8alue, // Encoded using UTF-8 | |
175 bool decodeDataUriScheme, | |
176 Encoding dicomEncoding); | |
177 | |
178 static DcmElement* FromJson(const DicomTag& tag, | |
179 const Json::Value& element, // Encoded using UTF-8 | |
180 bool decodeDataUriScheme, | |
181 Encoding dicomEncoding); | |
182 | |
183 static DcmPixelSequence* GetPixelSequence(DcmDataset& dataset); | |
184 | |
185 static Encoding ExtractEncoding(const Json::Value& json, | |
186 Encoding defaultEncoding); | |
187 | |
188 static DcmDataset* FromJson(const Json::Value& json, // Encoded using UTF-8 | |
189 bool generateIdentifiers, | |
190 bool decodeDataUriScheme, | |
191 Encoding defaultEncoding); | |
192 | |
193 static DcmFileFormat* LoadFromMemoryBuffer(const void* buffer, | |
194 size_t size); | |
195 | |
196 static void FromJson(DicomMap& values, | |
197 const Json::Value& result); | |
198 }; | |
199 } |