comparison Framework/Orthanc/OrthancServer/FromDcmtkBridge.h @ 1:dc730d11b101

orthanc dependencies
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 22 Oct 2016 21:50:15 +0200
parents
children 8f68ad57fd18
comparison
equal deleted inserted replaced
0:4a7a53257c7d 1:dc730d11b101
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/DicomMap.h"
38
39 #include <dcmtk/dcmdata/dcdatset.h>
40 #include <dcmtk/dcmdata/dcmetinf.h>
41 #include <dcmtk/dcmdata/dcpixseq.h>
42 #include <dcmtk/dcmdata/dcfilefo.h>
43 #include <json/json.h>
44
45 namespace Orthanc
46 {
47 class FromDcmtkBridge
48 {
49 public:
50 static void InitializeDictionary();
51
52 static void RegisterDictionaryTag(const DicomTag& tag,
53 ValueRepresentation vr,
54 const std::string& name,
55 unsigned int minMultiplicity,
56 unsigned int maxMultiplicity);
57
58 static Encoding DetectEncoding(DcmItem& dataset,
59 Encoding defaultEncoding);
60
61 static void Convert(DicomMap& target,
62 DcmItem& dataset,
63 unsigned int maxStringLength,
64 Encoding defaultEncoding);
65
66 static DicomTag Convert(const DcmTag& tag);
67
68 static DicomTag GetTag(const DcmElement& element);
69
70 static bool IsUnknownTag(const DicomTag& tag);
71
72 static DicomValue* ConvertLeafElement(DcmElement& element,
73 DicomToJsonFlags flags,
74 unsigned int maxStringLength,
75 Encoding encoding);
76
77 static void ToJson(Json::Value& parent,
78 DcmElement& element,
79 DicomToJsonFormat format,
80 DicomToJsonFlags flags,
81 unsigned int maxStringLength,
82 Encoding dicomEncoding);
83
84 static void ToJson(Json::Value& target,
85 DcmDataset& dataset,
86 DicomToJsonFormat format,
87 DicomToJsonFlags flags,
88 unsigned int maxStringLength,
89 Encoding defaultEncoding);
90
91 static void ToJson(Json::Value& target,
92 DcmMetaInfo& header,
93 DicomToJsonFormat format,
94 DicomToJsonFlags flags,
95 unsigned int maxStringLength);
96
97 static std::string GetName(const DicomTag& tag);
98
99 static DicomTag ParseTag(const char* name);
100
101 static DicomTag ParseTag(const std::string& name)
102 {
103 return ParseTag(name.c_str());
104 }
105
106 static bool HasTag(const DicomMap& fields,
107 const std::string& tagName)
108 {
109 return fields.HasTag(ParseTag(tagName));
110 }
111
112 static const DicomValue& GetValue(const DicomMap& fields,
113 const std::string& tagName)
114 {
115 return fields.GetValue(ParseTag(tagName));
116 }
117
118 static void SetValue(DicomMap& target,
119 const std::string& tagName,
120 DicomValue* value)
121 {
122 target.SetValue(ParseTag(tagName), value);
123 }
124
125 static void ToJson(Json::Value& result,
126 const DicomMap& values,
127 bool simplify);
128
129 static std::string GenerateUniqueIdentifier(ResourceType level);
130
131 static bool SaveToMemoryBuffer(std::string& buffer,
132 DcmDataset& dataSet);
133
134 static ValueRepresentation Convert(DcmEVR vr);
135
136 static ValueRepresentation LookupValueRepresentation(const DicomTag& tag);
137
138 static DcmElement* CreateElementForTag(const DicomTag& tag);
139
140 static void FillElementWithString(DcmElement& element,
141 const DicomTag& tag,
142 const std::string& utf8alue, // Encoded using UTF-8
143 bool decodeDataUriScheme,
144 Encoding dicomEncoding);
145
146 static DcmElement* FromJson(const DicomTag& tag,
147 const Json::Value& element, // Encoded using UTF-8
148 bool decodeDataUriScheme,
149 Encoding dicomEncoding);
150
151 static DcmPixelSequence* GetPixelSequence(DcmDataset& dataset);
152
153 static Encoding ExtractEncoding(const Json::Value& json,
154 Encoding defaultEncoding);
155
156 static DcmDataset* FromJson(const Json::Value& json, // Encoded using UTF-8
157 bool generateIdentifiers,
158 bool decodeDataUriScheme,
159 Encoding defaultEncoding);
160
161 static DcmFileFormat* LoadFromMemoryBuffer(const void* buffer,
162 size_t size);
163
164 static void FromJson(DicomMap& values,
165 const Json::Value& result);
166 };
167 }