comparison Framework/Orthanc/OrthancServer/ToDcmtkBridge.cpp @ 1:dc730d11b101

orthanc dependencies
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 22 Oct 2016 21:50:15 +0200
parents
children
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 #include "PrecompiledHeadersServer.h"
34 #include "ToDcmtkBridge.h"
35
36 #include <memory>
37 #include <dcmtk/dcmnet/diutil.h>
38
39 #include "../Core/OrthancException.h"
40
41
42 namespace Orthanc
43 {
44 DcmDataset* ToDcmtkBridge::Convert(const DicomMap& map)
45 {
46 std::auto_ptr<DcmDataset> result(new DcmDataset);
47
48 for (DicomMap::Map::const_iterator
49 it = map.map_.begin(); it != map.map_.end(); ++it)
50 {
51 if (!it->second->IsNull())
52 {
53 std::string s = it->second->GetContent();
54 DU_putStringDOElement(result.get(), Convert(it->first), s.c_str());
55 }
56 }
57
58 return result.release();
59 }
60
61
62 DcmEVR ToDcmtkBridge::Convert(ValueRepresentation vr)
63 {
64 switch (vr)
65 {
66 case ValueRepresentation_ApplicationEntity:
67 return EVR_AE;
68
69 case ValueRepresentation_AgeString:
70 return EVR_AS;
71
72 case ValueRepresentation_AttributeTag:
73 return EVR_AT;
74
75 case ValueRepresentation_CodeString:
76 return EVR_CS;
77
78 case ValueRepresentation_Date:
79 return EVR_DA;
80
81 case ValueRepresentation_DecimalString:
82 return EVR_DS;
83
84 case ValueRepresentation_DateTime:
85 return EVR_DT;
86
87 case ValueRepresentation_FloatingPointSingle:
88 return EVR_FL;
89
90 case ValueRepresentation_FloatingPointDouble:
91 return EVR_FD;
92
93 case ValueRepresentation_IntegerString:
94 return EVR_IS;
95
96 case ValueRepresentation_LongString:
97 return EVR_LO;
98
99 case ValueRepresentation_LongText:
100 return EVR_LT;
101
102 case ValueRepresentation_OtherByte:
103 return EVR_OB;
104
105 // Not supported as of DCMTK 3.6.0
106 /*case ValueRepresentation_OtherDouble:
107 return EVR_OD;*/
108
109 case ValueRepresentation_OtherFloat:
110 return EVR_OF;
111
112 // Not supported as of DCMTK 3.6.0
113 /*case ValueRepresentation_OtherLong:
114 return EVR_OL;*/
115
116 case ValueRepresentation_OtherWord:
117 return EVR_OW;
118
119 case ValueRepresentation_PersonName:
120 return EVR_PN;
121
122 case ValueRepresentation_ShortString:
123 return EVR_SH;
124
125 case ValueRepresentation_SignedLong:
126 return EVR_SL;
127
128 case ValueRepresentation_Sequence:
129 return EVR_SQ;
130
131 case ValueRepresentation_SignedShort:
132 return EVR_SS;
133
134 case ValueRepresentation_ShortText:
135 return EVR_ST;
136
137 case ValueRepresentation_Time:
138 return EVR_TM;
139
140 // Not supported as of DCMTK 3.6.0
141 /*case ValueRepresentation_UnlimitedCharacters:
142 return EVR_UC;*/
143
144 case ValueRepresentation_UniqueIdentifier:
145 return EVR_UI;
146
147 case ValueRepresentation_UnsignedLong:
148 return EVR_UL;
149
150 case ValueRepresentation_Unknown:
151 return EVR_UN;
152
153 // Not supported as of DCMTK 3.6.0
154 /*case ValueRepresentation_UniversalResource:
155 return EVR_UR;*/
156
157 case ValueRepresentation_UnsignedShort:
158 return EVR_US;
159
160 case ValueRepresentation_UnlimitedText:
161 return EVR_UT;
162
163 default:
164 throw OrthancException(ErrorCode_ParameterOutOfRange);
165 }
166 }
167 }