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