Mercurial > hg > orthanc
annotate Core/DicomParsing/FromDcmtkBridge.cpp @ 2573:3372c5255333 jobs
StoreScuJob, Orthanc Explorer for jobs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 09 May 2018 17:56:14 +0200 |
parents | ea63d9f90377 |
children | 47d812308d63 |
rev | line source |
---|---|
0 | 1 /** |
62 | 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:
1147
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2431
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 | |
448
9d830dcc7730
missing copyright information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
419
diff
changeset
|
33 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
34 #include "../PrecompiledHeaders.h" |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
35 |
71 | 36 #ifndef NOMINMAX |
37 #define NOMINMAX | |
38 #endif | |
0 | 39 |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
40 #if !defined(ORTHANC_SANDBOXED) |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
41 # error The macro ORTHANC_SANDBOXED must be defined |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
42 #endif |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
43 |
0 | 44 #include "FromDcmtkBridge.h" |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
45 #include "ToDcmtkBridge.h" |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
46 #include "../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
47 #include "../Toolbox.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
48 #include "../OrthancException.h" |
0 | 49 |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
50 #if ORTHANC_SANDBOXED == 0 |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
51 # include "../TemporaryFile.h" |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
52 #endif |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
53 |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
54 #include <list> |
71 | 55 #include <limits> |
56 | |
0 | 57 #include <boost/lexical_cast.hpp> |
1656 | 58 #include <boost/filesystem.hpp> |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
59 #include <boost/algorithm/string/predicate.hpp> |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
60 #include <boost/algorithm/string/join.hpp> |
0 | 61 |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
62 #include <dcmtk/dcmdata/dcdeftag.h> |
0 | 63 #include <dcmtk/dcmdata/dcdicent.h> |
64 #include <dcmtk/dcmdata/dcdict.h> | |
65 #include <dcmtk/dcmdata/dcfilefo.h> | |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
66 #include <dcmtk/dcmdata/dcostrmb.h> |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
67 #include <dcmtk/dcmdata/dcpixel.h> |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
68 #include <dcmtk/dcmdata/dcuid.h> |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
69 #include <dcmtk/dcmdata/dcistrmb.h> |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
70 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
71 #include <dcmtk/dcmdata/dcvrae.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
72 #include <dcmtk/dcmdata/dcvras.h> |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
73 #include <dcmtk/dcmdata/dcvrat.h> |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
74 #include <dcmtk/dcmdata/dcvrcs.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
75 #include <dcmtk/dcmdata/dcvrda.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
76 #include <dcmtk/dcmdata/dcvrds.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
77 #include <dcmtk/dcmdata/dcvrdt.h> |
0 | 78 #include <dcmtk/dcmdata/dcvrfd.h> |
79 #include <dcmtk/dcmdata/dcvrfl.h> | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
80 #include <dcmtk/dcmdata/dcvris.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
81 #include <dcmtk/dcmdata/dcvrlo.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
82 #include <dcmtk/dcmdata/dcvrlt.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
83 #include <dcmtk/dcmdata/dcvrpn.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
84 #include <dcmtk/dcmdata/dcvrsh.h> |
0 | 85 #include <dcmtk/dcmdata/dcvrsl.h> |
86 #include <dcmtk/dcmdata/dcvrss.h> | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
87 #include <dcmtk/dcmdata/dcvrst.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
88 #include <dcmtk/dcmdata/dcvrtm.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
89 #include <dcmtk/dcmdata/dcvrui.h> |
0 | 90 #include <dcmtk/dcmdata/dcvrul.h> |
91 #include <dcmtk/dcmdata/dcvrus.h> | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
92 #include <dcmtk/dcmdata/dcvrut.h> |
0 | 93 |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
94 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
95 # include <EmbeddedResources.h> |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
96 #endif |
682
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
677
diff
changeset
|
97 |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
98 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
99 # include <dcmtk/dcmjpeg/djdecode.h> |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
100 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
101 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
102 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
103 # include <dcmtk/dcmjpls/djdecode.h> |
1930 | 104 #endif |
105 | |
106 | |
62 | 107 namespace Orthanc |
0 | 108 { |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
109 static inline uint16_t GetCharValue(char c) |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
110 { |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
111 if (c >= '0' && c <= '9') |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
112 return c - '0'; |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
113 else if (c >= 'a' && c <= 'f') |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
114 return c - 'a' + 10; |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
115 else if (c >= 'A' && c <= 'F') |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
116 return c - 'A' + 10; |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
117 else |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
118 return 0; |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
119 } |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
120 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
121 static inline uint16_t GetTagValue(const char* c) |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
122 { |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
123 return ((GetCharValue(c[0]) << 12) + |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
124 (GetCharValue(c[1]) << 8) + |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
125 (GetCharValue(c[2]) << 4) + |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
126 GetCharValue(c[3])); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
127 } |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
176
diff
changeset
|
128 |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
129 |
1656 | 130 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 |
131 static void LoadEmbeddedDictionary(DcmDataDictionary& dictionary, | |
132 EmbeddedResources::FileResourceId resource) | |
133 { | |
2017 | 134 std::string content; |
135 EmbeddedResources::GetFileResource(content, resource); | |
1656 | 136 |
2513
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
137 #if ORTHANC_SANDBOXED == 0 |
2143
fd5875662670
creation of namespace SystemToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
138 TemporaryFile tmp; |
2017 | 139 tmp.Write(content); |
1656 | 140 |
141 if (!dictionary.loadDictionary(tmp.GetPath().c_str())) | |
142 { | |
2017 | 143 LOG(ERROR) << "Cannot read embedded dictionary. Under Windows, make sure that " |
144 << "your TEMP directory does not contain special characters."; | |
1656 | 145 throw OrthancException(ErrorCode_InternalError); |
146 } | |
2513
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
147 #else |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
148 if (!dictionary.loadFromMemory(content)) |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
149 { |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
150 LOG(ERROR) << "Cannot read embedded dictionary. Under Windows, make sure that " |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
151 << "your TEMP directory does not contain special characters."; |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
152 throw OrthancException(ErrorCode_InternalError); |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
153 } |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
154 #endif |
1656 | 155 } |
156 | |
157 #else | |
158 static void LoadExternalDictionary(DcmDataDictionary& dictionary, | |
159 const std::string& directory, | |
160 const std::string& filename) | |
161 { | |
162 boost::filesystem::path p = directory; | |
163 p = p / filename; | |
164 | |
165 LOG(WARNING) << "Loading the external DICOM dictionary " << p; | |
166 | |
167 if (!dictionary.loadDictionary(p.string().c_str())) | |
168 { | |
169 throw OrthancException(ErrorCode_InternalError); | |
170 } | |
171 } | |
172 #endif | |
173 | |
174 | |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
175 namespace |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
176 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
177 class DictionaryLocker |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
178 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
179 private: |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
180 DcmDataDictionary& dictionary_; |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
181 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
182 public: |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
183 DictionaryLocker() : dictionary_(dcmDataDict.wrlock()) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
184 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
185 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
186 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
187 ~DictionaryLocker() |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
188 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
189 dcmDataDict.unlock(); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
190 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
191 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
192 DcmDataDictionary& operator*() |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
193 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
194 return dictionary_; |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
195 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
196 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
197 DcmDataDictionary* operator->() |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
198 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
199 return &dictionary_; |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
200 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
201 }; |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
202 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
203 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
204 #define DCMTK_TO_CTYPE_CONVERTER(converter, cType, dcmtkType, getter) \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
205 \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
206 struct converter \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
207 { \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
208 typedef cType CType; \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
209 \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
210 static bool Apply(CType& result, \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
211 DcmElement& element, \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
212 size_t i) \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
213 { \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
214 return dynamic_cast<dcmtkType&>(element).getter(result, i).good(); \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
215 } \ |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
216 }; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
217 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
218 DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint32Converter, Sint32, DcmSignedLong, getSint32) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
219 DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint16Converter, Sint16, DcmSignedShort, getSint16) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
220 DCMTK_TO_CTYPE_CONVERTER(DcmtkToUint32Converter, Uint32, DcmUnsignedLong, getUint32) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
221 DCMTK_TO_CTYPE_CONVERTER(DcmtkToUint16Converter, Uint16, DcmUnsignedShort, getUint16) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
222 DCMTK_TO_CTYPE_CONVERTER(DcmtkToFloat32Converter, Float32, DcmFloatingPointSingle, getFloat32) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
223 DCMTK_TO_CTYPE_CONVERTER(DcmtkToFloat64Converter, Float64, DcmFloatingPointDouble, getFloat64) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
224 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
225 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
226 template <typename F> |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
227 static DicomValue* ApplyDcmtkToCTypeConverter(DcmElement& element) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
228 { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
229 F f; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
230 typename F::CType value; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
231 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
232 if (element.getLength() > sizeof(typename F::CType) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
233 && (element.getLength() % sizeof(typename F::CType)) == 0) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
234 { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
235 size_t count = element.getLength() / sizeof(typename F::CType); |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
236 std::vector<std::string> strings; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
237 for (size_t i = 0; i < count; i++) { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
238 if (f.Apply(value, element, i)) { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
239 strings.push_back(boost::lexical_cast<std::string>(value)); |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
240 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
241 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
242 return new DicomValue(boost::algorithm::join(strings, "\\"), false); |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
243 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
244 else if (f.Apply(value, element, 0)) { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
245 return new DicomValue(boost::lexical_cast<std::string>(value), false); |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
246 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
247 else { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
248 return new DicomValue; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
249 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
250 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
251 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
252 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
253 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
254 |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
255 void FromDcmtkBridge::InitializeDictionary(bool loadPrivateDictionary) |
1656 | 256 { |
2296 | 257 LOG(INFO) << "Using DCTMK version: " << DCMTK_VERSION_NUMBER; |
258 | |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
259 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
260 DictionaryLocker locker; |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
261 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
262 locker->clear(); |
1656 | 263 |
264 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 | |
2528
832217e4e872
old warnings turned into info
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2522
diff
changeset
|
265 LOG(INFO) << "Loading the embedded dictionaries"; |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
266 /** |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
267 * Do not load DICONDE dictionary, it breaks the other tags. The |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
268 * command "strace storescu 2>&1 |grep dic" shows that DICONDE |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
269 * dictionary is not loaded by storescu. |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
270 **/ |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
271 //LoadEmbeddedDictionary(*locker, EmbeddedResources::DICTIONARY_DICONDE); |
1656 | 272 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
273 LoadEmbeddedDictionary(*locker, EmbeddedResources::DICTIONARY_DICOM); |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
274 |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
275 if (loadPrivateDictionary) |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
276 { |
2152
cbebc5d072b0
Use of DCMTK 3.6.1 dictionary of private tags in standalone builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2151
diff
changeset
|
277 LOG(INFO) << "Loading the embedded dictionary of private tags"; |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
278 LoadEmbeddedDictionary(*locker, EmbeddedResources::DICTIONARY_PRIVATE); |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
279 } |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
280 else |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
281 { |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
282 LOG(INFO) << "The dictionary of private tags has not been loaded"; |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
283 } |
1656 | 284 |
2364 | 285 #elif defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
286 std::string path = DCMTK_DICTIONARY_DIR; |
1656 | 287 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
288 const char* env = std::getenv(DCM_DICT_ENVIRONMENT_VARIABLE); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
289 if (env != NULL) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
290 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
291 path = std::string(env); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
292 } |
1656 | 293 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
294 LoadExternalDictionary(*locker, path, "dicom.dic"); |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
295 |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
296 if (loadPrivateDictionary) |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
297 { |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
298 LoadExternalDictionary(*locker, path, "private.dic"); |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
299 } |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
300 else |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
301 { |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
302 LOG(INFO) << "The dictionary of private tags has not been loaded"; |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
303 } |
1656 | 304 |
305 #else | |
306 #error Support your platform here | |
307 #endif | |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
308 } |
1656 | 309 |
310 /* make sure data dictionary is loaded */ | |
311 if (!dcmDataDict.isDictionaryLoaded()) | |
312 { | |
313 LOG(ERROR) << "No DICOM dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE; | |
314 throw OrthancException(ErrorCode_InternalError); | |
315 } | |
316 | |
317 { | |
318 // Test the dictionary with a simple DICOM tag | |
319 DcmTag key(0x0010, 0x1030); // This is PatientWeight | |
320 if (key.getEVR() != EVR_DS) | |
321 { | |
322 LOG(ERROR) << "The DICOM dictionary has not been correctly read"; | |
323 throw OrthancException(ErrorCode_InternalError); | |
324 } | |
325 } | |
326 } | |
327 | |
328 | |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
329 void FromDcmtkBridge::RegisterDictionaryTag(const DicomTag& tag, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
330 ValueRepresentation vr, |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
331 const std::string& name, |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
332 unsigned int minMultiplicity, |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
333 unsigned int maxMultiplicity, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
334 const std::string& privateCreator) |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
335 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
336 if (minMultiplicity < 1) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
337 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
338 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
339 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
340 |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
341 bool arbitrary = false; |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
342 if (maxMultiplicity == 0) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
343 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
344 maxMultiplicity = DcmVariableVM; |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
345 arbitrary = true; |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
346 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
347 else if (maxMultiplicity < minMultiplicity) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
348 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
349 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
350 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
351 |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
352 DcmEVR evr = ToDcmtkBridge::Convert(vr); |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
353 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
354 LOG(INFO) << "Registering tag in dictionary: " << tag << " " << (DcmVR(evr).getValidVRName()) << " " |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
355 << name << " (multiplicity: " << minMultiplicity << "-" |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
356 << (arbitrary ? "n" : boost::lexical_cast<std::string>(maxMultiplicity)) << ")"; |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
357 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
358 std::auto_ptr<DcmDictEntry> entry; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
359 if (privateCreator.empty()) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
360 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
361 if (tag.GetGroup() % 2 == 1) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
362 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
363 char buf[128]; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
364 sprintf(buf, "Warning: You are registering a private tag (%04x,%04x), " |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
365 "but no private creator was associated with it", |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
366 tag.GetGroup(), tag.GetElement()); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
367 LOG(WARNING) << buf; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
368 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
369 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
370 entry.reset(new DcmDictEntry(tag.GetGroup(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
371 tag.GetElement(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
372 evr, name.c_str(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
373 static_cast<int>(minMultiplicity), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
374 static_cast<int>(maxMultiplicity), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
375 NULL /* version */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
376 OFTrue /* doCopyString */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
377 NULL /* private creator */)); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
378 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
379 else |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
380 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
381 // "Private Data Elements have an odd Group Number that is not |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
382 // (0001,eeee), (0003,eeee), (0005,eeee), (0007,eeee), or |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
383 // (FFFF,eeee)." |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
384 if (tag.GetGroup() % 2 == 0 /* even */ || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
385 tag.GetGroup() == 0x0001 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
386 tag.GetGroup() == 0x0003 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
387 tag.GetGroup() == 0x0005 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
388 tag.GetGroup() == 0x0007 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
389 tag.GetGroup() == 0xffff) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
390 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
391 char buf[128]; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
392 sprintf(buf, "Trying to register private tag (%04x,%04x), but it must have an odd group >= 0x0009", |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
393 tag.GetGroup(), tag.GetElement()); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
394 LOG(ERROR) << buf; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
395 throw OrthancException(ErrorCode_ParameterOutOfRange); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
396 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
397 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
398 entry.reset(new DcmDictEntry(tag.GetGroup(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
399 tag.GetElement(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
400 evr, name.c_str(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
401 static_cast<int>(minMultiplicity), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
402 static_cast<int>(maxMultiplicity), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
403 "private" /* version */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
404 OFTrue /* doCopyString */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
405 privateCreator.c_str())); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
406 } |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
407 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
408 entry->setGroupRangeRestriction(DcmDictRange_Unspecified); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
409 entry->setElementRangeRestriction(DcmDictRange_Unspecified); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
410 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
411 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
412 DictionaryLocker locker; |
2116
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
413 |
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
414 if (locker->findEntry(name.c_str())) |
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
415 { |
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
416 LOG(ERROR) << "Cannot register two tags with the same symbolic name \"" << name << "\""; |
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
417 throw OrthancException(ErrorCode_AlreadyExistingTag); |
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
418 } |
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
419 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
420 locker->addEntry(entry.release()); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
421 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
422 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
423 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
424 |
1936 | 425 Encoding FromDcmtkBridge::DetectEncoding(DcmItem& dataset, |
1928
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
426 Encoding defaultEncoding) |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
427 { |
1928
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
428 Encoding encoding = defaultEncoding; |
957
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
429 |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
430 OFString tmp; |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
431 if (dataset.findAndGetOFString(DCM_SpecificCharacterSet, tmp).good()) |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
432 { |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
433 std::string characterSet = Toolbox::StripSpaces(std::string(tmp.c_str())); |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
434 |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
435 if (characterSet.empty()) |
957
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
436 { |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
437 // Empty specific character set tag: Use the default encoding |
1087 | 438 } |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
439 else if (GetDicomEncoding(encoding, characterSet.c_str())) |
1087 | 440 { |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
441 // The specific character set is supported by the Orthanc core |
1087 | 442 } |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
443 else |
1087 | 444 { |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
445 LOG(WARNING) << "Value of Specific Character Set (0008,0005) is not supported: " << characterSet |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
446 << ", fallback to ASCII (remove all special characters)"; |
957
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
447 encoding = Encoding_Ascii; |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
448 } |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
449 } |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
450 else |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
451 { |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
452 // No specific character set tag: Use the default encoding |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
453 } |
957
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
454 |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
455 return encoding; |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
456 } |
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
457 |
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
458 |
2125 | 459 void FromDcmtkBridge::ExtractDicomSummary(DicomMap& target, |
460 DcmItem& dataset, | |
461 unsigned int maxStringLength, | |
462 Encoding defaultEncoding) | |
0 | 463 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
464 std::set<DicomTag> ignoreTagLength; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
465 |
1928
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
466 Encoding encoding = DetectEncoding(dataset, defaultEncoding); |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
467 |
0 | 468 target.Clear(); |
469 for (unsigned long i = 0; i < dataset.card(); i++) | |
470 { | |
471 DcmElement* element = dataset.getElement(i); | |
472 if (element && element->isLeaf()) | |
473 { | |
474 target.SetValue(element->getTag().getGTag(), | |
475 element->getTag().getETag(), | |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
476 ConvertLeafElement(*element, DicomToJsonFlags_Default, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
477 maxStringLength, encoding, ignoreTagLength)); |
0 | 478 } |
479 } | |
480 } | |
481 | |
482 | |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
483 DicomTag FromDcmtkBridge::Convert(const DcmTag& tag) |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
484 { |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
485 return DicomTag(tag.getGTag(), tag.getETag()); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
486 } |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
487 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
488 |
0 | 489 DicomTag FromDcmtkBridge::GetTag(const DcmElement& element) |
490 { | |
491 return DicomTag(element.getGTag(), element.getETag()); | |
492 } | |
493 | |
494 | |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
495 DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element, |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
496 DicomToJsonFlags flags, |
1929
cda5b0ab4ce5
ORTHANC_MAXIMUM_TAG_LENGTH made explicit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1928
diff
changeset
|
497 unsigned int maxStringLength, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
498 Encoding encoding, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
499 const std::set<DicomTag>& ignoreTagLength) |
0 | 500 { |
501 if (!element.isLeaf()) | |
502 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
503 // This function is only applicable to leaf elements |
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
504 throw OrthancException(ErrorCode_BadParameterType); |
0 | 505 } |
506 | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
507 char *c = NULL; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
508 if (element.isaString() && |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
509 element.getString(c).good()) |
0 | 510 { |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
511 if (c == NULL) // This case corresponds to the empty string |
0 | 512 { |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
513 return new DicomValue("", false); |
0 | 514 } |
515 else | |
516 { | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
517 std::string s(c); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
518 std::string utf8 = Toolbox::ConvertToUtf8(s, encoding); |
1854
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
519 |
1929
cda5b0ab4ce5
ORTHANC_MAXIMUM_TAG_LENGTH made explicit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1928
diff
changeset
|
520 if (maxStringLength != 0 && |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
521 utf8.size() > maxStringLength && |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
522 ignoreTagLength.find(GetTag(element)) == ignoreTagLength.end()) |
1854
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
523 { |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
524 return new DicomValue; // Too long, create a NULL value |
1854
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
525 } |
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
526 else |
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
527 { |
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
528 return new DicomValue(utf8, false); |
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
529 } |
0 | 530 } |
531 } | |
532 | |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
533 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
534 if (element.getVR() == EVR_UN) |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
535 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
536 // Unknown value representation: Lookup in the dictionary. This |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
537 // is notably the case for private tags registered with the |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
538 // "Dictionary" configuration option. |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
539 DictionaryLocker locker; |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
540 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
541 const DcmDictEntry* entry = locker->findEntry(element.getTag().getXTag(), |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
542 element.getTag().getPrivateCreator()); |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
543 if (entry != NULL && |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
544 entry->getVR().isaString()) |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
545 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
546 Uint8* data = NULL; |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
547 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
548 // At (*), we do not try and convert to UTF-8, as nothing says |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
549 // the encoding of the private tag is the same as that of the |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
550 // remaining of the DICOM dataset. Only go for ASCII strings. |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
551 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
552 if (element.getUint8Array(data) == EC_Normal && |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
553 Toolbox::IsAsciiString(data, element.getLength())) // (*) |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
554 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
555 if (data == NULL) |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
556 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
557 return new DicomValue("", false); // Empty string |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
558 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
559 else if (maxStringLength != 0 && |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
560 element.getLength() > maxStringLength && |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
561 ignoreTagLength.find(GetTag(element)) == ignoreTagLength.end()) |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
562 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
563 return new DicomValue; // Too long, create a NULL value |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
564 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
565 else |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
566 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
567 std::string s(reinterpret_cast<const char*>(data), element.getLength()); |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
568 return new DicomValue(s, false); |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
569 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
570 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
571 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
572 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
573 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
574 |
0 | 575 try |
576 { | |
577 // http://support.dcmtk.org/docs/dcvr_8h-source.html | |
578 switch (element.getVR()) | |
579 { | |
580 | |
581 /** | |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
582 * Deal with binary data (including PixelData). |
0 | 583 **/ |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
584 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
585 case EVR_OB: // other byte |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
586 case EVR_OF: // other float |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
587 case EVR_OW: // other word |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
588 case EVR_UN: // unknown value representation |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
589 case EVR_ox: // OB or OW depending on context |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
590 case EVR_DS: // decimal string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
591 case EVR_IS: // integer string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
592 case EVR_AS: // age string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
593 case EVR_DA: // date string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
594 case EVR_DT: // date time string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
595 case EVR_TM: // time string |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
596 case EVR_AE: // application entity title |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
597 case EVR_CS: // code string |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
598 case EVR_SH: // short string |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
599 case EVR_LO: // long string |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
600 case EVR_ST: // short text |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
601 case EVR_LT: // long text |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
602 case EVR_UT: // unlimited text |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
603 case EVR_PN: // person name |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
604 case EVR_UI: // unique identifier |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
605 case EVR_UNKNOWN: // used internally for elements with unknown VR (encoded with 4-byte length field in explicit VR) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
606 case EVR_UNKNOWN2B: // used internally for elements with unknown VR with 2-byte length field in explicit VR |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
607 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
608 if (!(flags & DicomToJsonFlags_ConvertBinaryToNull)) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
609 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
610 Uint8* data = NULL; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
611 if (element.getUint8Array(data) == EC_Normal) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
612 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
613 return new DicomValue(reinterpret_cast<const char*>(data), element.getLength(), true); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
614 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
615 } |
0 | 616 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
617 return new DicomValue; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
618 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
619 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
620 /** |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
621 * Numeric types |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
622 **/ |
0 | 623 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
624 case EVR_SL: // signed long |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
625 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
626 return ApplyDcmtkToCTypeConverter<DcmtkToSint32Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
627 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
628 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
629 case EVR_SS: // signed short |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
630 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
631 return ApplyDcmtkToCTypeConverter<DcmtkToSint16Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
632 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
633 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
634 case EVR_UL: // unsigned long |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
635 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
636 return ApplyDcmtkToCTypeConverter<DcmtkToUint32Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
637 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
638 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
639 case EVR_US: // unsigned short |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
640 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
641 return ApplyDcmtkToCTypeConverter<DcmtkToUint16Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
642 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
643 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
644 case EVR_FL: // float single-precision |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
645 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
646 return ApplyDcmtkToCTypeConverter<DcmtkToFloat32Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
647 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
648 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
649 case EVR_FD: // float double-precision |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
650 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
651 return ApplyDcmtkToCTypeConverter<DcmtkToFloat64Converter>(element); |
1131 | 652 } |
653 | |
654 | |
655 /** | |
656 * Attribute tag. | |
657 **/ | |
658 | |
659 case EVR_AT: | |
660 { | |
1147 | 661 DcmTagKey tag; |
662 if (dynamic_cast<DcmAttributeTag&>(element).getTagVal(tag, 0).good()) | |
663 { | |
664 DicomTag t(tag.getGroup(), tag.getElement()); | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
665 return new DicomValue(t.Format(), false); |
1147 | 666 } |
1131 | 667 else |
1147 | 668 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
669 return new DicomValue; |
1147 | 670 } |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
671 } |
0 | 672 |
673 | |
674 /** | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
675 * Sequence types, should never occur at this point because of |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
676 * "element.isLeaf()". |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
677 **/ |
0 | 678 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
679 case EVR_SQ: // sequence of items |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
680 return new DicomValue; |
0 | 681 |
682 | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
683 /** |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
684 * Internal to DCMTK. |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
685 **/ |
0 | 686 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
687 case EVR_xs: // SS or US depending on context |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
688 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
689 case EVR_na: // na="not applicable", for data which has no VR |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
690 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
691 case EVR_item: // used internally for items |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
692 case EVR_metainfo: // used internally for meta info datasets |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
693 case EVR_dataset: // used internally for datasets |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
694 case EVR_fileFormat: // used internally for DICOM files |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
695 case EVR_dicomDir: // used internally for DICOMDIR objects |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
696 case EVR_dirRecord: // used internally for DICOMDIR records |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
697 case EVR_pixelSQ: // used internally for pixel sequences in a compressed image |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
698 case EVR_pixelItem: // used internally for pixel items in a compressed image |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
699 case EVR_PixelData: // used internally for uncompressed pixeld data |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
700 case EVR_OverlayData: // used internally for overlay data |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
701 return new DicomValue; |
0 | 702 |
703 | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
704 /** |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
705 * Default case. |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
706 **/ |
0 | 707 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
708 default: |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
709 return new DicomValue; |
0 | 710 } |
711 } | |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
712 catch (boost::bad_lexical_cast&) |
0 | 713 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
714 return new DicomValue; |
0 | 715 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
716 catch (std::bad_cast&) |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
717 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
718 return new DicomValue; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
719 } |
0 | 720 } |
721 | |
722 | |
1687 | 723 static Json::Value& PrepareNode(Json::Value& parent, |
724 DcmElement& element, | |
725 DicomToJsonFormat format) | |
0 | 726 { |
1687 | 727 assert(parent.type() == Json::objectValue); |
0 | 728 |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
729 DicomTag tag(FromDcmtkBridge::GetTag(element)); |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
730 const std::string formattedTag = tag.Format(); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
731 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
732 if (format == DicomToJsonFormat_Short) |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
733 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
734 parent[formattedTag] = Json::nullValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
735 return parent[formattedTag]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
736 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
737 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
738 // This code gives access to the name of the private tags |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
739 std::string tagName = FromDcmtkBridge::GetTagName(element); |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
740 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
741 switch (format) |
0 | 742 { |
1860
c7d70f659190
DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1854
diff
changeset
|
743 case DicomToJsonFormat_Human: |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
744 parent[tagName] = Json::nullValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
745 return parent[tagName]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
746 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
747 case DicomToJsonFormat_Full: |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
748 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
749 parent[formattedTag] = Json::objectValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
750 Json::Value& node = parent[formattedTag]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
751 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
752 if (element.isLeaf()) |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
753 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
754 node["Name"] = tagName; |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
755 |
2076 | 756 if (element.getTag().getPrivateCreator() != NULL) |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
757 { |
2076 | 758 node["PrivateCreator"] = element.getTag().getPrivateCreator(); |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
759 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
760 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
761 return node; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
762 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
763 else |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
764 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
765 node["Name"] = tagName; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
766 node["Type"] = "Sequence"; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
767 node["Value"] = Json::nullValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
768 return node["Value"]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
769 } |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
770 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
771 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
772 default: |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
773 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1687 | 774 } |
775 } | |
776 | |
777 | |
778 static void LeafValueToJson(Json::Value& target, | |
779 const DicomValue& value, | |
780 DicomToJsonFormat format, | |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
781 DicomToJsonFlags flags, |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
782 unsigned int maxStringLength) |
1687 | 783 { |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
784 Json::Value* targetValue = NULL; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
785 Json::Value* targetType = NULL; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
786 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
787 switch (format) |
1687 | 788 { |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
789 case DicomToJsonFormat_Short: |
1860
c7d70f659190
DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1854
diff
changeset
|
790 case DicomToJsonFormat_Human: |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
791 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
792 assert(target.type() == Json::nullValue); |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
793 targetValue = ⌖ |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
794 break; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
795 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
796 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
797 case DicomToJsonFormat_Full: |
0 | 798 { |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
799 assert(target.type() == Json::objectValue); |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
800 target["Value"] = Json::nullValue; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
801 target["Type"] = Json::nullValue; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
802 targetType = &target["Type"]; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
803 targetValue = &target["Value"]; |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
804 break; |
0 | 805 } |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
806 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
807 default: |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
808 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1687 | 809 } |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
810 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
811 assert(targetValue != NULL); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
812 assert(targetValue->type() == Json::nullValue); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
813 assert(targetType == NULL || targetType->type() == Json::nullValue); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
814 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
815 if (value.IsNull()) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
816 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
817 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
818 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
819 *targetType = "Null"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
820 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
821 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
822 else if (value.IsBinary()) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
823 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
824 if (flags & DicomToJsonFlags_ConvertBinaryToAscii) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
825 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
826 *targetValue = Toolbox::ConvertToAscii(value.GetContent()); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
827 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
828 else |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
829 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
830 std::string s; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
831 value.FormatDataUriScheme(s); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
832 *targetValue = s; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
833 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
834 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
835 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
836 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
837 *targetType = "Binary"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
838 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
839 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
840 else if (maxStringLength == 0 || |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
841 value.GetContent().size() <= maxStringLength) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
842 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
843 *targetValue = value.GetContent(); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
844 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
845 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
846 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
847 *targetType = "String"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
848 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
849 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
850 else |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
851 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
852 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
853 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
854 *targetType = "TooLong"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
855 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
856 } |
1687 | 857 } |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
858 |
1687 | 859 |
2126 | 860 void FromDcmtkBridge::ElementToJson(Json::Value& parent, |
861 DcmElement& element, | |
862 DicomToJsonFormat format, | |
863 DicomToJsonFlags flags, | |
864 unsigned int maxStringLength, | |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
865 Encoding encoding, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
866 const std::set<DicomTag>& ignoreTagLength) |
1687 | 867 { |
1691 | 868 if (parent.type() == Json::nullValue) |
869 { | |
870 parent = Json::objectValue; | |
871 } | |
872 | |
873 assert(parent.type() == Json::objectValue); | |
1687 | 874 Json::Value& target = PrepareNode(parent, element, format); |
875 | |
876 if (element.isLeaf()) | |
877 { | |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
878 // The "0" below lets "LeafValueToJson()" take care of "TooLong" values |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
879 std::auto_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
880 (element, flags, 0, encoding, ignoreTagLength)); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
881 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
882 if (ignoreTagLength.find(GetTag(element)) == ignoreTagLength.end()) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
883 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
884 LeafValueToJson(target, *v, format, flags, maxStringLength); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
885 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
886 else |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
887 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
888 LeafValueToJson(target, *v, format, flags, 0); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
889 } |
0 | 890 } |
891 else | |
892 { | |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
893 assert(target.type() == Json::nullValue); |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
894 target = Json::arrayValue; |
0 | 895 |
896 // "All subclasses of DcmElement except for DcmSequenceOfItems | |
897 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset | |
1687 | 898 // etc. are not." The following dynamic_cast is thus OK. |
0 | 899 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element); |
900 | |
901 for (unsigned long i = 0; i < sequence.card(); i++) | |
902 { | |
903 DcmItem* child = sequence.getItem(i); | |
1687 | 904 Json::Value& v = target.append(Json::objectValue); |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
905 DatasetToJson(v, *child, format, flags, maxStringLength, encoding, ignoreTagLength); |
1687 | 906 } |
0 | 907 } |
908 } | |
909 | |
910 | |
2126 | 911 void FromDcmtkBridge::DatasetToJson(Json::Value& parent, |
912 DcmItem& item, | |
913 DicomToJsonFormat format, | |
914 DicomToJsonFlags flags, | |
915 unsigned int maxStringLength, | |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
916 Encoding encoding, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
917 const std::set<DicomTag>& ignoreTagLength) |
1686 | 918 { |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
919 assert(parent.type() == Json::objectValue); |
1686 | 920 |
921 for (unsigned long i = 0; i < item.card(); i++) | |
922 { | |
923 DcmElement* element = item.getElement(i); | |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
924 if (element == NULL) |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
925 { |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
926 throw OrthancException(ErrorCode_InternalError); |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
927 } |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
928 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
929 DicomTag tag(FromDcmtkBridge::Convert(element->getTag())); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
930 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
931 /*element->getTag().isPrivate()*/ |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
932 if (tag.IsPrivate() && |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
933 !(flags & DicomToJsonFlags_IncludePrivateTags)) |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
934 { |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
935 continue; |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
936 } |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
937 |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
938 if (!(flags & DicomToJsonFlags_IncludeUnknownTags)) |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
939 { |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
940 DictionaryLocker locker; |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
941 if (locker->findEntry(element->getTag(), NULL) == NULL) |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
942 { |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
943 continue; |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
944 } |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
945 } |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
946 |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
947 DcmEVR evr = element->getTag().getEVR(); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
948 if (evr == EVR_OB || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
949 evr == EVR_OF || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
950 evr == EVR_OW || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
951 evr == EVR_UN || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
952 evr == EVR_ox) |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
953 { |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
954 // This is a binary tag |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
955 if ((tag == DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludePixelData)) || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
956 (tag != DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludeBinary))) |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
957 { |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
958 continue; |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
959 } |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
960 } |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
961 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
962 FromDcmtkBridge::ElementToJson(parent, *element, format, flags, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
963 maxStringLength, encoding, ignoreTagLength); |
1686 | 964 } |
965 } | |
966 | |
967 | |
2126 | 968 void FromDcmtkBridge::ExtractDicomAsJson(Json::Value& target, |
969 DcmDataset& dataset, | |
970 DicomToJsonFormat format, | |
971 DicomToJsonFlags flags, | |
2131 | 972 unsigned int maxStringLength, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
973 Encoding defaultEncoding, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
974 const std::set<DicomTag>& ignoreTagLength) |
0 | 975 { |
2131 | 976 Encoding encoding = DetectEncoding(dataset, defaultEncoding); |
2126 | 977 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
978 target = Json::objectValue; |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
979 DatasetToJson(target, dataset, format, flags, maxStringLength, encoding, ignoreTagLength); |
0 | 980 } |
981 | |
982 | |
2126 | 983 void FromDcmtkBridge::ExtractHeaderAsJson(Json::Value& target, |
984 DcmMetaInfo& dataset, | |
985 DicomToJsonFormat format, | |
986 DicomToJsonFlags flags, | |
987 unsigned int maxStringLength) | |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
988 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
989 std::set<DicomTag> ignoreTagLength; |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
990 target = Json::objectValue; |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
991 DatasetToJson(target, dataset, format, flags, maxStringLength, Encoding_Ascii, ignoreTagLength); |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
992 } |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
993 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
994 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
995 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
996 static std::string GetTagNameInternal(DcmTag& tag) |
0 | 997 { |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
998 { |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
999 // Some patches for important tags because of different DICOM |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1000 // dictionaries between DCMTK versions |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1001 DicomTag tmp(tag.getGroup(), tag.getElement()); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1002 std::string n = tmp.GetMainTagsName(); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1003 if (n.size() != 0) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1004 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1005 return n; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1006 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1007 // End of patches |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1008 } |
106 | 1009 |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1010 #if 0 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1011 // This version explicitly calls the dictionary |
0 | 1012 const DcmDataDictionary& dict = dcmDataDict.rdlock(); |
1013 const DcmDictEntry* entry = dict.findEntry(tag, NULL); | |
1014 | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1015 std::string s(DcmTag_ERROR_TagName); |
0 | 1016 if (entry != NULL) |
1017 { | |
1018 s = std::string(entry->getTagName()); | |
1019 } | |
1020 | |
1021 dcmDataDict.unlock(); | |
1022 return s; | |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1023 #else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1024 const char* name = tag.getTagName(); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1025 if (name == NULL) |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1026 { |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1027 return DcmTag_ERROR_TagName; |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1028 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1029 else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1030 { |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1031 return std::string(name); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1032 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1033 #endif |
0 | 1034 } |
1035 | |
1036 | |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1037 std::string FromDcmtkBridge::GetTagName(const DicomTag& t, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1038 const std::string& privateCreator) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1039 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1040 DcmTag tag(t.GetGroup(), t.GetElement()); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1041 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1042 if (!privateCreator.empty()) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1043 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1044 tag.setPrivateCreator(privateCreator.c_str()); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1045 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1046 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1047 return GetTagNameInternal(tag); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1048 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1049 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1050 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1051 std::string FromDcmtkBridge::GetTagName(const DcmElement& element) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1052 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1053 // Copy the tag to ensure const-correctness of DcmElement. Note |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1054 // that the private creator information is also copied. |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1055 DcmTag tag(element.getTag()); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1056 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1057 return GetTagNameInternal(tag); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1058 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1059 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1060 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1061 |
304 | 1062 DicomTag FromDcmtkBridge::ParseTag(const char* name) |
0 | 1063 { |
304 | 1064 if (strlen(name) == 9 && |
1065 isxdigit(name[0]) && | |
1066 isxdigit(name[1]) && | |
1067 isxdigit(name[2]) && | |
1068 isxdigit(name[3]) && | |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
1069 (name[4] == '-' || name[4] == ',') && |
304 | 1070 isxdigit(name[5]) && |
1071 isxdigit(name[6]) && | |
1072 isxdigit(name[7]) && | |
1073 isxdigit(name[8])) | |
1074 { | |
1075 uint16_t group = GetTagValue(name); | |
1076 uint16_t element = GetTagValue(name + 5); | |
1077 return DicomTag(group, element); | |
1078 } | |
1079 | |
1861
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1080 if (strlen(name) == 8 && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1081 isxdigit(name[0]) && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1082 isxdigit(name[1]) && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1083 isxdigit(name[2]) && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1084 isxdigit(name[3]) && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1085 isxdigit(name[4]) && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1086 isxdigit(name[5]) && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1087 isxdigit(name[6]) && |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1088 isxdigit(name[7])) |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1089 { |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1090 uint16_t group = GetTagValue(name); |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1091 uint16_t element = GetTagValue(name + 4); |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1092 return DicomTag(group, element); |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1093 } |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1094 |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1095 #if 0 |
0 | 1096 const DcmDataDictionary& dict = dcmDataDict.rdlock(); |
1097 const DcmDictEntry* entry = dict.findEntry(name); | |
1098 | |
1099 if (entry == NULL) | |
1100 { | |
1101 dcmDataDict.unlock(); | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
1102 throw OrthancException(ErrorCode_UnknownDicomTag); |
0 | 1103 } |
1104 else | |
1105 { | |
1106 DcmTagKey key = entry->getKey(); | |
1107 DicomTag tag(key.getGroup(), key.getElement()); | |
1108 dcmDataDict.unlock(); | |
1109 return tag; | |
1110 } | |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1111 #else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1112 DcmTag tag; |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1113 if (DcmTag::findTagFromName(name, tag).good()) |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1114 { |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1115 return DicomTag(tag.getGTag(), tag.getETag()); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1116 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1117 else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1118 { |
2470 | 1119 LOG(INFO) << "Unknown DICOM tag: \"" << name << "\""; |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
1120 throw OrthancException(ErrorCode_UnknownDicomTag); |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1121 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1122 #endif |
0 | 1123 } |
1124 | |
1125 | |
1655
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1126 bool FromDcmtkBridge::IsUnknownTag(const DicomTag& tag) |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1127 { |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1128 DcmTag tmp(tag.GetGroup(), tag.GetElement()); |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1129 return tmp.isUnknownVR(); |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1130 } |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1131 |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1132 |
0 | 1133 void FromDcmtkBridge::ToJson(Json::Value& result, |
1368 | 1134 const DicomMap& values, |
1135 bool simplify) | |
0 | 1136 { |
1137 if (result.type() != Json::objectValue) | |
1138 { | |
62 | 1139 throw OrthancException(ErrorCode_BadParameterType); |
0 | 1140 } |
1141 | |
1142 result.clear(); | |
1143 | |
1144 for (DicomMap::Map::const_iterator | |
656 | 1145 it = values.map_.begin(); it != values.map_.end(); ++it) |
0 | 1146 { |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1147 // TODO Inject PrivateCreator if some is available in the DicomMap? |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1148 const std::string tagName = GetTagName(it->first, ""); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1149 |
1368 | 1150 if (simplify) |
1151 { | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1152 if (it->second->IsNull()) |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1153 { |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1154 result[tagName] = Json::nullValue; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1155 } |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1156 else |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1157 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1158 // TODO IsBinary |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1159 result[tagName] = it->second->GetContent(); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1160 } |
1368 | 1161 } |
1162 else | |
1163 { | |
1164 Json::Value value = Json::objectValue; | |
1165 | |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1166 value["Name"] = tagName; |
1368 | 1167 |
1168 if (it->second->IsNull()) | |
1169 { | |
1170 value["Type"] = "Null"; | |
1171 value["Value"] = Json::nullValue; | |
1172 } | |
1173 else | |
1174 { | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1175 // TODO IsBinary |
1368 | 1176 value["Type"] = "String"; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
1177 value["Value"] = it->second->GetContent(); |
1368 | 1178 } |
1179 | |
1180 result[it->first.Format()] = value; | |
1181 } | |
0 | 1182 } |
1183 } | |
176 | 1184 |
1185 | |
788 | 1186 std::string FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType level) |
176 | 1187 { |
1188 char uid[100]; | |
1189 | |
1190 switch (level) | |
1191 { | |
788 | 1192 case ResourceType_Patient: |
311 | 1193 // The "PatientID" field is of type LO (Long String), 64 |
1194 // Bytes Maximum. An UUID is of length 36, thus it can be used | |
1195 // as a random PatientID. | |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
1196 return Toolbox::GenerateUuid(); |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1197 |
788 | 1198 case ResourceType_Instance: |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1199 return dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT); |
176 | 1200 |
788 | 1201 case ResourceType_Series: |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1202 return dcmGenerateUniqueIdentifier(uid, SITE_SERIES_UID_ROOT); |
176 | 1203 |
788 | 1204 case ResourceType_Study: |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1205 return dcmGenerateUniqueIdentifier(uid, SITE_STUDY_UID_ROOT); |
176 | 1206 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1207 default: |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1208 throw OrthancException(ErrorCode_ParameterOutOfRange); |
176 | 1209 } |
1210 } | |
1211 | |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1212 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
1213 DcmDataset& dataSet) |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1214 { |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1215 // Determine the transfer syntax which shall be used to write the |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1216 // information to the file. We always switch to the Little Endian |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1217 // syntax, with explicit length. |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1218 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1219 // http://support.dcmtk.org/docs/dcxfer_8h-source.html |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1220 |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1221 |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1222 /** |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1223 * Note that up to Orthanc 0.7.1 (inclusive), the |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1224 * "EXS_LittleEndianExplicit" was always used to save the DICOM |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1225 * dataset into memory. We now keep the original transfer syntax |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1226 * (if available). |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1227 **/ |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
1228 E_TransferSyntax xfer = dataSet.getOriginalXfer(); |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1229 if (xfer == EXS_Unknown) |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1230 { |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1231 // No information about the original transfer syntax: This is |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1232 // most probably a DICOM dataset that was read from memory. |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1233 xfer = EXS_LittleEndianExplicit; |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1234 } |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1235 |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1236 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1237 |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1238 // Create the meta-header information |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
1239 DcmFileFormat ff(&dataSet); |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1240 ff.validateMetaInfo(xfer); |
1316
1c8dfedefefe
Fix anonymization generating non-portable DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1307
diff
changeset
|
1241 ff.removeInvalidGroups(); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1242 |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1243 // Create a memory buffer with the proper size |
1876
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1244 { |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1245 const uint32_t estimatedSize = ff.calcElementLength(xfer, encodingType); // (*) |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1246 buffer.resize(estimatedSize); |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1247 } |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1248 |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1249 DcmOutputBufferStream ob(&buffer[0], buffer.size()); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1250 |
661
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1251 // Fill the memory buffer with the meta-header and the dataset |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1252 ff.transferInit(); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1253 OFCondition c = ff.write(ob, xfer, encodingType, NULL, |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1254 /*opt_groupLength*/ EGL_recalcGL, |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1255 /*opt_paddingType*/ EPD_withoutPadding); |
d233b5090105
accept more transfer syntaxes for C-Store SCP, write meta-header when receiving files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
1256 ff.transferEnd(); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1257 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1258 if (c.good()) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1259 { |
1876
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1260 // The DICOM file is successfully written, truncate the target |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1261 // buffer if its size was overestimated by (*) |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1262 ob.flush(); |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1263 |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1264 size_t effectiveSize = static_cast<size_t>(ob.tell()); |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1265 if (effectiveSize < buffer.size()) |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1266 { |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1267 buffer.resize(effectiveSize); |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1268 } |
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1269 |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1270 return true; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1271 } |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1272 else |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1273 { |
1876
9b458e4484a1
truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1861
diff
changeset
|
1274 // Error |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1275 buffer.clear(); |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1276 return false; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1277 } |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1278 } |
1360 | 1279 |
1280 | |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1281 ValueRepresentation FromDcmtkBridge::LookupValueRepresentation(const DicomTag& tag) |
1360 | 1282 { |
1283 DcmTag t(tag.GetGroup(), tag.GetElement()); | |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1284 return Convert(t.getEVR()); |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1285 } |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1286 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1287 ValueRepresentation FromDcmtkBridge::Convert(const DcmEVR vr) |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1288 { |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1289 switch (vr) |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1290 { |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1291 case EVR_AE: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1292 return ValueRepresentation_ApplicationEntity; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1293 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1294 case EVR_AS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1295 return ValueRepresentation_AgeString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1296 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1297 case EVR_AT: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1298 return ValueRepresentation_AttributeTag; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1299 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1300 case EVR_CS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1301 return ValueRepresentation_CodeString; |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1302 |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1303 case EVR_DA: |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1304 return ValueRepresentation_Date; |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1305 |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1306 case EVR_DS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1307 return ValueRepresentation_DecimalString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1308 |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1309 case EVR_DT: |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1310 return ValueRepresentation_DateTime; |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1311 |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1312 case EVR_FL: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1313 return ValueRepresentation_FloatingPointSingle; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1314 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1315 case EVR_FD: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1316 return ValueRepresentation_FloatingPointDouble; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1317 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1318 case EVR_IS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1319 return ValueRepresentation_IntegerString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1320 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1321 case EVR_LO: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1322 return ValueRepresentation_LongString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1323 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1324 case EVR_LT: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1325 return ValueRepresentation_LongText; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1326 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1327 case EVR_OB: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1328 return ValueRepresentation_OtherByte; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1329 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1330 // Not supported as of DCMTK 3.6.0 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1331 /*case EVR_OD: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1332 return ValueRepresentation_OtherDouble;*/ |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1333 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1334 case EVR_OF: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1335 return ValueRepresentation_OtherFloat; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1336 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1337 // Not supported as of DCMTK 3.6.0 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1338 /*case EVR_OL: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1339 return ValueRepresentation_OtherLong;*/ |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1340 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1341 case EVR_OW: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1342 return ValueRepresentation_OtherWord; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1343 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1344 case EVR_PN: |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1345 return ValueRepresentation_PersonName; |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1346 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1347 case EVR_SH: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1348 return ValueRepresentation_ShortString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1349 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1350 case EVR_SL: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1351 return ValueRepresentation_SignedLong; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1352 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1353 case EVR_SQ: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1354 return ValueRepresentation_Sequence; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1355 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1356 case EVR_SS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1357 return ValueRepresentation_SignedShort; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1358 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1359 case EVR_ST: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1360 return ValueRepresentation_ShortText; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1361 |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1362 case EVR_TM: |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1363 return ValueRepresentation_Time; |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1364 |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1365 // Not supported as of DCMTK 3.6.0 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1366 /*case EVR_UC: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1367 return ValueRepresentation_UnlimitedCharacters;*/ |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1368 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1369 case EVR_UI: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1370 return ValueRepresentation_UniqueIdentifier; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1371 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1372 case EVR_UL: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1373 return ValueRepresentation_UnsignedLong; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1374 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1375 case EVR_UN: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1376 return ValueRepresentation_Unknown; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1377 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1378 // Not supported as of DCMTK 3.6.0 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1379 /*case EVR_UR: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1380 return ValueRepresentation_UniversalResource;*/ |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1381 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1382 case EVR_US: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1383 return ValueRepresentation_UnsignedShort; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1384 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1385 case EVR_UT: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1386 return ValueRepresentation_UnlimitedText; |
1792 | 1387 |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1388 default: |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1389 return ValueRepresentation_NotSupported; |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1390 } |
1360 | 1391 } |
1392 | |
1689 | 1393 |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1394 static bool IsBinaryTag(const DcmTag& key) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1395 { |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1396 return (key.isUnknownVR() || |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1397 key.getEVR() == EVR_OB || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1398 key.getEVR() == EVR_OF || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1399 key.getEVR() == EVR_OW || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1400 key.getEVR() == EVR_UN || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1401 key.getEVR() == EVR_ox); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1402 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1403 |
1689 | 1404 |
1405 DcmElement* FromDcmtkBridge::CreateElementForTag(const DicomTag& tag) | |
1406 { | |
1407 DcmTag key(tag.GetGroup(), tag.GetElement()); | |
1408 | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1409 if (tag.IsPrivate() || |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1410 IsBinaryTag(key)) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1411 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1412 return new DcmOtherByteOtherWord(key); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1413 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1414 |
1689 | 1415 switch (key.getEVR()) |
1416 { | |
1417 // http://support.dcmtk.org/docs/dcvr_8h-source.html | |
1418 | |
1419 /** | |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1420 * Binary types, handled above |
1689 | 1421 **/ |
1422 | |
1423 case EVR_OB: // other byte | |
1424 case EVR_OF: // other float | |
1425 case EVR_OW: // other word | |
1426 case EVR_UN: // unknown value representation | |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1427 case EVR_ox: // OB or OW depending on context |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1428 throw OrthancException(ErrorCode_InternalError); |
1689 | 1429 |
1430 | |
1431 /** | |
1432 * String types. | |
1433 * http://support.dcmtk.org/docs/classDcmByteString.html | |
1434 **/ | |
1435 | |
1436 case EVR_AS: // age string | |
1437 return new DcmAgeString(key); | |
1438 | |
1439 case EVR_AE: // application entity title | |
1440 return new DcmApplicationEntity(key); | |
1441 | |
1442 case EVR_CS: // code string | |
1443 return new DcmCodeString(key); | |
1444 | |
1445 case EVR_DA: // date string | |
1446 return new DcmDate(key); | |
1447 | |
1448 case EVR_DT: // date time string | |
1449 return new DcmDateTime(key); | |
1450 | |
1451 case EVR_DS: // decimal string | |
1452 return new DcmDecimalString(key); | |
1453 | |
1454 case EVR_IS: // integer string | |
1455 return new DcmIntegerString(key); | |
1456 | |
1457 case EVR_TM: // time string | |
1458 return new DcmTime(key); | |
1459 | |
1460 case EVR_UI: // unique identifier | |
1461 return new DcmUniqueIdentifier(key); | |
1462 | |
1463 case EVR_ST: // short text | |
1464 return new DcmShortText(key); | |
1465 | |
1466 case EVR_LO: // long string | |
1467 return new DcmLongString(key); | |
1468 | |
1469 case EVR_LT: // long text | |
1470 return new DcmLongText(key); | |
1471 | |
1472 case EVR_UT: // unlimited text | |
1473 return new DcmUnlimitedText(key); | |
1474 | |
1475 case EVR_SH: // short string | |
1476 return new DcmShortString(key); | |
1477 | |
1478 case EVR_PN: // person name | |
1479 return new DcmPersonName(key); | |
1480 | |
1481 | |
1482 /** | |
1483 * Numerical types | |
1484 **/ | |
1485 | |
1486 case EVR_SL: // signed long | |
1487 return new DcmSignedLong(key); | |
1488 | |
1489 case EVR_SS: // signed short | |
1490 return new DcmSignedShort(key); | |
1491 | |
1492 case EVR_UL: // unsigned long | |
1493 return new DcmUnsignedLong(key); | |
1494 | |
1495 case EVR_US: // unsigned short | |
1496 return new DcmUnsignedShort(key); | |
1497 | |
1498 case EVR_FL: // float single-precision | |
1499 return new DcmFloatingPointSingle(key); | |
1500 | |
1501 case EVR_FD: // float double-precision | |
1502 return new DcmFloatingPointDouble(key); | |
1503 | |
1504 | |
1505 /** | |
1506 * Sequence types, should never occur at this point. | |
1507 **/ | |
1508 | |
1509 case EVR_SQ: // sequence of items | |
1510 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1511 | |
1512 | |
1513 /** | |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1514 * TODO |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1515 **/ |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1516 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1517 case EVR_AT: // attribute tag |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1518 throw OrthancException(ErrorCode_NotImplemented); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1519 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1520 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1521 /** |
1689 | 1522 * Internal to DCMTK. |
1523 **/ | |
1524 | |
1525 case EVR_xs: // SS or US depending on context | |
1526 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) | |
1527 case EVR_na: // na="not applicable", for data which has no VR | |
1528 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor | |
1529 case EVR_item: // used internally for items | |
1530 case EVR_metainfo: // used internally for meta info datasets | |
1531 case EVR_dataset: // used internally for datasets | |
1532 case EVR_fileFormat: // used internally for DICOM files | |
1533 case EVR_dicomDir: // used internally for DICOMDIR objects | |
1534 case EVR_dirRecord: // used internally for DICOMDIR records | |
1535 case EVR_pixelSQ: // used internally for pixel sequences in a compressed image | |
1536 case EVR_pixelItem: // used internally for pixel items in a compressed image | |
1537 case EVR_UNKNOWN: // used internally for elements with unknown VR (encoded with 4-byte length field in explicit VR) | |
1538 case EVR_PixelData: // used internally for uncompressed pixeld data | |
1539 case EVR_OverlayData: // used internally for overlay data | |
1540 case EVR_UNKNOWN2B: // used internally for elements with unknown VR with 2-byte length field in explicit VR | |
1541 default: | |
1542 break; | |
1543 } | |
1544 | |
1545 throw OrthancException(ErrorCode_InternalError); | |
1546 } | |
1547 | |
1548 | |
1549 | |
1550 void FromDcmtkBridge::FillElementWithString(DcmElement& element, | |
1551 const DicomTag& tag, | |
1695 | 1552 const std::string& utf8Value, |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1553 bool decodeDataUriScheme, |
1695 | 1554 Encoding dicomEncoding) |
1689 | 1555 { |
1556 std::string binary; | |
1695 | 1557 const std::string* decoded = &utf8Value; |
1689 | 1558 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1559 if (decodeDataUriScheme && |
1695 | 1560 boost::starts_with(utf8Value, "data:application/octet-stream;base64,")) |
1689 | 1561 { |
1562 std::string mime; | |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1563 if (!Toolbox::DecodeDataUriScheme(mime, binary, utf8Value)) |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1564 { |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1565 throw OrthancException(ErrorCode_BadFileFormat); |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1566 } |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1567 |
1695 | 1568 decoded = &binary; |
1569 } | |
1570 else if (dicomEncoding != Encoding_Utf8) | |
1571 { | |
1572 binary = Toolbox::ConvertFromUtf8(utf8Value, dicomEncoding); | |
1689 | 1573 decoded = &binary; |
1574 } | |
1575 | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1576 DcmTag key(tag.GetGroup(), tag.GetElement()); |
1689 | 1577 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1578 if (tag.IsPrivate() || |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1579 IsBinaryTag(key)) |
1689 | 1580 { |
1581 if (element.putUint8Array((const Uint8*) decoded->c_str(), decoded->size()).good()) | |
1582 { | |
1583 return; | |
1584 } | |
1585 else | |
1586 { | |
1587 throw OrthancException(ErrorCode_InternalError); | |
1588 } | |
1589 } | |
1590 | |
1591 bool ok = false; | |
1592 | |
1593 try | |
1594 { | |
1595 switch (key.getEVR()) | |
1596 { | |
1597 // http://support.dcmtk.org/docs/dcvr_8h-source.html | |
1598 | |
1599 /** | |
1600 * TODO. | |
1601 **/ | |
1602 | |
1603 case EVR_OB: // other byte | |
1604 case EVR_OF: // other float | |
1605 case EVR_OW: // other word | |
1606 case EVR_AT: // attribute tag | |
1607 throw OrthancException(ErrorCode_NotImplemented); | |
1608 | |
1609 case EVR_UN: // unknown value representation | |
1610 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1611 | |
1612 | |
1613 /** | |
1614 * String types. | |
1615 **/ | |
1616 | |
1617 case EVR_DS: // decimal string | |
1618 case EVR_IS: // integer string | |
1619 case EVR_AS: // age string | |
1620 case EVR_DA: // date string | |
1621 case EVR_DT: // date time string | |
1622 case EVR_TM: // time string | |
1623 case EVR_AE: // application entity title | |
1624 case EVR_CS: // code string | |
1625 case EVR_SH: // short string | |
1626 case EVR_LO: // long string | |
1627 case EVR_ST: // short text | |
1628 case EVR_LT: // long text | |
1629 case EVR_UT: // unlimited text | |
1630 case EVR_PN: // person name | |
1631 case EVR_UI: // unique identifier | |
1632 { | |
1633 ok = element.putString(decoded->c_str()).good(); | |
1634 break; | |
1635 } | |
1636 | |
1637 | |
1638 /** | |
1639 * Numerical types | |
1640 **/ | |
1641 | |
1642 case EVR_SL: // signed long | |
1643 { | |
1644 ok = element.putSint32(boost::lexical_cast<Sint32>(*decoded)).good(); | |
1645 break; | |
1646 } | |
1647 | |
1648 case EVR_SS: // signed short | |
1649 { | |
1650 ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good(); | |
1651 break; | |
1652 } | |
1653 | |
1654 case EVR_UL: // unsigned long | |
1655 { | |
1656 ok = element.putUint32(boost::lexical_cast<Uint32>(*decoded)).good(); | |
1657 break; | |
1658 } | |
1659 | |
1660 case EVR_US: // unsigned short | |
1661 { | |
1662 ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good(); | |
1663 break; | |
1664 } | |
1665 | |
1666 case EVR_FL: // float single-precision | |
1667 { | |
1668 ok = element.putFloat32(boost::lexical_cast<float>(*decoded)).good(); | |
1669 break; | |
1670 } | |
1671 | |
1672 case EVR_FD: // float double-precision | |
1673 { | |
1674 ok = element.putFloat64(boost::lexical_cast<double>(*decoded)).good(); | |
1675 break; | |
1676 } | |
1677 | |
1678 | |
1679 /** | |
1680 * Sequence types, should never occur at this point. | |
1681 **/ | |
1682 | |
1683 case EVR_SQ: // sequence of items | |
1684 { | |
1685 ok = false; | |
1686 break; | |
1687 } | |
1688 | |
1689 | |
1690 /** | |
1691 * Internal to DCMTK. | |
1692 **/ | |
1693 | |
1694 case EVR_ox: // OB or OW depending on context | |
1695 case EVR_xs: // SS or US depending on context | |
1696 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) | |
1697 case EVR_na: // na="not applicable", for data which has no VR | |
1698 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor | |
1699 case EVR_item: // used internally for items | |
1700 case EVR_metainfo: // used internally for meta info datasets | |
1701 case EVR_dataset: // used internally for datasets | |
1702 case EVR_fileFormat: // used internally for DICOM files | |
1703 case EVR_dicomDir: // used internally for DICOMDIR objects | |
1704 case EVR_dirRecord: // used internally for DICOMDIR records | |
1705 case EVR_pixelSQ: // used internally for pixel sequences in a compressed image | |
1706 case EVR_pixelItem: // used internally for pixel items in a compressed image | |
1707 case EVR_UNKNOWN: // used internally for elements with unknown VR (encoded with 4-byte length field in explicit VR) | |
1708 case EVR_PixelData: // used internally for uncompressed pixeld data | |
1709 case EVR_OverlayData: // used internally for overlay data | |
1710 case EVR_UNKNOWN2B: // used internally for elements with unknown VR with 2-byte length field in explicit VR | |
1711 default: | |
1712 break; | |
1713 } | |
1714 } | |
1715 catch (boost::bad_lexical_cast&) | |
1716 { | |
1717 ok = false; | |
1718 } | |
1719 | |
1720 if (!ok) | |
1721 { | |
2216
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1722 LOG(ERROR) << "While creating a DICOM instance, tag (" << tag.Format() |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1723 << ") has out-of-range value: \"" << *decoded << "\""; |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1724 throw OrthancException(ErrorCode_BadFileFormat); |
1689 | 1725 } |
1726 } | |
1727 | |
1728 | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1729 DcmElement* FromDcmtkBridge::FromJson(const DicomTag& tag, |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1730 const Json::Value& value, |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1731 bool decodeDataUriScheme, |
1695 | 1732 Encoding dicomEncoding) |
1689 | 1733 { |
1734 std::auto_ptr<DcmElement> element; | |
1735 | |
1690 | 1736 switch (value.type()) |
1689 | 1737 { |
1690 | 1738 case Json::stringValue: |
1739 element.reset(CreateElementForTag(tag)); | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1740 FillElementWithString(*element, tag, value.asString(), decodeDataUriScheme, dicomEncoding); |
1690 | 1741 break; |
1742 | |
2216
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1743 case Json::nullValue: |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1744 element.reset(CreateElementForTag(tag)); |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1745 FillElementWithString(*element, tag, "", decodeDataUriScheme, dicomEncoding); |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1746 break; |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1747 |
1690 | 1748 case Json::arrayValue: |
1749 { | |
1750 DcmTag key(tag.GetGroup(), tag.GetElement()); | |
1751 if (key.getEVR() != EVR_SQ) | |
1752 { | |
1753 throw OrthancException(ErrorCode_BadParameterType); | |
1754 } | |
1755 | |
2287
9f3414878c02
Fix Debian #865606 (orthanc FTBFS with libdcmtk-dev 3.6.1~20170228-2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2275
diff
changeset
|
1756 DcmSequenceOfItems* sequence = new DcmSequenceOfItems(key); |
1690 | 1757 element.reset(sequence); |
1758 | |
1759 for (Json::Value::ArrayIndex i = 0; i < value.size(); i++) | |
1760 { | |
1761 std::auto_ptr<DcmItem> item(new DcmItem); | |
1762 | |
1763 Json::Value::Members members = value[i].getMemberNames(); | |
1764 for (Json::Value::ArrayIndex j = 0; j < members.size(); j++) | |
1765 { | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1766 item->insert(FromJson(ParseTag(members[j]), value[i][members[j]], decodeDataUriScheme, dicomEncoding)); |
1690 | 1767 } |
1768 | |
1769 sequence->append(item.release()); | |
1770 } | |
1771 | |
1772 break; | |
1773 } | |
1774 | |
1775 default: | |
1776 throw OrthancException(ErrorCode_BadParameterType); | |
1689 | 1777 } |
1778 | |
1779 return element.release(); | |
1780 } | |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1781 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1782 |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1783 DcmPixelSequence* FromDcmtkBridge::GetPixelSequence(DcmDataset& dataset) |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1784 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1785 DcmElement *element = NULL; |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
1786 if (!dataset.findAndGetElement(DCM_PixelData, element).good()) |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1787 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1788 throw OrthancException(ErrorCode_BadFileFormat); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1789 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1790 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1791 DcmPixelData& pixelData = dynamic_cast<DcmPixelData&>(*element); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1792 DcmPixelSequence* pixelSequence = NULL; |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1793 if (!pixelData.getEncapsulatedRepresentation |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1794 (dataset.getOriginalXfer(), NULL, pixelSequence).good()) |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1795 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1796 return NULL; |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1797 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1798 else |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1799 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1800 return pixelSequence; |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1801 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1802 } |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1803 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1804 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1805 Encoding FromDcmtkBridge::ExtractEncoding(const Json::Value& json, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1806 Encoding defaultEncoding) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1807 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1808 if (json.type() != Json::objectValue) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1809 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1810 throw OrthancException(ErrorCode_BadParameterType); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1811 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1812 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1813 Encoding encoding = defaultEncoding; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1814 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1815 const Json::Value::Members tags = json.getMemberNames(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1816 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1817 // Look for SpecificCharacterSet (0008,0005) in the JSON file |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1818 for (size_t i = 0; i < tags.size(); i++) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1819 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1820 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1821 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1822 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1823 const Json::Value& value = json[tags[i]]; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1824 if (value.type() != Json::stringValue || |
2216
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1825 (value.asString().length() != 0 && |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1826 !GetDicomEncoding(encoding, value.asCString()))) |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1827 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1828 LOG(ERROR) << "Unknown encoding while creating DICOM from JSON: " << value; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1829 throw OrthancException(ErrorCode_BadRequest); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1830 } |
2216
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1831 |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1832 if (value.asString().length() == 0) |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1833 { |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1834 return defaultEncoding; |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
1835 } |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1836 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1837 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1838 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1839 return encoding; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1840 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1841 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1842 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1843 static void SetString(DcmDataset& target, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1844 const DcmTag& tag, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1845 const std::string& value) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1846 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1847 if (!target.putAndInsertString(tag, value.c_str()).good()) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1848 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1849 throw OrthancException(ErrorCode_InternalError); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1850 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1851 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1852 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1853 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1854 DcmDataset* FromDcmtkBridge::FromJson(const Json::Value& json, // Encoded using UTF-8 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1855 bool generateIdentifiers, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1856 bool decodeDataUriScheme, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1857 Encoding defaultEncoding) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1858 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1859 std::auto_ptr<DcmDataset> result(new DcmDataset); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1860 Encoding encoding = ExtractEncoding(json, defaultEncoding); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1861 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1862 SetString(*result, DCM_SpecificCharacterSet, GetDicomSpecificCharacterSet(encoding)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1863 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1864 const Json::Value::Members tags = json.getMemberNames(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1865 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1866 bool hasPatientId = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1867 bool hasStudyInstanceUid = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1868 bool hasSeriesInstanceUid = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1869 bool hasSopInstanceUid = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1870 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1871 for (size_t i = 0; i < tags.size(); i++) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1872 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1873 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1874 const Json::Value& value = json[tags[i]]; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1875 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1876 if (tag == DICOM_TAG_PATIENT_ID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1877 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1878 hasPatientId = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1879 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1880 else if (tag == DICOM_TAG_STUDY_INSTANCE_UID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1881 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1882 hasStudyInstanceUid = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1883 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1884 else if (tag == DICOM_TAG_SERIES_INSTANCE_UID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1885 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1886 hasSeriesInstanceUid = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1887 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1888 else if (tag == DICOM_TAG_SOP_INSTANCE_UID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1889 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1890 hasSopInstanceUid = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1891 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1892 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1893 if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1894 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1895 std::auto_ptr<DcmElement> element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1896 const DcmTagKey& tag = element->getTag(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1897 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1898 result->findAndDeleteElement(tag); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1899 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1900 DcmElement* tmp = element.release(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1901 if (!result->insert(tmp, false, false).good()) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1902 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1903 delete tmp; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1904 throw OrthancException(ErrorCode_InternalError); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1905 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1906 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1907 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1908 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1909 if (!hasPatientId && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1910 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1911 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1912 SetString(*result, DCM_PatientID, GenerateUniqueIdentifier(ResourceType_Patient)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1913 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1914 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1915 if (!hasStudyInstanceUid && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1916 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1917 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1918 SetString(*result, DCM_StudyInstanceUID, GenerateUniqueIdentifier(ResourceType_Study)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1919 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1920 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1921 if (!hasSeriesInstanceUid && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1922 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1923 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1924 SetString(*result, DCM_SeriesInstanceUID, GenerateUniqueIdentifier(ResourceType_Series)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1925 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1926 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1927 if (!hasSopInstanceUid && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1928 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1929 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1930 SetString(*result, DCM_SOPInstanceUID, GenerateUniqueIdentifier(ResourceType_Instance)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1931 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1932 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1933 return result.release(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
1934 } |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1935 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1936 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1937 DcmFileFormat* FromDcmtkBridge::LoadFromMemoryBuffer(const void* buffer, |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1938 size_t size) |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1939 { |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1940 DcmInputBufferStream is; |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1941 if (size > 0) |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1942 { |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1943 is.setBuffer(buffer, size); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1944 } |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1945 is.setEos(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1946 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1947 std::auto_ptr<DcmFileFormat> result(new DcmFileFormat); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1948 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1949 result->transferInit(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1950 if (!result->read(is).good()) |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1951 { |
2431
14537babc1e6
print error if unable to parse DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1952 LOG(ERROR) << "Cannot parse an invalid DICOM file (size: " << size << " bytes)"; |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1953 throw OrthancException(ErrorCode_BadFileFormat); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1954 } |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1955 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1956 result->loadAllDataIntoMemory(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1957 result->transferEnd(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1958 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1959 return result.release(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1960 } |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1961 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1962 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1963 void FromDcmtkBridge::FromJson(DicomMap& target, |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1964 const Json::Value& source) |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1965 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1966 if (source.type() != Json::objectValue) |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1967 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1968 throw OrthancException(ErrorCode_BadFileFormat); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1969 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1970 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1971 target.Clear(); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1972 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1973 Json::Value::Members members = source.getMemberNames(); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1974 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1975 for (size_t i = 0; i < members.size(); i++) |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1976 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1977 const Json::Value& value = source[members[i]]; |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1978 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1979 if (value.type() != Json::stringValue) |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1980 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1981 throw OrthancException(ErrorCode_BadFileFormat); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1982 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1983 |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1984 target.SetValue(ParseTag(members[i]), value.asString(), false); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1985 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1986 } |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1987 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1988 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1989 void FromDcmtkBridge::ChangeStringEncoding(DcmItem& dataset, |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1990 Encoding source, |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1991 Encoding target) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1992 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1993 // Recursive exploration of a dataset to change the encoding of |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1994 // each string-like element |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1995 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1996 if (source == target) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1997 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1998 return; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
1999 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2000 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2001 for (unsigned long i = 0; i < dataset.card(); i++) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2002 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2003 DcmElement* element = dataset.getElement(i); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2004 if (element) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2005 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2006 if (element->isLeaf()) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2007 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2008 char *c = NULL; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2009 if (element->isaString() && |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2010 element->getString(c).good() && |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2011 c != NULL) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2012 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2013 std::string a = Toolbox::ConvertToUtf8(c, source); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2014 std::string b = Toolbox::ConvertFromUtf8(a, target); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2015 element->putString(b.c_str()); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2016 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2017 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2018 else |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2019 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2020 // "All subclasses of DcmElement except for DcmSequenceOfItems |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2021 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2022 // etc. are not." The following dynamic_cast is thus OK. |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2023 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(*element); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2024 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2025 for (unsigned long j = 0; j < sequence.card(); j++) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2026 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2027 ChangeStringEncoding(*sequence.getItem(j), source, target); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2028 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2029 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2030 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2031 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2032 } |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2033 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2034 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2035 bool FromDcmtkBridge::LookupTransferSyntax(std::string& result, |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2036 DcmFileFormat& dicom) |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2037 { |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2038 const char* value = NULL; |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2039 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2040 if (dicom.getMetaInfo() != NULL && |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2041 dicom.getMetaInfo()->findAndGetString(DCM_TransferSyntaxUID, value).good() && |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2042 value != NULL) |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2043 { |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2044 result.assign(value); |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2045 return true; |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2046 } |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2047 else |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2048 { |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2049 return false; |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2050 } |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2051 } |
2218
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2052 |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2053 |
2232
3dd44baebc36
macro ORTHANC_ENABLE_LUA for orthanc-wsi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2218
diff
changeset
|
2054 #if ORTHANC_ENABLE_LUA == 1 |
2218
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2055 void FromDcmtkBridge::ExecuteToDicom(DicomMap& target, |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2056 LuaFunctionCall& call) |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2057 { |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2058 Json::Value output; |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2059 call.ExecuteToJson(output, true /* keep strings */); |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2060 |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2061 target.Clear(); |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2062 |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2063 if (output.type() == Json::arrayValue && |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2064 output.size() == 0) |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2065 { |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2066 // This case happens for empty tables |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2067 return; |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2068 } |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2069 |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2070 if (output.type() != Json::objectValue) |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2071 { |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2072 LOG(ERROR) << "Lua: IncomingFindRequestFilter must return a table"; |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2073 throw OrthancException(ErrorCode_LuaBadOutput); |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2074 } |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2075 |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2076 Json::Value::Members members = output.getMemberNames(); |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2077 |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2078 for (size_t i = 0; i < members.size(); i++) |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2079 { |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2080 if (output[members[i]].type() != Json::stringValue) |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2081 { |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2082 LOG(ERROR) << "Lua: IncomingFindRequestFilter must return a table mapping names of DICOM tags to strings"; |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2083 throw OrthancException(ErrorCode_LuaBadOutput); |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2084 } |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2085 |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2086 DicomTag tag(ParseTag(members[i])); |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2087 target.SetValue(tag, output[members[i]].asString(), false); |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2088 } |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2216
diff
changeset
|
2089 } |
2232
3dd44baebc36
macro ORTHANC_ENABLE_LUA for orthanc-wsi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2218
diff
changeset
|
2090 #endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2091 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2092 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2093 void FromDcmtkBridge::ExtractDicomSummary(DicomMap& target, |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2094 DcmItem& dataset) |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2095 { |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2096 ExtractDicomSummary(target, dataset, |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2097 ORTHANC_MAXIMUM_TAG_LENGTH, |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2098 GetDefaultDicomEncoding()); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2099 } |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2100 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2101 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2102 void FromDcmtkBridge::ExtractDicomAsJson(Json::Value& target, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
2103 DcmDataset& dataset, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
2104 const std::set<DicomTag>& ignoreTagLength) |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2105 { |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2106 ExtractDicomAsJson(target, dataset, |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2107 DicomToJsonFormat_Full, |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2108 DicomToJsonFlags_Default, |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2109 ORTHANC_MAXIMUM_TAG_LENGTH, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
2110 GetDefaultDicomEncoding(), |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
2111 ignoreTagLength); |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2112 } |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2113 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2114 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2115 void FromDcmtkBridge::InitializeCodecs() |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2116 { |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2117 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
2528
832217e4e872
old warnings turned into info
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2522
diff
changeset
|
2118 LOG(INFO) << "Registering JPEG Lossless codecs in DCMTK"; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2119 DJLSDecoderRegistration::registerCodecs(); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2120 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2121 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2122 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
2528
832217e4e872
old warnings turned into info
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2522
diff
changeset
|
2123 LOG(INFO) << "Registering JPEG codecs in DCMTK"; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2124 DJDecoderRegistration::registerCodecs(); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2125 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2126 } |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2127 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2128 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2129 void FromDcmtkBridge::FinalizeCodecs() |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2130 { |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2131 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2132 // Unregister JPEG-LS codecs |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2133 DJLSDecoderRegistration::cleanup(); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2134 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2135 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2136 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2137 // Unregister JPEG codecs |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2138 DJDecoderRegistration::cleanup(); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2139 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2140 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2141 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2142 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2143 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2144 // Forward declaration |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2145 static void ApplyVisitorToElement(DcmElement& element, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2146 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2147 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2148 const std::vector<size_t>& parentIndexes, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2149 Encoding encoding); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2150 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2151 static void ApplyVisitorToDataset(DcmItem& dataset, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2152 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2153 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2154 const std::vector<size_t>& parentIndexes, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2155 Encoding encoding) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2156 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2157 assert(parentTags.size() == parentIndexes.size()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2158 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2159 for (unsigned long i = 0; i < dataset.card(); i++) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2160 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2161 DcmElement* element = dataset.getElement(i); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2162 if (element == NULL) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2163 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2164 throw OrthancException(ErrorCode_InternalError); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2165 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2166 else |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2167 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2168 ApplyVisitorToElement(*element, visitor, parentTags, parentIndexes, encoding); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2169 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2170 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2171 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2172 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2173 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2174 static void ApplyVisitorToLeaf(DcmElement& element, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2175 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2176 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2177 const std::vector<size_t>& parentIndexes, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2178 const DicomTag& tag, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2179 Encoding encoding) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2180 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2181 // TODO - Merge this function with ConvertLeafElement() |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2182 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2183 assert(element.isLeaf()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2184 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2185 DcmEVR evr = element.getTag().getEVR(); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2186 ValueRepresentation vr = FromDcmtkBridge::Convert(evr); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2187 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2188 char *c = NULL; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2189 if (element.isaString() && |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2190 element.getString(c).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2191 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2192 std::string utf8; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2193 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2194 if (c != NULL) // This case corresponds to the empty string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2195 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2196 std::string s(c); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2197 utf8 = Toolbox::ConvertToUtf8(s, encoding); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2198 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2199 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2200 std::string newValue; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2201 ITagVisitor::Action action = visitor.VisitString |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2202 (newValue, parentTags, parentIndexes, tag, vr, utf8); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2203 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2204 switch (action) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2205 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2206 case ITagVisitor::Action_None: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2207 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2208 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2209 case ITagVisitor::Action_Replace: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2210 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2211 std::string s = Toolbox::ConvertFromUtf8(newValue, encoding); |
2522
ce2dfba9417c
fix build with dcmtk 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2513
diff
changeset
|
2212 if (element.putString(s.c_str()) != EC_Normal) |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2213 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2214 LOG(ERROR) << "Cannot replace value of tag: " << tag.Format(); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2215 throw OrthancException(ErrorCode_InternalError); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2216 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2217 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2218 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2219 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2220 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2221 default: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2222 throw OrthancException(ErrorCode_InternalError); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2223 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2224 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2225 return; // We're done |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2226 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2227 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2228 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2229 try |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2230 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2231 // http://support.dcmtk.org/docs/dcvr_8h-source.html |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2232 switch (element.getVR()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2233 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2234 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2235 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2236 * Deal with binary data (including PixelData). |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2237 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2238 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2239 case EVR_OB: // other byte |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2240 case EVR_OF: // other float |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2241 case EVR_OW: // other word |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2242 case EVR_UN: // unknown value representation |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2243 case EVR_ox: // OB or OW depending on context |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2244 case EVR_DS: // decimal string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2245 case EVR_IS: // integer string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2246 case EVR_AS: // age string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2247 case EVR_DA: // date string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2248 case EVR_DT: // date time string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2249 case EVR_TM: // time string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2250 case EVR_AE: // application entity title |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2251 case EVR_CS: // code string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2252 case EVR_SH: // short string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2253 case EVR_LO: // long string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2254 case EVR_ST: // short text |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2255 case EVR_LT: // long text |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2256 case EVR_UT: // unlimited text |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2257 case EVR_PN: // person name |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2258 case EVR_UI: // unique identifier |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2259 case EVR_UNKNOWN: // used internally for elements with unknown VR (encoded with 4-byte length field in explicit VR) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2260 case EVR_UNKNOWN2B: // used internally for elements with unknown VR with 2-byte length field in explicit VR |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2261 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2262 Uint8* data = NULL; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2263 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2264 if (element.getUint8Array(data) == EC_Normal) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2265 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2266 visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data, element.getLength()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2267 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2268 else |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2269 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2270 visitor.VisitUnknown(parentTags, parentIndexes, tag, vr); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2271 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2272 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2273 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2274 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2275 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2276 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2277 * Numeric types |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2278 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2279 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2280 case EVR_SL: // signed long |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2281 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2282 Sint32 f; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2283 if (dynamic_cast<DcmSignedLong&>(element).getSint32(f).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2284 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2285 visitor.VisitInteger(parentTags, parentIndexes, tag, vr, f); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2286 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2287 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2288 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2289 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2290 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2291 case EVR_SS: // signed short |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2292 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2293 Sint16 f; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2294 if (dynamic_cast<DcmSignedShort&>(element).getSint16(f).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2295 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2296 visitor.VisitInteger(parentTags, parentIndexes, tag, vr, f); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2297 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2298 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2299 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2300 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2301 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2302 case EVR_UL: // unsigned long |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2303 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2304 Uint32 f; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2305 if (dynamic_cast<DcmUnsignedLong&>(element).getUint32(f).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2306 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2307 visitor.VisitInteger(parentTags, parentIndexes, tag, vr, f); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2308 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2309 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2310 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2311 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2312 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2313 case EVR_US: // unsigned short |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2314 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2315 Uint16 f; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2316 if (dynamic_cast<DcmUnsignedShort&>(element).getUint16(f).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2317 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2318 visitor.VisitInteger(parentTags, parentIndexes, tag, vr, f); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2319 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2320 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2321 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2322 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2323 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2324 case EVR_FL: // float single-precision |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2325 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2326 Float32 f; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2327 if (dynamic_cast<DcmFloatingPointSingle&>(element).getFloat32(f).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2328 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2329 visitor.VisitDouble(parentTags, parentIndexes, tag, vr, f); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2330 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2331 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2332 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2333 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2334 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2335 case EVR_FD: // float double-precision |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2336 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2337 Float64 f; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2338 if (dynamic_cast<DcmFloatingPointDouble&>(element).getFloat64(f).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2339 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2340 visitor.VisitDouble(parentTags, parentIndexes, tag, vr, f); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2341 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2342 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2343 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2344 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2345 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2346 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2347 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2348 * Attribute tag. |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2349 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2350 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2351 case EVR_AT: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2352 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2353 DcmTagKey tagKey; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2354 if (dynamic_cast<DcmAttributeTag&>(element).getTagVal(tagKey, 0).good()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2355 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2356 DicomTag t(tagKey.getGroup(), tagKey.getElement()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2357 visitor.VisitAttribute(parentTags, parentIndexes, tag, vr, t); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2358 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2359 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2360 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2361 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2362 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2363 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2364 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2365 * Sequence types, should never occur at this point because of |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2366 * "element.isLeaf()". |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2367 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2368 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2369 case EVR_SQ: // sequence of items |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2370 return; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2371 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2372 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2373 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2374 * Internal to DCMTK. |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2375 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2376 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2377 case EVR_xs: // SS or US depending on context |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2378 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2379 case EVR_na: // na="not applicable", for data which has no VR |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2380 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2381 case EVR_item: // used internally for items |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2382 case EVR_metainfo: // used internally for meta info datasets |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2383 case EVR_dataset: // used internally for datasets |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2384 case EVR_fileFormat: // used internally for DICOM files |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2385 case EVR_dicomDir: // used internally for DICOMDIR objects |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2386 case EVR_dirRecord: // used internally for DICOMDIR records |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2387 case EVR_pixelSQ: // used internally for pixel sequences in a compressed image |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2388 case EVR_pixelItem: // used internally for pixel items in a compressed image |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2389 case EVR_PixelData: // used internally for uncompressed pixeld data |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2390 case EVR_OverlayData: // used internally for overlay data |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2391 visitor.VisitUnknown(parentTags, parentIndexes, tag, vr); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2392 return; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2393 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2394 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2395 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2396 * Default case. |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2397 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2398 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2399 default: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2400 return; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2401 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2402 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2403 catch (boost::bad_lexical_cast&) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2404 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2405 return; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2406 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2407 catch (std::bad_cast&) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2408 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2409 return; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2410 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2411 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2412 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2413 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2414 static void ApplyVisitorToElement(DcmElement& element, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2415 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2416 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2417 const std::vector<size_t>& parentIndexes, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2418 Encoding encoding) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2419 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2420 assert(parentTags.size() == parentIndexes.size()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2421 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2422 DicomTag tag(FromDcmtkBridge::Convert(element.getTag())); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2423 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2424 if (element.isLeaf()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2425 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2426 ApplyVisitorToLeaf(element, visitor, parentTags, parentIndexes, tag, encoding); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2427 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2428 else |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2429 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2430 // "All subclasses of DcmElement except for DcmSequenceOfItems |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2431 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2432 // etc. are not." The following dynamic_cast is thus OK. |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2433 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2434 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2435 std::vector<DicomTag> tags = parentTags; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2436 std::vector<size_t> indexes = parentIndexes; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2437 tags.push_back(tag); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2438 indexes.push_back(0); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2439 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2440 for (unsigned long i = 0; i < sequence.card(); i++) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2441 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2442 indexes.back() = static_cast<size_t>(i); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2443 DcmItem* child = sequence.getItem(i); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2444 ApplyVisitorToDataset(*child, visitor, tags, indexes, encoding); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2445 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2446 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2447 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2448 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2449 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2450 void FromDcmtkBridge::Apply(DcmItem& dataset, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2451 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2452 Encoding defaultEncoding) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2453 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2454 std::vector<DicomTag> parentTags; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2455 std::vector<size_t> parentIndexes; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2456 Encoding encoding = DetectEncoding(dataset, defaultEncoding); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2457 ApplyVisitorToDataset(dataset, visitor, parentTags, parentIndexes, encoding); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2458 } |
0 | 2459 } |