Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 5073:859f3668c181
replaced macro "#warning" by "#pragma message" for Visual Studio
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 16 Aug 2022 11:06:25 +0200 |
parents | ea9e2680da6f |
children | 9fd4e12efabc |
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 |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4845
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4845
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
11 * the License, or (at your option) any later version. |
136 | 12 * |
0 | 13 * This program is distributed in the hope that it will be useful, but |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
16 * Lesser General Public License for more details. |
0 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
0 | 21 **/ |
22 | |
448
9d830dcc7730
missing copyright information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
419
diff
changeset
|
23 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
24 #include "../PrecompiledHeaders.h" |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
25 |
71 | 26 #ifndef NOMINMAX |
27 #define NOMINMAX | |
28 #endif | |
0 | 29 |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
30 #if !defined(ORTHANC_SANDBOXED) |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
31 # 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
|
32 #endif |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
33 |
3117 | 34 #if !defined(DCMTK_VERSION_NUMBER) |
35 # error The macro DCMTK_VERSION_NUMBER must be defined | |
36 #endif | |
37 | |
0 | 38 #include "FromDcmtkBridge.h" |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
39 #include "ToDcmtkBridge.h" |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
40 #include "../Compatibility.h" |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
41 #include "../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
42 #include "../Toolbox.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
43 #include "../OrthancException.h" |
0 | 44 |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
45 #if ORTHANC_SANDBOXED == 0 |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
46 # include "../TemporaryFile.h" |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
47 #endif |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
48 |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
49 #include <list> |
71 | 50 #include <limits> |
51 | |
0 | 52 #include <boost/lexical_cast.hpp> |
1656 | 53 #include <boost/filesystem.hpp> |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
54 #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
|
55 #include <boost/algorithm/string/join.hpp> |
0 | 56 |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
57 #include <dcmtk/dcmdata/dcdeftag.h> |
0 | 58 #include <dcmtk/dcmdata/dcdicent.h> |
59 #include <dcmtk/dcmdata/dcdict.h> | |
60 #include <dcmtk/dcmdata/dcfilefo.h> | |
3769
eb044cc49d51
compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
61 #include <dcmtk/dcmdata/dcistrmb.h> |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
62 #include <dcmtk/dcmdata/dcostrmb.h> |
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
63 #include <dcmtk/dcmdata/dcpixel.h> |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
64 #include <dcmtk/dcmdata/dcuid.h> |
3769
eb044cc49d51
compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
65 #include <dcmtk/dcmdata/dcxfer.h> |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
66 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
67 #include <dcmtk/dcmdata/dcvrae.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
68 #include <dcmtk/dcmdata/dcvras.h> |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
69 #include <dcmtk/dcmdata/dcvrat.h> |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
70 #include <dcmtk/dcmdata/dcvrcs.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
71 #include <dcmtk/dcmdata/dcvrda.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
72 #include <dcmtk/dcmdata/dcvrds.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
73 #include <dcmtk/dcmdata/dcvrdt.h> |
0 | 74 #include <dcmtk/dcmdata/dcvrfd.h> |
75 #include <dcmtk/dcmdata/dcvrfl.h> | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
76 #include <dcmtk/dcmdata/dcvris.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
77 #include <dcmtk/dcmdata/dcvrlo.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
78 #include <dcmtk/dcmdata/dcvrlt.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
79 #include <dcmtk/dcmdata/dcvrpn.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
80 #include <dcmtk/dcmdata/dcvrsh.h> |
0 | 81 #include <dcmtk/dcmdata/dcvrsl.h> |
82 #include <dcmtk/dcmdata/dcvrss.h> | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
83 #include <dcmtk/dcmdata/dcvrst.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
84 #include <dcmtk/dcmdata/dcvrtm.h> |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
85 #include <dcmtk/dcmdata/dcvrui.h> |
0 | 86 #include <dcmtk/dcmdata/dcvrul.h> |
87 #include <dcmtk/dcmdata/dcvrus.h> | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
88 #include <dcmtk/dcmdata/dcvrut.h> |
0 | 89 |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3199
diff
changeset
|
90 #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
|
91 # 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
|
92 # 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
|
93 #endif |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3199
diff
changeset
|
94 |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
95 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 |
4032
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
96 # include <OrthancFrameworkResources.h> |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
97 #endif |
682
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
677
diff
changeset
|
98 |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
99 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
100 # include <dcmtk/dcmjpeg/djdecode.h> |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
101 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
102 # include <dcmtk/dcmjpeg/djencode.h> |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
103 # endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
104 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
105 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
106 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
107 # include <dcmtk/dcmjpls/djdecode.h> |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
108 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
109 # include <dcmtk/dcmjpls/djencode.h> |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
110 # endif |
1930 | 111 #endif |
112 | |
113 | |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
114 #include <dcmtk/dcmdata/dcrledrg.h> |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
115 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
116 # include <dcmtk/dcmdata/dcrleerg.h> |
3765
4a25727401cd
first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3748
diff
changeset
|
117 # include <dcmtk/dcmimage/diregist.h> // include to support color images |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
118 #endif |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
119 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
120 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
121 static bool hasExternalDictionaries_ = false; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
122 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
123 |
62 | 124 namespace Orthanc |
0 | 125 { |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
126 static bool IsBinaryTag(const DcmTag& key) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
127 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
128 return (key.isUnknownVR() || |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
129 key.getEVR() == EVR_OB || |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
130 key.getEVR() == EVR_OW || |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
131 key.getEVR() == EVR_UN || |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
132 key.getEVR() == EVR_ox); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
133 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
134 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
135 |
1656 | 136 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 |
137 static void LoadEmbeddedDictionary(DcmDataDictionary& dictionary, | |
4032
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
138 FrameworkResources::FileResourceId resource) |
1656 | 139 { |
2017 | 140 std::string content; |
4032
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
141 FrameworkResources::GetFileResource(content, resource); |
1656 | 142 |
2513
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
143 #if ORTHANC_SANDBOXED == 0 |
2143
fd5875662670
creation of namespace SystemToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
144 TemporaryFile tmp; |
2017 | 145 tmp.Write(content); |
1656 | 146 |
147 if (!dictionary.loadDictionary(tmp.GetPath().c_str())) | |
148 { | |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
149 throw OrthancException(ErrorCode_InternalError, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
150 "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
|
151 "your TEMP directory does not contain special characters."); |
1656 | 152 } |
2513
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
153 #else |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
154 if (!dictionary.loadFromMemory(content)) |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
155 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
156 throw OrthancException(ErrorCode_InternalError, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
157 "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
|
158 "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
|
159 } |
97a74f0eac7a
loading DICOM dictionaries in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
160 #endif |
1656 | 161 } |
162 #endif | |
163 | |
164 | |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
165 namespace |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
166 { |
4030
100fbe970762
DANGEROUS commit: removing HAS_EMBEDDED_RESOURCES
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4016
diff
changeset
|
167 class DictionaryLocker : public boost::noncopyable |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
168 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
169 private: |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
170 DcmDataDictionary& 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 public: |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
173 DictionaryLocker() : dictionary_(dcmDataDict.wrlock()) |
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 } |
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 ~DictionaryLocker() |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
178 { |
3117 | 179 #if DCMTK_VERSION_NUMBER >= 364 |
180 dcmDataDict.wrunlock(); | |
181 #else | |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
182 dcmDataDict.unlock(); |
3117 | 183 #endif |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
184 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
185 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
186 DcmDataDictionary& operator*() |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
187 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
188 return dictionary_; |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
189 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
190 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
191 DcmDataDictionary* operator->() |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
192 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
193 return &dictionary_; |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
194 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
195 }; |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
196 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
197 |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
198 ORTHANC_FORCE_INLINE |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
199 static std::string FloatToString(float v) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
200 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
201 /** |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
202 * From "boost::lexical_cast" documentation: "For more involved |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
203 * conversions, such as where precision or formatting need tighter |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
204 * control than is offered by the default behavior of |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
205 * lexical_cast, the conventional stringstream approach is |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
206 * recommended." |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
207 * https://www.boost.org/doc/libs/1_65_0/doc/html/boost_lexical_cast.html |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
208 * http://www.gotw.ca/publications/mill19.htm |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
209 * |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
210 * The precision of 17 corresponds to "defaultRealPrecision" in JsonCpp: |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
211 * https://github.com/open-source-parsers/jsoncpp/blob/master/include/json/value.h |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
212 **/ |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
213 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
214 //return boost::lexical_cast<std::string>(v); // This was used in Orthanc <= 1.9.0 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
215 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
216 std::ostringstream ss; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
217 ss << std::setprecision(17) << v; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
218 return ss.str(); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
219 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
220 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
221 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
222 ORTHANC_FORCE_INLINE |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
223 static std::string DoubleToString(double v) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
224 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
225 //return boost::lexical_cast<std::string>(v); // This was used in Orthanc <= 1.9.0 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
226 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
227 std::ostringstream ss; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
228 ss << std::setprecision(17) << v; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
229 return ss.str(); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
230 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
231 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
232 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
233 #define DCMTK_TO_CTYPE_CONVERTER(converter, cType, dcmtkType, getter, toStringFunction) \ |
3594
0654d0838de8
disable thread support in DCMTK if wasm/asm.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3577
diff
changeset
|
234 \ |
0654d0838de8
disable thread support in DCMTK if wasm/asm.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3577
diff
changeset
|
235 struct converter \ |
0654d0838de8
disable thread support in DCMTK if wasm/asm.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3577
diff
changeset
|
236 { \ |
0654d0838de8
disable thread support in DCMTK if wasm/asm.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3577
diff
changeset
|
237 typedef cType CType; \ |
0654d0838de8
disable thread support in DCMTK if wasm/asm.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3577
diff
changeset
|
238 \ |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
239 ORTHANC_FORCE_INLINE \ |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
240 static bool Apply(CType& result, \ |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
241 DcmElement& element, \ |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
242 size_t i) \ |
3594
0654d0838de8
disable thread support in DCMTK if wasm/asm.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3577
diff
changeset
|
243 { \ |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
244 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
|
245 } \ |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
246 \ |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
247 ORTHANC_FORCE_INLINE \ |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
248 static std::string ToString(CType value) \ |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
249 { \ |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
250 return toStringFunction(value); \ |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
251 } \ |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
252 }; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
253 |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
254 DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint32Converter, Sint32, DcmSignedLong, getSint32, boost::lexical_cast<std::string>) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
255 DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint16Converter, Sint16, DcmSignedShort, getSint16, boost::lexical_cast<std::string>) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
256 DCMTK_TO_CTYPE_CONVERTER(DcmtkToUint32Converter, Uint32, DcmUnsignedLong, getUint32, boost::lexical_cast<std::string>) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
257 DCMTK_TO_CTYPE_CONVERTER(DcmtkToUint16Converter, Uint16, DcmUnsignedShort, getUint16, boost::lexical_cast<std::string>) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
258 DCMTK_TO_CTYPE_CONVERTER(DcmtkToFloat32Converter, Float32, DcmFloatingPointSingle, getFloat32, FloatToString) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
259 DCMTK_TO_CTYPE_CONVERTER(DcmtkToFloat64Converter, Float64, DcmFloatingPointDouble, getFloat64, DoubleToString) |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
260 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
261 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
262 template <typename F> |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
263 static DicomValue* ApplyDcmtkToCTypeConverter(DcmElement& element) |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
264 { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
265 F f; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
266 typename F::CType value; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
267 |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
268 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
|
269 && (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
|
270 { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
271 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
|
272 std::vector<std::string> strings; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
273 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
|
274 if (f.Apply(value, element, i)) { |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
275 strings.push_back(F::ToString(value)); |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
276 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
277 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
278 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
|
279 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
280 else if (f.Apply(value, element, 0)) { |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
281 return new DicomValue(F::ToString(value), false); |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
282 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
283 else { |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
284 return new DicomValue; |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
285 } |
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
286 } |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
287 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
288 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
289 |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
290 void FromDcmtkBridge::InitializeDictionary(bool loadPrivateDictionary) |
1656 | 291 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
292 CLOG(INFO, DICOM) << "Using DCTMK version: " << DCMTK_VERSION_NUMBER; |
2296 | 293 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
294 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
295 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
296 DictionaryLocker locker; |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
297 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
298 locker->clear(); |
1656 | 299 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
300 CLOG(INFO, DICOM) << "Loading the embedded dictionaries"; |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
301 /** |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
302 * 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
|
303 * 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
|
304 * dictionary is not loaded by storescu. |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
305 **/ |
4032
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
306 //LoadEmbeddedDictionary(*locker, FrameworkResources::DICTIONARY_DICONDE); |
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
307 |
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
308 LoadEmbeddedDictionary(*locker, FrameworkResources::DICTIONARY_DICOM); |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
309 |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
310 if (loadPrivateDictionary) |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
311 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
312 CLOG(INFO, DICOM) << "Loading the embedded dictionary of private tags"; |
4032
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
313 LoadEmbeddedDictionary(*locker, FrameworkResources::DICTIONARY_PRIVATE); |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
314 } |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
315 else |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
316 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
317 CLOG(INFO, DICOM) << "The dictionary of private tags has not been loaded"; |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
318 } |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
319 } |
3302
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
320 #else |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
321 { |
3302
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
322 std::vector<std::string> dictionaries; |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
323 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
324 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
|
325 if (env != NULL) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
326 { |
3302
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
327 // This mimics the behavior of DCMTK: |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
328 // 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
|
329 #if defined(_WIN32) |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
330 Toolbox::TokenizeString(dictionaries, std::string(env), ';'); |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
331 #else |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
332 Toolbox::TokenizeString(dictionaries, std::string(env), ':'); |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
333 #endif |
2151
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
334 } |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
335 else |
8cbb55089a1d
New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
336 { |
3302
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
337 boost::filesystem::path base = DCMTK_DICTIONARY_DIR; |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
338 dictionaries.push_back((base / "dicom.dic").string()); |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
339 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
340 if (loadPrivateDictionary) |
3302
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
341 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
342 dictionaries.push_back((base / "private.dic").string()); |
3302
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
343 } |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
344 } |
8ed445e94486
Fix issue #126 (Orthanc and DCMDICTPATH)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
345 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
346 LoadExternalDictionaries(dictionaries); |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
347 hasExternalDictionaries_ = false; // Fix the side-effect of "LoadExternalDictionaries()" |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
348 } |
1656 | 349 #endif |
350 | |
351 /* make sure data dictionary is loaded */ | |
352 if (!dcmDataDict.isDictionaryLoaded()) | |
353 { | |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
354 throw OrthancException(ErrorCode_InternalError, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
355 "No DICOM dictionary loaded, check environment variable: " + |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
356 std::string(DCM_DICT_ENVIRONMENT_VARIABLE)); |
1656 | 357 } |
358 | |
359 { | |
360 // Test the dictionary with a simple DICOM tag | |
361 DcmTag key(0x0010, 0x1030); // This is PatientWeight | |
362 if (key.getEVR() != EVR_DS) | |
363 { | |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
364 throw OrthancException(ErrorCode_InternalError, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
365 "The DICOM dictionary has not been correctly read"); |
1656 | 366 } |
367 } | |
368 } | |
369 | |
370 | |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
371 void FromDcmtkBridge::LoadExternalDictionaries(const std::vector<std::string>& dictionaries) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
372 { |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
373 DictionaryLocker locker; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
374 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
375 CLOG(INFO, DICOM) << "Clearing the DICOM dictionary"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
376 locker->clear(); |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
377 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
378 for (size_t i = 0; i < dictionaries.size(); i++) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
379 { |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
380 LOG(WARNING) << "Loading external DICOM dictionary: \"" << dictionaries[i] << "\""; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
381 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
382 if (!locker->loadDictionary(dictionaries[i].c_str())) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
383 { |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
384 throw OrthancException(ErrorCode_InexistentFile); |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
385 } |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
386 } |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
387 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
388 hasExternalDictionaries_ = true; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
389 } |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
390 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
391 |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
392 void FromDcmtkBridge::RegisterDictionaryTag(const DicomTag& tag, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
393 ValueRepresentation vr, |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
394 const std::string& name, |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
395 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
|
396 unsigned int maxMultiplicity, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
397 const std::string& privateCreator) |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
398 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
399 if (minMultiplicity < 1) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
400 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
401 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
402 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
403 |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
404 bool arbitrary = false; |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
405 if (maxMultiplicity == 0) |
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 maxMultiplicity = DcmVariableVM; |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
408 arbitrary = true; |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
409 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
410 else if (maxMultiplicity < minMultiplicity) |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
411 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
412 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
413 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
414 |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
415 DcmEVR evr = ToDcmtkBridge::Convert(vr); |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
416 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
417 CLOG(INFO, DICOM) << "Registering tag in dictionary: (" << tag.Format() << ") " |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
418 << (DcmVR(evr).getValidVRName()) << " " |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
419 << name << " (multiplicity: " << minMultiplicity << "-" |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
420 << (arbitrary ? "n" : boost::lexical_cast<std::string>(maxMultiplicity)) << ")"; |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
421 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
422 std::unique_ptr<DcmDictEntry> entry; |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
423 if (privateCreator.empty()) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
424 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
425 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
|
426 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
427 char buf[128]; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
428 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
|
429 "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
|
430 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
|
431 LOG(WARNING) << buf; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
432 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
433 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
434 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
|
435 tag.GetElement(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
436 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
|
437 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
|
438 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
|
439 NULL /* version */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
440 OFTrue /* doCopyString */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
441 NULL /* private creator */)); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
442 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
443 else |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
444 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
445 // "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
|
446 // (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
|
447 // (FFFF,eeee)." |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
448 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
|
449 tag.GetGroup() == 0x0001 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
450 tag.GetGroup() == 0x0003 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
451 tag.GetGroup() == 0x0005 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
452 tag.GetGroup() == 0x0007 || |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
453 tag.GetGroup() == 0xffff) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
454 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
455 char buf[128]; |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
456 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
|
457 tag.GetGroup(), tag.GetElement()); |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
458 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
|
459 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
460 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
461 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
|
462 tag.GetElement(), |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
463 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
|
464 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
|
465 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
|
466 "private" /* version */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
467 OFTrue /* doCopyString */, |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
468 privateCreator.c_str())); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
469 } |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
470 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
471 entry->setGroupRangeRestriction(DcmDictRange_Unspecified); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
472 entry->setElementRangeRestriction(DcmDictRange_Unspecified); |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
473 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
474 { |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
475 DictionaryLocker locker; |
2116
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
476 |
4695
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
477 if (locker->findEntry(DcmTagKey(tag.GetGroup(), tag.GetElement()), |
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
478 privateCreator.empty() ? NULL : privateCreator.c_str())) |
2116
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
479 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
480 throw OrthancException(ErrorCode_AlreadyExistingTag, |
4695
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
481 "Cannot register twice the tag (" + tag.Format() + |
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
482 "), whose symbolic name is \"" + name + "\""); |
2116
2fabd1073728
prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2115
diff
changeset
|
483 } |
4695
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
484 else |
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
485 { |
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
486 locker->addEntry(entry.release()); |
651f069c7f77
fix error if overriding existing tag in the DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4690
diff
changeset
|
487 } |
1657
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
488 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
489 } |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
490 |
5360cdba70d8
New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
491 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
492 Encoding FromDcmtkBridge::DetectEncoding(bool& hasCodeExtensions, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
493 DcmItem& dataset, |
1928
84c7eaeb5244
Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1927
diff
changeset
|
494 Encoding defaultEncoding) |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
495 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
496 // 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
|
497 |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
498 OFString tmp; |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
499 if (dataset.findAndGetOFStringArray(DCM_SpecificCharacterSet, tmp).good()) |
957
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
500 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
501 std::vector<std::string> tokens; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
502 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
|
503 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
504 hasCodeExtensions = (tokens.size() > 1); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
505 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
506 for (size_t i = 0; i < tokens.size(); i++) |
957
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
507 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
508 std::string characterSet = Toolbox::StripSpaces(tokens[i]); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
509 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
510 if (!characterSet.empty()) |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
511 { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
512 Encoding encoding; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
513 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
514 if (GetDicomEncoding(encoding, characterSet.c_str())) |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
515 { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
516 // 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
|
517 return encoding; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
518 } |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
519 else |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
520 { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
521 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
|
522 << ", fallback to ASCII (remove all special characters)"; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
523 return Encoding_Ascii; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
524 } |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
525 } |
957
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
526 } |
63973b76a51f
detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
527 } |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
528 else |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
529 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
530 hasCodeExtensions = false; |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
531 } |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
532 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
533 // 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
|
534 return defaultEncoding; |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
535 } |
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
536 |
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
537 |
4297 | 538 Encoding FromDcmtkBridge::DetectEncoding(DcmItem &dataset, |
539 Encoding defaultEncoding) | |
540 { | |
541 bool hasCodeExtensions; // ignored | |
542 return DetectEncoding(hasCodeExtensions, dataset, defaultEncoding); | |
543 } | |
544 | |
545 | |
546 void FromDcmtkBridge::ExtractDicomSummary(DicomMap& target, | |
2125 | 547 DcmItem& dataset, |
548 unsigned int maxStringLength, | |
3577
33cfcc74d1b1
argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3448
diff
changeset
|
549 const std::set<DicomTag>& ignoreTagLength) |
0 | 550 { |
4137
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
551 const Encoding defaultEncoding = GetDefaultDicomEncoding(); |
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
552 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
553 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
554 Encoding encoding = DetectEncoding(hasCodeExtensions, dataset, defaultEncoding); |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
555 |
0 | 556 target.Clear(); |
557 for (unsigned long i = 0; i < dataset.card(); i++) | |
558 { | |
559 DcmElement* element = dataset.getElement(i); | |
560 if (element && element->isLeaf()) | |
561 { | |
3651
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
562 target.SetValueInternal(element->getTag().getGTag(), |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
563 element->getTag().getETag(), |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
564 ConvertLeafElement(*element, DicomToJsonFlags_Default, |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
565 maxStringLength, encoding, hasCodeExtensions, ignoreTagLength)); |
0 | 566 } |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
567 else |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
568 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
569 DcmSequenceOfItems* sequence = dynamic_cast<DcmSequenceOfItems*>(element); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
570 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
571 if (sequence) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
572 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
573 Json::Value jsonSequence = Json::arrayValue; |
5050 | 574 for (unsigned long s = 0; s < sequence->card(); s++) |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
575 { |
5050 | 576 DcmItem* child = sequence->getItem(s); |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
577 Json::Value& v = jsonSequence.append(Json::objectValue); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
578 DatasetToJson(v, *child, DicomToJsonFormat_Full, DicomToJsonFlags_Default, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
579 maxStringLength, encoding, hasCodeExtensions, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
580 ignoreTagLength, 1); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
581 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
582 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
583 target.SetValue(DicomTag(element->getTag().getGTag(), element->getTag().getETag()), |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
584 jsonSequence); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
585 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
586 } |
0 | 587 } |
588 } | |
589 | |
590 | |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
591 DicomTag FromDcmtkBridge::Convert(const DcmTag& tag) |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
592 { |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
593 return DicomTag(tag.getGTag(), tag.getETag()); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
594 } |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
595 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
957
diff
changeset
|
596 |
0 | 597 DicomTag FromDcmtkBridge::GetTag(const DcmElement& element) |
598 { | |
599 return DicomTag(element.getGTag(), element.getETag()); | |
600 } | |
601 | |
602 | |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
603 static DicomValue* CreateValueFromUtf8String(const DicomTag& tag, |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
604 const std::string& utf8, |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
605 unsigned int maxStringLength, |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
606 const std::set<DicomTag>& ignoreTagLength) |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
607 { |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
608 if (maxStringLength != 0 && |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
609 utf8.size() > maxStringLength && |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
610 ignoreTagLength.find(tag) == ignoreTagLength.end()) |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
611 { |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
612 return new DicomValue; // Too long, create a NULL value |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
613 } |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
614 else |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
615 { |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
616 return new DicomValue(utf8, false); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
617 } |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
618 } |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
619 |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
620 |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
621 DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element, |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
622 DicomToJsonFlags flags, |
1929
cda5b0ab4ce5
ORTHANC_MAXIMUM_TAG_LENGTH made explicit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1928
diff
changeset
|
623 unsigned int maxStringLength, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
624 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
625 bool hasCodeExtensions, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
626 const std::set<DicomTag>& ignoreTagLength) |
0 | 627 { |
628 if (!element.isLeaf()) | |
629 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
630 // This function is only applicable to leaf elements |
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
631 throw OrthancException(ErrorCode_BadParameterType); |
0 | 632 } |
633 | |
634 { | |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
635 char *c = NULL; |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
636 if (element.isaString() && |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
637 element.getString(c).good()) |
0 | 638 { |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
639 if (c == NULL) // This case corresponds to the empty string |
1854
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
640 { |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
641 return new DicomValue("", false); |
1854
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
642 } |
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
643 else |
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
644 { |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
645 const std::string s(c); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
646 const std::string utf8 = Toolbox::ConvertToUtf8(s, encoding, hasCodeExtensions); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
647 return CreateValueFromUtf8String(GetTag(element), utf8, maxStringLength, ignoreTagLength); |
1854
e2c3d752ee1a
prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1831
diff
changeset
|
648 } |
0 | 649 } |
650 } | |
651 | |
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
|
652 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
653 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
|
654 { |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
655 /** |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
656 * Unknown value representation: Lookup in the dictionary. This |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
657 * is notably the case for private tags registered with the |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
658 * "Dictionary" configuration option, or for public tags with |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
659 * "EVR_UN" in the case of Little Endian Implicit transfer |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
660 * syntax (cf. DICOM CP 246). |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
661 * ftp://medical.nema.org/medical/dicom/final/cp246_ft.pdf |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
662 **/ |
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
|
663 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
|
664 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
665 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
|
666 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
|
667 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
|
668 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
|
669 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
670 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
|
671 |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
672 if (element.getUint8Array(data) == EC_Normal) |
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
|
673 { |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
674 Uint32 length = element.getLength(); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
675 |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
676 if (data == NULL || |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
677 length == 0) |
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
|
678 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
679 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
|
680 } |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
681 |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
682 // Remove the trailing padding, if any |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
683 if (length > 0 && |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
684 length % 2 == 0 && |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
685 data[length - 1] == '\0') |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
686 { |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
687 length = length - 1; |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
688 } |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
689 |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
690 if (element.getTag().isPrivate()) |
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
|
691 { |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
692 // For private tags, we do not try and convert to UTF-8, |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
693 // as nothing ensures that the encoding of the private tag |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
694 // is the same as that of the remaining of the DICOM |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
695 // dataset. Only go for ASCII strings. |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
696 if (Toolbox::IsAsciiString(data, length)) |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
697 { |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
698 const std::string s(reinterpret_cast<const char*>(data), length); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
699 return CreateValueFromUtf8String(GetTag(element), s, maxStringLength, ignoreTagLength); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
700 } |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
701 else |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
702 { |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
703 // Not a plain ASCII string: Consider it as a binary |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
704 // value that is handled in the switch-case below |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
705 } |
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
|
706 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
707 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
|
708 { |
4527
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
709 // For public tags, convert to UTF-8 by using the |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
710 // "SpecificCharacterSet" tag, if present. This branch is |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
711 // new in Orthanc 1.9.1 (cf. DICOM CP 246). |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
712 const std::string s(reinterpret_cast<const char*>(data), length); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
713 const std::string utf8 = Toolbox::ConvertToUtf8(s, encoding, hasCodeExtensions); |
31f940334496
Handle public tags with "UN" value representation and containing a string (cf. DICOM CP 246)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4516
diff
changeset
|
714 return CreateValueFromUtf8String(GetTag(element), utf8, maxStringLength, ignoreTagLength); |
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
|
715 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
716 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
717 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
718 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
719 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
720 |
0 | 721 try |
722 { | |
723 // http://support.dcmtk.org/docs/dcvr_8h-source.html | |
724 switch (element.getVR()) | |
725 { | |
726 | |
727 /** | |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
728 * Deal with binary data (including PixelData). |
0 | 729 **/ |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
730 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
731 case EVR_OB: // other byte |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
732 case EVR_OF: // other float |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
733 case EVR_OW: // other word |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
734 case EVR_UN: // unknown value representation |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
735 case EVR_ox: // OB or OW depending on context |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
736 case EVR_DS: // decimal string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
737 case EVR_IS: // integer string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
738 case EVR_AS: // age string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
739 case EVR_DA: // date string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
740 case EVR_DT: // date time string |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
741 case EVR_TM: // time string |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
742 case EVR_AE: // application entity title |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
743 case EVR_CS: // code string |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
744 case EVR_SH: // short string |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
745 case EVR_LO: // long string |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
746 case EVR_ST: // short text |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
747 case EVR_LT: // long text |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
748 case EVR_UT: // unlimited text |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
749 case EVR_PN: // person name |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
750 case EVR_UI: // unique identifier |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
751 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
|
752 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
|
753 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
754 if (!(flags & DicomToJsonFlags_ConvertBinaryToNull)) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
755 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
756 Uint8* data = NULL; |
4845
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
757 Uint16* data16 = NULL; |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
758 if (element.getUint8Array(data) == EC_Normal) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
759 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
760 return new DicomValue(reinterpret_cast<const char*>(data), element.getLength(), true); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
761 } |
4845
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
762 else if (element.getUint16Array(data16) == EC_Normal) |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
763 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
764 return new DicomValue(reinterpret_cast<const char*>(data16), element.getLength(), true); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
765 } |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
766 } |
0 | 767 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
768 return new DicomValue; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
769 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
770 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
771 /** |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
772 * Numeric types |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
773 **/ |
0 | 774 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
775 case EVR_SL: // signed long |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
776 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
777 return ApplyDcmtkToCTypeConverter<DcmtkToSint32Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
778 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
779 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
780 case EVR_SS: // signed short |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
781 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
782 return ApplyDcmtkToCTypeConverter<DcmtkToSint16Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
783 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
784 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
785 case EVR_UL: // unsigned long |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
786 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
787 return ApplyDcmtkToCTypeConverter<DcmtkToUint32Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
788 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
789 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
790 case EVR_US: // unsigned short |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
791 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
792 return ApplyDcmtkToCTypeConverter<DcmtkToUint16Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
793 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
794 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
795 case EVR_FL: // float single-precision |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
796 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
797 return ApplyDcmtkToCTypeConverter<DcmtkToFloat32Converter>(element); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
798 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
799 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
800 case EVR_FD: // float double-precision |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
801 { |
2554
ea63d9f90377
/tags now returns multiple numerical values in a \ separated string
am@osimis.io
parents:
2528
diff
changeset
|
802 return ApplyDcmtkToCTypeConverter<DcmtkToFloat64Converter>(element); |
1131 | 803 } |
804 | |
805 | |
806 /** | |
807 * Attribute tag. | |
808 **/ | |
809 | |
810 case EVR_AT: | |
811 { | |
1147 | 812 DcmTagKey tag; |
813 if (dynamic_cast<DcmAttributeTag&>(element).getTagVal(tag, 0).good()) | |
814 { | |
815 DicomTag t(tag.getGroup(), tag.getElement()); | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
816 return new DicomValue(t.Format(), false); |
1147 | 817 } |
1131 | 818 else |
1147 | 819 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
820 return new DicomValue; |
1147 | 821 } |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
822 } |
0 | 823 |
824 | |
825 /** | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
826 * 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
|
827 * "element.isLeaf()". |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
828 **/ |
0 | 829 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
830 case EVR_SQ: // sequence of items |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
831 return new DicomValue; |
0 | 832 |
833 | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
834 /** |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
835 * Internal to DCMTK. |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
836 **/ |
0 | 837 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
838 case EVR_xs: // SS or US depending on context |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
839 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
|
840 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
|
841 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
|
842 case EVR_item: // used internally for items |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
843 case EVR_metainfo: // used internally for meta info datasets |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
844 case EVR_dataset: // used internally for datasets |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
845 case EVR_fileFormat: // used internally for DICOM files |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
846 case EVR_dicomDir: // used internally for DICOMDIR objects |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
847 case EVR_dirRecord: // used internally for DICOMDIR records |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
848 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
|
849 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
|
850 case EVR_PixelData: // used internally for uncompressed pixeld data |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
851 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
|
852 return new DicomValue; |
0 | 853 |
854 | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
855 /** |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
856 * Default case. |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
857 **/ |
0 | 858 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
859 default: |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
860 return new DicomValue; |
0 | 861 } |
862 } | |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
863 catch (boost::bad_lexical_cast&) |
0 | 864 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
865 return new DicomValue; |
0 | 866 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
867 catch (std::bad_cast&) |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
868 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
869 return new DicomValue; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
870 } |
0 | 871 } |
872 | |
873 | |
1687 | 874 static Json::Value& PrepareNode(Json::Value& parent, |
875 DcmElement& element, | |
876 DicomToJsonFormat format) | |
0 | 877 { |
1687 | 878 assert(parent.type() == Json::objectValue); |
0 | 879 |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
880 DicomTag tag(FromDcmtkBridge::GetTag(element)); |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
881 const std::string formattedTag = tag.Format(); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
882 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
883 if (format == DicomToJsonFormat_Short) |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
884 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
885 parent[formattedTag] = Json::nullValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
886 return parent[formattedTag]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
887 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
888 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
889 // 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
|
890 std::string tagName = FromDcmtkBridge::GetTagName(element); |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
891 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
892 switch (format) |
0 | 893 { |
1860
c7d70f659190
DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1854
diff
changeset
|
894 case DicomToJsonFormat_Human: |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
895 parent[tagName] = Json::nullValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
896 return parent[tagName]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
897 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
898 case DicomToJsonFormat_Full: |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
899 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
900 parent[formattedTag] = Json::objectValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
901 Json::Value& node = parent[formattedTag]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
902 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
903 if (element.isLeaf()) |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
904 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
905 node["Name"] = tagName; |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
906 |
2076 | 907 if (element.getTag().getPrivateCreator() != NULL) |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
908 { |
2076 | 909 node["PrivateCreator"] = element.getTag().getPrivateCreator(); |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
910 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
911 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
912 return node; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
913 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
914 else |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
915 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
916 node["Name"] = tagName; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
917 node["Type"] = "Sequence"; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
918 node["Value"] = Json::nullValue; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
919 return node["Value"]; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
920 } |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
921 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
922 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
923 default: |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
924 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1687 | 925 } |
926 } | |
927 | |
928 | |
929 static void LeafValueToJson(Json::Value& target, | |
930 const DicomValue& value, | |
931 DicomToJsonFormat format, | |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
932 DicomToJsonFlags flags, |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
933 unsigned int maxStringLength) |
1687 | 934 { |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
935 Json::Value* targetValue = NULL; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
936 Json::Value* targetType = NULL; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
937 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
938 switch (format) |
1687 | 939 { |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
940 case DicomToJsonFormat_Short: |
1860
c7d70f659190
DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1854
diff
changeset
|
941 case DicomToJsonFormat_Human: |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
942 { |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
943 assert(target.type() == Json::nullValue); |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
944 targetValue = ⌖ |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
945 break; |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
946 } |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
947 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
948 case DicomToJsonFormat_Full: |
0 | 949 { |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
950 assert(target.type() == Json::objectValue); |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
951 target["Value"] = Json::nullValue; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
952 target["Type"] = Json::nullValue; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
953 targetType = &target["Type"]; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
954 targetValue = &target["Value"]; |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
955 break; |
0 | 956 } |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
957 |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
958 default: |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
959 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1687 | 960 } |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
961 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
962 assert(targetValue != NULL); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
963 assert(targetValue->type() == Json::nullValue); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
964 assert(targetType == NULL || targetType->type() == Json::nullValue); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
965 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
966 if (value.IsNull()) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
967 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
968 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
969 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
970 *targetType = "Null"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
971 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
972 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
973 else if (value.IsBinary()) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
974 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
975 if (flags & DicomToJsonFlags_ConvertBinaryToAscii) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
976 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
977 *targetValue = Toolbox::ConvertToAscii(value.GetContent()); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
978 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
979 else |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
980 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
981 std::string s; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
982 value.FormatDataUriScheme(s); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
983 *targetValue = s; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
984 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
985 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
986 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
987 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
988 *targetType = "Binary"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
989 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
990 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
991 else if (maxStringLength == 0 || |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
992 value.GetContent().size() <= maxStringLength) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
993 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
994 *targetValue = value.GetContent(); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
995 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
996 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
997 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
998 *targetType = "String"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
999 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1000 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1001 else |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1002 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1003 if (targetType != NULL) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1004 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1005 *targetType = "TooLong"; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1006 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1007 } |
1687 | 1008 } |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
1009 |
1687 | 1010 |
2126 | 1011 void FromDcmtkBridge::ElementToJson(Json::Value& parent, |
1012 DcmElement& element, | |
1013 DicomToJsonFormat format, | |
1014 DicomToJsonFlags flags, | |
1015 unsigned int maxStringLength, | |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1016 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
1017 bool hasCodeExtensions, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1018 const std::set<DicomTag>& ignoreTagLength, |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1019 unsigned int depth) |
1687 | 1020 { |
1691 | 1021 if (parent.type() == Json::nullValue) |
1022 { | |
1023 parent = Json::objectValue; | |
1024 } | |
1025 | |
1026 assert(parent.type() == Json::objectValue); | |
1687 | 1027 Json::Value& target = PrepareNode(parent, element, format); |
1028 | |
1029 if (element.isLeaf()) | |
1030 { | |
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
|
1031 // The "0" below lets "LeafValueToJson()" take care of "TooLong" values |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
1032 std::unique_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1033 (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
|
1034 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1035 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
|
1036 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1037 LeafValueToJson(target, *v, format, flags, maxStringLength); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1038 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1039 else |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1040 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1041 LeafValueToJson(target, *v, format, flags, 0); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1042 } |
0 | 1043 } |
1044 else | |
1045 { | |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
1046 assert(target.type() == Json::nullValue); |
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
1047 target = Json::arrayValue; |
0 | 1048 |
1049 // "All subclasses of DcmElement except for DcmSequenceOfItems | |
1050 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset | |
1687 | 1051 // etc. are not." The following dynamic_cast is thus OK. |
0 | 1052 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element); |
1053 | |
1054 for (unsigned long i = 0; i < sequence.card(); i++) | |
1055 { | |
1056 DcmItem* child = sequence.getItem(i); | |
1687 | 1057 Json::Value& v = target.append(Json::objectValue); |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1058 DatasetToJson(v, *child, format, flags, maxStringLength, encoding, hasCodeExtensions, |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1059 ignoreTagLength, depth + 1); |
1687 | 1060 } |
0 | 1061 } |
1062 } | |
1063 | |
1064 | |
2126 | 1065 void FromDcmtkBridge::DatasetToJson(Json::Value& parent, |
1066 DcmItem& item, | |
1067 DicomToJsonFormat format, | |
1068 DicomToJsonFlags flags, | |
1069 unsigned int maxStringLength, | |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1070 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
1071 bool hasCodeExtensions, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1072 const std::set<DicomTag>& ignoreTagLength, |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1073 unsigned int depth) |
1686 | 1074 { |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
1075 assert(parent.type() == Json::objectValue); |
1686 | 1076 |
1077 for (unsigned long i = 0; i < item.card(); i++) | |
1078 { | |
1079 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
|
1080 if (element == NULL) |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
1081 { |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
1082 throw OrthancException(ErrorCode_InternalError); |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
1083 } |
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
1084 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1085 DicomTag tag(FromDcmtkBridge::Convert(element->getTag())); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1086 |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1087 // New flag in Orthanc 1.9.1 |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1088 if (depth == 0 && |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1089 (flags & DicomToJsonFlags_StopAfterPixelData) && |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1090 tag > DICOM_TAG_PIXEL_DATA) |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1091 { |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1092 continue; |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1093 } |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1094 |
4516
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
1095 // New flag in Orthanc 1.9.1 |
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
1096 if ((flags & DicomToJsonFlags_SkipGroupLengths) && |
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
1097 tag.GetElement() == 0x0000) |
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
1098 { |
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
1099 continue; |
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
1100 } |
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
1101 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1102 /*element->getTag().isPrivate()*/ |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1103 if (tag.IsPrivate() && |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1104 !(flags & DicomToJsonFlags_IncludePrivateTags)) |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1105 { |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1106 continue; |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1107 } |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1108 |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1109 if (!(flags & DicomToJsonFlags_IncludeUnknownTags)) |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
1110 { |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1111 DictionaryLocker locker; |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1112 if (locker->findEntry(element->getTag(), element->getTag().getPrivateCreator()) == NULL) |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1113 { |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1114 continue; |
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1115 } |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
1116 } |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
1117 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1118 if (IsBinaryTag(element->getTag())) |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1119 { |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1120 // This is a binary tag |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1121 if ((tag == DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludePixelData)) || |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1122 (tag != DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludeBinary))) |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1123 { |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1124 continue; |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1125 } |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1126 } |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
1127 |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1128 FromDcmtkBridge::ElementToJson(parent, *element, format, flags, maxStringLength, encoding, |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1129 hasCodeExtensions, ignoreTagLength, depth); |
1686 | 1130 } |
1131 } | |
1132 | |
1133 | |
2126 | 1134 void FromDcmtkBridge::ExtractDicomAsJson(Json::Value& target, |
1135 DcmDataset& dataset, | |
1136 DicomToJsonFormat format, | |
1137 DicomToJsonFlags flags, | |
2131 | 1138 unsigned int maxStringLength, |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1139 const std::set<DicomTag>& ignoreTagLength) |
0 | 1140 { |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
1141 const Encoding defaultEncoding = GetDefaultDicomEncoding(); |
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
1142 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
1143 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
1144 Encoding encoding = DetectEncoding(hasCodeExtensions, dataset, defaultEncoding); |
2126 | 1145 |
1688
27d70e9ee2e4
DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1687
diff
changeset
|
1146 target = Json::objectValue; |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1147 DatasetToJson(target, dataset, format, flags, maxStringLength, encoding, hasCodeExtensions, ignoreTagLength, 0); |
0 | 1148 } |
1149 | |
1150 | |
2126 | 1151 void FromDcmtkBridge::ExtractHeaderAsJson(Json::Value& target, |
1152 DcmMetaInfo& dataset, | |
1153 DicomToJsonFormat format, | |
1154 DicomToJsonFlags flags, | |
1155 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
|
1156 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1157 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
|
1158 target = Json::objectValue; |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4501
diff
changeset
|
1159 DatasetToJson(target, dataset, format, flags, maxStringLength, Encoding_Ascii, false, ignoreTagLength, 0); |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
1160 } |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
1161 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1818
diff
changeset
|
1162 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1163 static std::string GetTagNameInternal(DcmTag& tag) |
0 | 1164 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1165 if (!hasExternalDictionaries_) |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1166 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1167 /** |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1168 * Some patches for important tags because of different DICOM |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1169 * dictionaries between DCMTK versions. Since Orthanc 1.9.4, we |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1170 * don't apply these patches if external dictionaries are |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1171 * loaded, notably for compatibility with DICONDE. In Orthanc <= |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1172 * 1.9.3, this was done by method "DicomTag::GetMainTagsName()". |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1173 **/ |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1174 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1175 DicomTag tmp(tag.getGroup(), tag.getElement()); |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1176 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1177 if (tmp == DICOM_TAG_ACCESSION_NUMBER) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1178 return "AccessionNumber"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1179 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1180 if (tmp == DICOM_TAG_SOP_INSTANCE_UID) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1181 return "SOPInstanceUID"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1182 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1183 if (tmp == DICOM_TAG_PATIENT_ID) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1184 return "PatientID"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1185 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1186 if (tmp == DICOM_TAG_SERIES_INSTANCE_UID) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1187 return "SeriesInstanceUID"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1188 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1189 if (tmp == DICOM_TAG_STUDY_INSTANCE_UID) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1190 return "StudyInstanceUID"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1191 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1192 if (tmp == DICOM_TAG_PIXEL_DATA) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1193 return "PixelData"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1194 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1195 if (tmp == DICOM_TAG_IMAGE_INDEX) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1196 return "ImageIndex"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1197 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1198 if (tmp == DICOM_TAG_INSTANCE_NUMBER) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1199 return "InstanceNumber"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1200 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1201 if (tmp == DICOM_TAG_NUMBER_OF_SLICES) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1202 return "NumberOfSlices"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1203 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1204 if (tmp == DICOM_TAG_NUMBER_OF_FRAMES) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1205 return "NumberOfFrames"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1206 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1207 if (tmp == DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1208 return "CardiacNumberOfImages"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1209 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1210 if (tmp == DICOM_TAG_IMAGES_IN_ACQUISITION) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1211 return "ImagesInAcquisition"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1212 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1213 if (tmp == DICOM_TAG_PATIENT_NAME) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1214 return "PatientName"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1215 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1216 if (tmp == DICOM_TAG_IMAGE_POSITION_PATIENT) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1217 return "ImagePositionPatient"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1218 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1219 if (tmp == DICOM_TAG_IMAGE_ORIENTATION_PATIENT) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1220 return "ImageOrientationPatient"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1221 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1222 // New in Orthanc 1.6.0, as tagged as "RETIRED_" since DCMTK 3.6.4 |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1223 if (tmp == DICOM_TAG_OTHER_PATIENT_IDS) |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1224 return "OtherPatientIDs"; |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1225 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1226 // End of patches |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1227 } |
106 | 1228 |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1229 #if 0 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1230 // This version explicitly calls the dictionary |
0 | 1231 const DcmDataDictionary& dict = dcmDataDict.rdlock(); |
1232 const DcmDictEntry* entry = dict.findEntry(tag, NULL); | |
1233 | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1234 std::string s(DcmTag_ERROR_TagName); |
0 | 1235 if (entry != NULL) |
1236 { | |
1237 s = std::string(entry->getTagName()); | |
1238 } | |
1239 | |
1240 dcmDataDict.unlock(); | |
1241 return s; | |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1242 #else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1243 const char* name = tag.getTagName(); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1244 if (name == NULL) |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1245 { |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1246 return DcmTag_ERROR_TagName; |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1247 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1248 else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1249 { |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1250 return std::string(name); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1251 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1252 #endif |
0 | 1253 } |
1254 | |
1255 | |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1256 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
|
1257 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
|
1258 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1259 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
|
1260 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1261 if (!privateCreator.empty()) |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1262 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1263 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
|
1264 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1265 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1266 return GetTagNameInternal(tag); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1267 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1268 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1269 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1270 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
|
1271 { |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1272 // 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
|
1273 // 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
|
1274 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
|
1275 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1276 return GetTagNameInternal(tag); |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1277 } |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1278 |
4297 | 1279 std::string FromDcmtkBridge::GetTagName(const DicomElement &element) |
1280 { | |
1281 return GetTagName(element.GetTag(), ""); | |
1282 } | |
1283 | |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1284 |
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2076
diff
changeset
|
1285 |
304 | 1286 DicomTag FromDcmtkBridge::ParseTag(const char* name) |
0 | 1287 { |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2554
diff
changeset
|
1288 DicomTag parsed(0, 0); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2554
diff
changeset
|
1289 if (DicomTag::ParseHexadecimal(parsed, name)) |
304 | 1290 { |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2554
diff
changeset
|
1291 return parsed; |
1861
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1292 } |
a7bea843a7bc
"OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
1293 |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1294 #if 0 |
0 | 1295 const DcmDataDictionary& dict = dcmDataDict.rdlock(); |
1296 const DcmDictEntry* entry = dict.findEntry(name); | |
1297 | |
1298 if (entry == NULL) | |
1299 { | |
1300 dcmDataDict.unlock(); | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1557
diff
changeset
|
1301 throw OrthancException(ErrorCode_UnknownDicomTag); |
0 | 1302 } |
1303 else | |
1304 { | |
1305 DcmTagKey key = entry->getKey(); | |
1306 DicomTag tag(key.getGroup(), key.getElement()); | |
1307 dcmDataDict.unlock(); | |
1308 return tag; | |
1309 } | |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1310 #else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1311 DcmTag tag; |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1312 if (DcmTag::findTagFromName(name, tag).good()) |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1313 { |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1314 return DicomTag(tag.getGTag(), tag.getETag()); |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1315 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1316 else |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1317 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1318 CLOG(INFO, DICOM) << "Unknown DICOM tag: \"" << name << "\""; |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1319 throw OrthancException(ErrorCode_UnknownDicomTag, name, false); |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1320 } |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1321 #endif |
0 | 1322 } |
1323 | |
4297 | 1324 DicomTag FromDcmtkBridge::ParseTag(const std::string &name) |
1325 { | |
1326 return ParseTag(name.c_str()); | |
1327 } | |
1328 | |
1329 bool FromDcmtkBridge::HasTag(const DicomMap &fields, const std::string &tagName) | |
1330 { | |
1331 return fields.HasTag(ParseTag(tagName)); | |
1332 } | |
1333 | |
4941 | 1334 void FromDcmtkBridge::FormatListOfTags(std::string& output, const std::set<DicomTag>& tags) |
1335 { | |
1336 std::set<std::string> values; | |
1337 for (std::set<DicomTag>::const_iterator it = tags.begin(); | |
4981 | 1338 it != tags.end(); ++it) |
4941 | 1339 { |
1340 values.insert(it->Format()); | |
1341 } | |
1342 | |
1343 Toolbox::JoinStrings(output, values, ";"); | |
1344 } | |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1345 |
4950
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1346 void FromDcmtkBridge::FormatListOfTags(Json::Value& output, const std::set<DicomTag>& tags) |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1347 { |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1348 output = Json::arrayValue; |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1349 for (std::set<DicomTag>::const_iterator it = tags.begin(); |
4981 | 1350 it != tags.end(); ++it) |
4950
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1351 { |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1352 output.append(it->Format()); |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1353 } |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1354 } |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4941
diff
changeset
|
1355 |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1356 // parses a list like "0010,0010;PatientBirthDate;0020,0020" |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1357 void FromDcmtkBridge::ParseListOfTags(std::set<DicomTag>& result, const std::string& source) |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1358 { |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1359 result.clear(); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1360 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1361 std::vector<std::string> tokens; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1362 Toolbox::TokenizeString(tokens, source, ';'); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1363 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1364 for (std::vector<std::string>::const_iterator it = tokens.begin(); |
4981 | 1365 it != tokens.end(); ++it) |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1366 { |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1367 if (it->size() > 0) |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1368 { |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1369 DicomTag tag = FromDcmtkBridge::ParseTag(*it); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1370 result.insert(tag); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1371 } |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1372 } |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1373 } |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1374 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
1375 |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1376 void FromDcmtkBridge::ParseListOfTags(std::set<DicomTag>& result, const Json::Value& source) |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1377 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1378 result.clear(); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1379 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1380 if (!source.isArray()) |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1381 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1382 throw OrthancException(ErrorCode_BadRequest, "List of tags is not an array"); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1383 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1384 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1385 for (Json::ArrayIndex i = 0; i < source.size(); i++) |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1386 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1387 const std::string& value = source[i].asString(); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1388 DicomTag tag = FromDcmtkBridge::ParseTag(value); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1389 result.insert(tag); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1390 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1391 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
1392 |
4297 | 1393 const DicomValue &FromDcmtkBridge::GetValue(const DicomMap &fields, |
1394 const std::string &tagName) | |
1395 { | |
1396 return fields.GetValue(ParseTag(tagName)); | |
1397 } | |
1398 | |
1399 void FromDcmtkBridge::SetValue(DicomMap &target, | |
1400 const std::string &tagName, | |
1401 DicomValue *value) | |
1402 { | |
1403 const DicomTag tag = ParseTag(tagName); | |
1404 target.SetValueInternal(tag.GetGroup(), tag.GetElement(), value); | |
1405 } | |
1406 | |
0 | 1407 |
1655
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1408 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
|
1409 { |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1410 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
|
1411 return tmp.isUnknownVR(); |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1412 } |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1413 |
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
1414 |
0 | 1415 void FromDcmtkBridge::ToJson(Json::Value& result, |
1368 | 1416 const DicomMap& values, |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1417 DicomToJsonFormat format) |
0 | 1418 { |
1419 if (result.type() != Json::objectValue) | |
1420 { | |
62 | 1421 throw OrthancException(ErrorCode_BadParameterType); |
0 | 1422 } |
1423 | |
1424 result.clear(); | |
1425 | |
3651
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1426 for (DicomMap::Content::const_iterator |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1427 it = values.content_.begin(); it != values.content_.end(); ++it) |
0 | 1428 { |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1429 switch (format) |
1368 | 1430 { |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1431 case DicomToJsonFormat_Human: |
1368 | 1432 { |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1433 // TODO Inject PrivateCreator if some is available in the DicomMap? |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1434 const std::string tagName = GetTagName(it->first, ""); |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1435 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1436 if (it->second->IsNull()) |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1437 { |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1438 result[tagName] = Json::nullValue; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1439 } |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1440 else if (it->second->IsSequence()) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1441 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1442 result[tagName] = Json::arrayValue; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1443 const Json::Value& jsonSequence = it->second->GetSequenceContent(); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1444 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1445 for (Json::Value::ArrayIndex i = 0; i < jsonSequence.size(); ++i) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1446 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1447 Json::Value target = Json::objectValue; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1448 Toolbox::SimplifyDicomAsJson(target, jsonSequence[i], DicomToJsonFormat_Human); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1449 result[tagName].append(target); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1450 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1451 } |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1452 else |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1453 { |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1454 // TODO IsBinary |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1455 result[tagName] = it->second->GetContent(); |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1456 } |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1457 break; |
1368 | 1458 } |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1459 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1460 case DicomToJsonFormat_Full: |
1368 | 1461 { |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1462 // TODO Inject PrivateCreator if some is available in the DicomMap? |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1463 const std::string tagName = GetTagName(it->first, ""); |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1464 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1465 Json::Value value = Json::objectValue; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1466 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1467 value["Name"] = tagName; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1468 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1469 if (it->second->IsNull()) |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1470 { |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1471 value["Type"] = "Null"; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1472 value["Value"] = Json::nullValue; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1473 } |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1474 else if (it->second->IsSequence()) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1475 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1476 value["Type"] = "Sequence"; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1477 value["Value"] = it->second->GetSequenceContent(); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1478 } |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1479 else |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1480 { |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1481 // TODO IsBinary |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1482 value["Type"] = "String"; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1483 value["Value"] = it->second->GetContent(); |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1484 } |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1485 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1486 result[it->first.Format()] = value; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1487 break; |
1368 | 1488 } |
1489 | |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1490 case DicomToJsonFormat_Short: |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1491 { |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1492 const std::string hex = it->first.Format(); |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1493 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1494 if (it->second->IsNull()) |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1495 { |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1496 result[hex] = Json::nullValue; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1497 } |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1498 else if (it->second->IsSequence()) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1499 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1500 result[hex] = Json::arrayValue; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1501 const Json::Value& jsonSequence = it->second->GetSequenceContent(); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1502 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1503 for (Json::Value::ArrayIndex i = 0; i < jsonSequence.size(); ++i) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1504 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1505 Json::Value target = Json::objectValue; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1506 Toolbox::SimplifyDicomAsJson(target, jsonSequence[i], DicomToJsonFormat_Short); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1507 result[hex].append(target); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1508 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5011
diff
changeset
|
1509 } |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1510 else |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1511 { |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1512 // TODO IsBinary |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1513 result[hex] = it->second->GetContent(); |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1514 } |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1515 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1516 break; |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1517 } |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1518 |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1519 default: |
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
1520 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1368 | 1521 } |
0 | 1522 } |
1523 } | |
176 | 1524 |
1525 | |
788 | 1526 std::string FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType level) |
176 | 1527 { |
1528 char uid[100]; | |
1529 | |
1530 switch (level) | |
1531 { | |
788 | 1532 case ResourceType_Patient: |
311 | 1533 // The "PatientID" field is of type LO (Long String), 64 |
1534 // Bytes Maximum. An UUID is of length 36, thus it can be used | |
1535 // as a random PatientID. | |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
1536 return Toolbox::GenerateUuid(); |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1537 |
788 | 1538 case ResourceType_Instance: |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1539 return dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT); |
176 | 1540 |
788 | 1541 case ResourceType_Series: |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1542 return dcmGenerateUniqueIdentifier(uid, SITE_SERIES_UID_ROOT); |
176 | 1543 |
788 | 1544 case ResourceType_Study: |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1545 return dcmGenerateUniqueIdentifier(uid, SITE_STUDY_UID_ROOT); |
176 | 1546 |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1547 default: |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
1548 throw OrthancException(ErrorCode_ParameterOutOfRange); |
176 | 1549 } |
1550 } | |
1551 | |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1552 |
3872
b40dfa6dc8da
working on a simpler abstraction for transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3811
diff
changeset
|
1553 |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1554 static bool SaveToMemoryBufferInternal(std::string& buffer, |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1555 DcmFileFormat& dicom, |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1556 E_TransferSyntax xfer) |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1557 { |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1558 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength; |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1559 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1560 // Create a memory buffer with the proper size |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1561 { |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1562 const uint32_t estimatedSize = dicom.calcElementLength(xfer, encodingType); // (*) |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1563 buffer.resize(estimatedSize); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1564 } |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1565 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1566 DcmOutputBufferStream ob(&buffer[0], buffer.size()); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1567 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1568 // Fill the memory buffer with the meta-header and the dataset |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1569 dicom.transferInit(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1570 OFCondition c = dicom.write(ob, xfer, encodingType, NULL, |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1571 /*opt_groupLength*/ EGL_recalcGL, |
3765
4a25727401cd
first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3748
diff
changeset
|
1572 /*opt_paddingType*/ EPD_noChange, |
4a25727401cd
first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3748
diff
changeset
|
1573 /*padlen*/ 0, /*subPadlen*/ 0, /*instanceLength*/ 0, |
4a25727401cd
first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3748
diff
changeset
|
1574 EWM_updateMeta /* creates new SOP instance UID on lossy */); |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1575 dicom.transferEnd(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1576 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1577 if (c.good()) |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1578 { |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1579 // The DICOM file is successfully written, truncate the target |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1580 // buffer if its size was overestimated by (*) |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1581 ob.flush(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1582 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1583 size_t effectiveSize = static_cast<size_t>(ob.tell()); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1584 if (effectiveSize < buffer.size()) |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1585 { |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1586 buffer.resize(effectiveSize); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1587 } |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1588 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1589 return true; |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1590 } |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1591 else |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1592 { |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1593 // Error |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1594 buffer.clear(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1595 return false; |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1596 } |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1597 } |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1598 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1599 |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1600 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer, |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
1601 DcmDataset& dataSet) |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1602 { |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1603 // Determine the transfer syntax which shall be used to write the |
3811
890af7156f19
fix transcoding to jpeg baseline
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3772
diff
changeset
|
1604 // information to the file. If not possible, switch to the Little |
890af7156f19
fix transcoding to jpeg baseline
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3772
diff
changeset
|
1605 // Endian syntax, with explicit length. |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1606 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1607 // 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
|
1608 |
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
|
1609 |
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
|
1610 /** |
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
|
1611 * 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
|
1612 * "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
|
1613 * 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
|
1614 * (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
|
1615 **/ |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1616 E_TransferSyntax xfer = dataSet.getCurrentXfer(); |
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
|
1617 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
|
1618 { |
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
|
1619 // 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
|
1620 // 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
|
1621 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
|
1622 } |
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
|
1623 |
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
|
1624 // Create the meta-header information |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
1625 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
|
1626 ff.validateMetaInfo(xfer); |
1316
1c8dfedefefe
Fix anonymization generating non-portable DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1307
diff
changeset
|
1627 ff.removeInvalidGroups(); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1628 |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1629 return SaveToMemoryBufferInternal(buffer, ff, xfer); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1630 } |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1631 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1632 |
3872
b40dfa6dc8da
working on a simpler abstraction for transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3811
diff
changeset
|
1633 bool FromDcmtkBridge::Transcode(DcmFileFormat& dicom, |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1634 DicomTransferSyntax syntax, |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1635 const DcmRepresentationParameter* representation) |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1636 { |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1637 E_TransferSyntax xfer; |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1638 if (!LookupDcmtkTransferSyntax(xfer, syntax)) |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1639 { |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1640 throw OrthancException(ErrorCode_InternalError); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1641 } |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
1642 else |
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
1643 { |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
1644 DicomTransferSyntax sourceSyntax; |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
1645 bool known = LookupOrthancTransferSyntax(sourceSyntax, dicom); |
3922
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
1646 |
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
1647 if (!dicom.chooseRepresentation(xfer, representation).good() || |
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
1648 !dicom.canWriteXfer(xfer) || |
3811
890af7156f19
fix transcoding to jpeg baseline
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3772
diff
changeset
|
1649 !dicom.validateMetaInfo(xfer, EWM_updateMeta).good()) |
890af7156f19
fix transcoding to jpeg baseline
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3772
diff
changeset
|
1650 { |
890af7156f19
fix transcoding to jpeg baseline
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3772
diff
changeset
|
1651 return false; |
890af7156f19
fix transcoding to jpeg baseline
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3772
diff
changeset
|
1652 } |
3872
b40dfa6dc8da
working on a simpler abstraction for transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3811
diff
changeset
|
1653 else |
b40dfa6dc8da
working on a simpler abstraction for transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3811
diff
changeset
|
1654 { |
b40dfa6dc8da
working on a simpler abstraction for transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3811
diff
changeset
|
1655 dicom.removeInvalidGroups(); |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1656 |
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
1657 if (known) |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1658 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1659 CLOG(INFO, DICOM) << "Transcoded an image from transfer syntax " |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1660 << GetTransferSyntaxUid(sourceSyntax) << " to " |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1661 << GetTransferSyntaxUid(syntax); |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1662 } |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1663 else |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1664 { |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1665 CLOG(INFO, DICOM) << "Transcoded an image from unknown transfer syntax to " |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1666 << GetTransferSyntaxUid(syntax); |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1667 } |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
1668 |
3872
b40dfa6dc8da
working on a simpler abstraction for transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3811
diff
changeset
|
1669 return true; |
b40dfa6dc8da
working on a simpler abstraction for transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3811
diff
changeset
|
1670 } |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1671 } |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
1672 } |
1360 | 1673 |
1674 | |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1675 ValueRepresentation FromDcmtkBridge::LookupValueRepresentation(const DicomTag& tag) |
1360 | 1676 { |
1677 DcmTag t(tag.GetGroup(), tag.GetElement()); | |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1678 return Convert(t.getEVR()); |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1679 } |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1680 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1681 ValueRepresentation FromDcmtkBridge::Convert(const DcmEVR vr) |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1682 { |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1683 switch (vr) |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1684 { |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1685 case EVR_AE: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1686 return ValueRepresentation_ApplicationEntity; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1687 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1688 case EVR_AS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1689 return ValueRepresentation_AgeString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1690 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1691 case EVR_AT: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1692 return ValueRepresentation_AttributeTag; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1693 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1694 case EVR_CS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1695 return ValueRepresentation_CodeString; |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1696 |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1697 case EVR_DA: |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1698 return ValueRepresentation_Date; |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1699 |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1700 case EVR_DS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1701 return ValueRepresentation_DecimalString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1702 |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1703 case EVR_DT: |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1704 return ValueRepresentation_DateTime; |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1705 |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1706 case EVR_FL: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1707 return ValueRepresentation_FloatingPointSingle; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1708 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1709 case EVR_FD: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1710 return ValueRepresentation_FloatingPointDouble; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1711 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1712 case EVR_IS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1713 return ValueRepresentation_IntegerString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1714 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1715 case EVR_LO: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1716 return ValueRepresentation_LongString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1717 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1718 case EVR_LT: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1719 return ValueRepresentation_LongText; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1720 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1721 case EVR_OB: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1722 return ValueRepresentation_OtherByte; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1723 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1724 #if DCMTK_VERSION_NUMBER >= 361 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1725 case EVR_OD: |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1726 return ValueRepresentation_OtherDouble; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1727 #endif |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1728 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1729 case EVR_OF: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1730 return ValueRepresentation_OtherFloat; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1731 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1732 #if DCMTK_VERSION_NUMBER >= 362 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1733 case EVR_OL: |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1734 return ValueRepresentation_OtherLong; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1735 #endif |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1736 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1737 case EVR_OW: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1738 return ValueRepresentation_OtherWord; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1739 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1740 case EVR_PN: |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1741 return ValueRepresentation_PersonName; |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1742 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1743 case EVR_SH: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1744 return ValueRepresentation_ShortString; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1745 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1746 case EVR_SL: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1747 return ValueRepresentation_SignedLong; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1748 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1749 case EVR_SQ: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1750 return ValueRepresentation_Sequence; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1751 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1752 case EVR_SS: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1753 return ValueRepresentation_SignedShort; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1754 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1755 case EVR_ST: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1756 return ValueRepresentation_ShortText; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1757 |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1758 case EVR_TM: |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1759 return ValueRepresentation_Time; |
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1760 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1761 #if DCMTK_VERSION_NUMBER >= 361 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1762 case EVR_UC: |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1763 return ValueRepresentation_UnlimitedCharacters; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1764 #endif |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1765 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1766 case EVR_UI: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1767 return ValueRepresentation_UniqueIdentifier; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1768 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1769 case EVR_UL: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1770 return ValueRepresentation_UnsignedLong; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1771 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1772 case EVR_UN: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1773 return ValueRepresentation_Unknown; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1774 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1775 #if DCMTK_VERSION_NUMBER >= 361 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1776 case EVR_UR: |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1777 return ValueRepresentation_UniversalResource; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
1778 #endif |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1779 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1780 case EVR_US: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1781 return ValueRepresentation_UnsignedShort; |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1782 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1783 case EVR_UT: |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1784 return ValueRepresentation_UnlimitedText; |
1792 | 1785 |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1786 default: |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
1787 return ValueRepresentation_NotSupported; |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1788 } |
1360 | 1789 } |
1790 | |
1689 | 1791 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1792 DcmElement* FromDcmtkBridge::CreateElementForTag(const DicomTag& tag, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1793 const std::string& privateCreator) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1794 { |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1795 if (tag.IsPrivate() && |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1796 privateCreator.empty()) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1797 { |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1798 // This solves issue 140 (Modifying private tags with REST API |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1799 // changes VR from LO to UN) |
4476
c1f36fd13730
migrate remaining links to issues in bitbucket to mercurial server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1800 // https://bugs.orthanc-server.com/show_bug.cgi?id=140 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1801 LOG(WARNING) << "Private creator should not be empty while creating a private tag: " << tag.Format(); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
1802 } |
1689 | 1803 |
3692
fd302ec6a502
fix for ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1804 #if DCMTK_VERSION_NUMBER >= 362 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1805 DcmTag key(tag.GetGroup(), tag.GetElement()); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1806 if (tag.IsPrivate()) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1807 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1808 return DcmItem::newDicomElement(key, privateCreator.c_str()); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1809 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1810 else |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1811 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1812 return DcmItem::newDicomElement(key, NULL); |
1689 | 1813 } |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1814 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1815 #else |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1816 DcmTag key(tag.GetGroup(), tag.GetElement()); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1817 if (tag.IsPrivate()) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1818 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1819 // https://forum.dcmtk.org/viewtopic.php?t=4527 |
3708 | 1820 LOG(WARNING) << "You are using DCMTK <= 3.6.1: All the private tags " |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1821 "are considered as having a binary value representation"; |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1822 key.setPrivateCreator(privateCreator.c_str()); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1823 return new DcmOtherByteOtherWord(key); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1824 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1825 else |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1826 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1827 return newDicomElement(key); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1828 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1829 #endif |
1689 | 1830 } |
1831 | |
1832 | |
1833 | |
1834 void FromDcmtkBridge::FillElementWithString(DcmElement& element, | |
1695 | 1835 const std::string& utf8Value, |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1836 bool decodeDataUriScheme, |
1695 | 1837 Encoding dicomEncoding) |
1689 | 1838 { |
1839 std::string binary; | |
1695 | 1840 const std::string* decoded = &utf8Value; |
1689 | 1841 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
1842 if (decodeDataUriScheme && |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2831
diff
changeset
|
1843 boost::starts_with(utf8Value, URI_SCHEME_PREFIX_BINARY)) |
1689 | 1844 { |
1845 std::string mime; | |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1846 if (!Toolbox::DecodeDataUriScheme(mime, binary, utf8Value)) |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1847 { |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1848 throw OrthancException(ErrorCode_BadFileFormat); |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1849 } |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1976
diff
changeset
|
1850 |
1695 | 1851 decoded = &binary; |
1852 } | |
1853 else if (dicomEncoding != Encoding_Utf8) | |
1854 { | |
1855 binary = Toolbox::ConvertFromUtf8(utf8Value, dicomEncoding); | |
1689 | 1856 decoded = &binary; |
1857 } | |
1858 | |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1859 if (IsBinaryTag(element.getTag())) |
1689 | 1860 { |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1861 bool ok; |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1862 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1863 switch (element.getTag().getEVR()) |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1864 { |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1865 case EVR_OW: |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1866 if (decoded->size() % sizeof(Uint16) != 0) |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1867 { |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1868 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
|
1869 ok = false; |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1870 } |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1871 else |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1872 { |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1873 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
|
1874 } |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1875 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1876 break; |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1877 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1878 default: |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1879 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
|
1880 break; |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1881 } |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1882 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1883 if (ok) |
1689 | 1884 { |
1885 return; | |
1886 } | |
1887 else | |
1888 { | |
1889 throw OrthancException(ErrorCode_InternalError); | |
1890 } | |
1891 } | |
1892 | |
1893 bool ok = false; | |
1894 | |
1895 try | |
1896 { | |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1897 switch (element.getTag().getEVR()) |
1689 | 1898 { |
1899 // http://support.dcmtk.org/docs/dcvr_8h-source.html | |
1900 | |
1901 /** | |
1902 * TODO. | |
1903 **/ | |
1904 | |
1905 case EVR_OB: // other byte | |
1906 case EVR_OW: // other word | |
1907 throw OrthancException(ErrorCode_NotImplemented); | |
1908 | |
1909 case EVR_UN: // unknown value representation | |
1910 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1911 | |
1912 | |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1913 /** |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1914 * String types. |
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
1915 **/ |
1689 | 1916 |
1917 case EVR_DS: // decimal string | |
1918 case EVR_IS: // integer string | |
1919 case EVR_AS: // age string | |
1920 case EVR_DA: // date string | |
1921 case EVR_DT: // date time string | |
1922 case EVR_TM: // time string | |
1923 case EVR_AE: // application entity title | |
1924 case EVR_CS: // code string | |
1925 case EVR_SH: // short string | |
1926 case EVR_LO: // long string | |
1927 case EVR_ST: // short text | |
1928 case EVR_LT: // long text | |
1929 case EVR_UT: // unlimited text | |
1930 case EVR_PN: // person name | |
1931 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
|
1932 #if DCMTK_VERSION_NUMBER >= 361 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1933 case EVR_UC: // unlimited characters |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
1934 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
|
1935 #endif |
1689 | 1936 { |
1937 ok = element.putString(decoded->c_str()).good(); | |
1938 break; | |
1939 } | |
1940 | |
1941 | |
1942 /** | |
1943 * Numerical types | |
1944 **/ | |
1945 | |
1946 case EVR_SL: // signed long | |
1947 { | |
1948 ok = element.putSint32(boost::lexical_cast<Sint32>(*decoded)).good(); | |
1949 break; | |
1950 } | |
1951 | |
1952 case EVR_SS: // signed short | |
1953 { | |
1954 ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good(); | |
1955 break; | |
1956 } | |
1957 | |
1958 case EVR_UL: // unsigned long | |
3692
fd302ec6a502
fix for ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1959 #if DCMTK_VERSION_NUMBER >= 362 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1960 case EVR_OL: // other long (requires byte-swapping) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1961 #endif |
1689 | 1962 { |
1963 ok = element.putUint32(boost::lexical_cast<Uint32>(*decoded)).good(); | |
1964 break; | |
1965 } | |
1966 | |
4845
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1967 case EVR_xs: // unsigned short, signed short or multiple values |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1968 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1969 if (decoded->find('\\') != std::string::npos) |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1970 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1971 ok = element.putString(decoded->c_str()).good(); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1972 } |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1973 else if (decoded->find('-') != std::string::npos) |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1974 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1975 ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good(); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1976 } |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1977 else |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1978 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1979 ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good(); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1980 } |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1981 break; |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1982 } |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1983 |
1689 | 1984 case EVR_US: // unsigned short |
1985 { | |
1986 ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good(); | |
1987 break; | |
1988 } | |
1989 | |
1990 case EVR_FL: // float single-precision | |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1991 case EVR_OF: // other float (requires byte swapping) |
1689 | 1992 { |
1993 ok = element.putFloat32(boost::lexical_cast<float>(*decoded)).good(); | |
1994 break; | |
1995 } | |
1996 | |
1997 case EVR_FD: // float double-precision | |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1998 #if DCMTK_VERSION_NUMBER >= 361 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1999 case EVR_OD: // other double (requires byte-swapping) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2000 #endif |
1689 | 2001 { |
2002 ok = element.putFloat64(boost::lexical_cast<double>(*decoded)).good(); | |
2003 break; | |
2004 } | |
2005 | |
2006 | |
2007 /** | |
4663
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2008 * Other types |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2009 **/ |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2010 |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2011 case EVR_AT: // attribute tag, new in Orthanc 1.9.4 |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2012 { |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2013 DicomTag value = ParseTag(utf8Value); |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2014 ok = element.putTagVal(DcmTagKey(value.GetGroup(), value.GetElement())).good(); |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2015 break; |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2016 } |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2017 |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2018 |
72af097bb92b
"Replace" tags in "/modify" and "/anonymize" now supports value representation AT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4528
diff
changeset
|
2019 /** |
1689 | 2020 * Sequence types, should never occur at this point. |
2021 **/ | |
2022 | |
2023 case EVR_SQ: // sequence of items | |
2024 { | |
2025 ok = false; | |
2026 break; | |
2027 } | |
2028 | |
2029 | |
2030 /** | |
2031 * Internal to DCMTK. | |
2032 **/ | |
2033 | |
2034 case EVR_ox: // OB or OW depending on context | |
2035 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) | |
2036 case EVR_na: // na="not applicable", for data which has no VR | |
2037 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor | |
2038 case EVR_item: // used internally for items | |
2039 case EVR_metainfo: // used internally for meta info datasets | |
2040 case EVR_dataset: // used internally for datasets | |
2041 case EVR_fileFormat: // used internally for DICOM files | |
2042 case EVR_dicomDir: // used internally for DICOMDIR objects | |
2043 case EVR_dirRecord: // used internally for DICOMDIR records | |
2044 case EVR_pixelSQ: // used internally for pixel sequences in a compressed image | |
2045 case EVR_pixelItem: // used internally for pixel items in a compressed image | |
2046 case EVR_UNKNOWN: // used internally for elements with unknown VR (encoded with 4-byte length field in explicit VR) | |
2047 case EVR_PixelData: // used internally for uncompressed pixeld data | |
2048 case EVR_OverlayData: // used internally for overlay data | |
2049 case EVR_UNKNOWN2B: // used internally for elements with unknown VR with 2-byte length field in explicit VR | |
2050 default: | |
2051 break; | |
2052 } | |
2053 } | |
2054 catch (boost::bad_lexical_cast&) | |
2055 { | |
2056 ok = false; | |
2057 } | |
2058 | |
2059 if (!ok) | |
2060 { | |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2061 DicomTag tag(element.getTag().getGroup(), element.getTag().getElement()); |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2062 throw OrthancException(ErrorCode_BadFileFormat, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2063 "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
|
2064 ") has out-of-range value: \"" + (*decoded) + "\""); |
1689 | 2065 } |
2066 } | |
2067 | |
2068 | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
2069 DcmElement* FromDcmtkBridge::FromJson(const DicomTag& tag, |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1691
diff
changeset
|
2070 const Json::Value& value, |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1792
diff
changeset
|
2071 bool decodeDataUriScheme, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2072 Encoding dicomEncoding, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2073 const std::string& privateCreator) |
1689 | 2074 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
2075 std::unique_ptr<DcmElement> element; |
1689 | 2076 |
1690 | 2077 switch (value.type()) |
1689 | 2078 { |
1690 | 2079 case Json::stringValue: |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2080 element.reset(CreateElementForTag(tag, privateCreator)); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2081 FillElementWithString(*element, value.asString(), decodeDataUriScheme, dicomEncoding); |
1690 | 2082 break; |
2083 | |
2216
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2084 case Json::nullValue: |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2085 element.reset(CreateElementForTag(tag, privateCreator)); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2086 FillElementWithString(*element, "", decodeDataUriScheme, dicomEncoding); |
2216
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2087 break; |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2088 |
1690 | 2089 case Json::arrayValue: |
2090 { | |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2091 const char* p = NULL; |
4016
c675d77b82ab
fix creation of sequence in private tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4007
diff
changeset
|
2092 if (tag.IsPrivate() && |
c675d77b82ab
fix creation of sequence in private tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4007
diff
changeset
|
2093 !privateCreator.empty()) |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2094 { |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2095 p = privateCreator.c_str(); |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2096 } |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2097 |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2098 DcmTag key(tag.GetGroup(), tag.GetElement(), p); |
1690 | 2099 if (key.getEVR() != EVR_SQ) |
2100 { | |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2101 throw OrthancException(ErrorCode_BadParameterType, |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3922
diff
changeset
|
2102 "Bad Parameter type for tag " + tag.Format()); |
1690 | 2103 } |
2104 | |
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
|
2105 DcmSequenceOfItems* sequence = new DcmSequenceOfItems(key); |
1690 | 2106 element.reset(sequence); |
2107 | |
2108 for (Json::Value::ArrayIndex i = 0; i < value.size(); i++) | |
2109 { | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
2110 std::unique_ptr<DcmItem> item(new DcmItem); |
1690 | 2111 |
2830 | 2112 switch (value[i].type()) |
1690 | 2113 { |
2830 | 2114 case Json::objectValue: |
2115 { | |
2116 Json::Value::Members members = value[i].getMemberNames(); | |
2117 for (Json::Value::ArrayIndex j = 0; j < members.size(); j++) | |
2118 { | |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2119 item->insert(FromJson(ParseTag(members[j]), value[i][members[j]], decodeDataUriScheme, dicomEncoding, privateCreator)); |
2830 | 2120 } |
2831 | 2121 break; |
2830 | 2122 } |
2123 | |
2124 case Json::arrayValue: | |
2831 | 2125 { |
2830 | 2126 // Lua cannot disambiguate between an empty dictionary |
2127 // and an empty array | |
2128 if (value[i].size() != 0) | |
2129 { | |
2130 throw OrthancException(ErrorCode_BadParameterType); | |
2131 } | |
2132 break; | |
2831 | 2133 } |
2830 | 2134 |
2135 default: | |
2136 throw OrthancException(ErrorCode_BadParameterType); | |
1690 | 2137 } |
2138 | |
2139 sequence->append(item.release()); | |
2140 } | |
2141 | |
2142 break; | |
2143 } | |
2144 | |
2145 default: | |
3895 | 2146 throw OrthancException(ErrorCode_BadParameterType, "Bad Parameter type for tag " + tag.Format()); |
1689 | 2147 } |
2148 | |
2149 return element.release(); | |
2150 } | |
1765
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
2151 |
57b9e6890482
New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
2152 |
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
|
2153 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
|
2154 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2155 DcmElement *element = NULL; |
1927
b60f27664b8f
simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1924
diff
changeset
|
2156 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
|
2157 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2158 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
|
2159 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2160 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2161 DcmPixelData& pixelData = dynamic_cast<DcmPixelData&>(*element); |
3922
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
2162 |
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
2163 E_TransferSyntax repType; |
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
2164 const DcmRepresentationParameter *repParam = NULL; |
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
2165 pixelData.getCurrentRepresentationKey(repType, repParam); |
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
2166 |
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
|
2167 DcmPixelSequence* pixelSequence = NULL; |
3922
74eeadf5d51d
fix access to compressed frames after transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3896
diff
changeset
|
2168 if (!pixelData.getEncapsulatedRepresentation(repType, repParam, pixelSequence).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
|
2169 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2170 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
|
2171 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2172 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
|
2173 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2174 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
|
2175 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
2176 } |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2177 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2178 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2179 Encoding FromDcmtkBridge::ExtractEncoding(const Json::Value& json, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2180 Encoding defaultEncoding) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2181 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2182 if (json.type() != Json::objectValue) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2183 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2184 throw OrthancException(ErrorCode_BadParameterType); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2185 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2186 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2187 Encoding encoding = defaultEncoding; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2188 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2189 const Json::Value::Members tags = json.getMemberNames(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2190 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2191 // Look for SpecificCharacterSet (0008,0005) in the JSON file |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2192 for (size_t i = 0; i < tags.size(); i++) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2193 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2194 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2195 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2196 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2197 const Json::Value& value = json[tags[i]]; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2198 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
|
2199 (value.asString().length() != 0 && |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2200 !GetDicomEncoding(encoding, value.asCString()))) |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2201 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2202 throw OrthancException(ErrorCode_BadRequest, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2203 "Unknown encoding while creating DICOM from JSON: " + |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2204 value.toStyledString()); |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2205 } |
2216
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2206 |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2207 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
|
2208 { |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2209 return defaultEncoding; |
9a8fab016145
sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2209
diff
changeset
|
2210 } |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2211 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2212 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2213 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2214 return encoding; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2215 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2216 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2217 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2218 static void SetString(DcmDataset& target, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2219 const DcmTag& tag, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2220 const std::string& value) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2221 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2222 if (!target.putAndInsertString(tag, value.c_str()).good()) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2223 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2224 throw OrthancException(ErrorCode_InternalError); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2225 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2226 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2227 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2228 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2229 DcmDataset* FromDcmtkBridge::FromJson(const Json::Value& json, // Encoded using UTF-8 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2230 bool generateIdentifiers, |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2231 bool decodeDataUriScheme, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2232 Encoding defaultEncoding, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2233 const std::string& privateCreator) |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2234 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
2235 std::unique_ptr<DcmDataset> result(new DcmDataset); |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2236 Encoding encoding = ExtractEncoding(json, defaultEncoding); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2237 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2238 SetString(*result, DCM_SpecificCharacterSet, GetDicomSpecificCharacterSet(encoding)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2239 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2240 const Json::Value::Members tags = json.getMemberNames(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2241 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2242 bool hasPatientId = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2243 bool hasStudyInstanceUid = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2244 bool hasSeriesInstanceUid = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2245 bool hasSopInstanceUid = false; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2246 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2247 for (size_t i = 0; i < tags.size(); i++) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2248 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2249 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2250 const Json::Value& value = json[tags[i]]; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2251 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2252 if (tag == DICOM_TAG_PATIENT_ID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2253 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2254 hasPatientId = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2255 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2256 else if (tag == DICOM_TAG_STUDY_INSTANCE_UID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2257 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2258 hasStudyInstanceUid = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2259 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2260 else if (tag == DICOM_TAG_SERIES_INSTANCE_UID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2261 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2262 hasSeriesInstanceUid = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2263 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2264 else if (tag == DICOM_TAG_SOP_INSTANCE_UID) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2265 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2266 hasSopInstanceUid = true; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2267 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2268 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2269 if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2270 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
2271 std::unique_ptr<DcmElement> element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); |
4200 | 2272 |
2273 result->findAndDeleteElement(element->getTag()); | |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2274 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2275 DcmElement* tmp = element.release(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2276 if (!result->insert(tmp, false, false).good()) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2277 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2278 delete tmp; |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2279 throw OrthancException(ErrorCode_InternalError); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2280 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2281 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2282 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2283 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2284 if (!hasPatientId && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2285 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2286 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2287 SetString(*result, DCM_PatientID, GenerateUniqueIdentifier(ResourceType_Patient)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2288 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2289 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2290 if (!hasStudyInstanceUid && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2291 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2292 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2293 SetString(*result, DCM_StudyInstanceUID, GenerateUniqueIdentifier(ResourceType_Study)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2294 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2295 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2296 if (!hasSeriesInstanceUid && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2297 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2298 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2299 SetString(*result, DCM_SeriesInstanceUID, GenerateUniqueIdentifier(ResourceType_Series)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2300 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2301 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2302 if (!hasSopInstanceUid && |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2303 generateIdentifiers) |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2304 { |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2305 SetString(*result, DCM_SOPInstanceUID, GenerateUniqueIdentifier(ResourceType_Instance)); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2306 } |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2307 |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2308 return result.release(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1930
diff
changeset
|
2309 } |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2310 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2311 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2312 DcmFileFormat* FromDcmtkBridge::LoadFromMemoryBuffer(const void* buffer, |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2313 size_t size) |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2314 { |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2315 DcmInputBufferStream is; |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2316 if (size > 0) |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2317 { |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2318 is.setBuffer(buffer, size); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2319 } |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2320 is.setEos(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2321 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3708
diff
changeset
|
2322 std::unique_ptr<DcmFileFormat> result(new DcmFileFormat); |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2323 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2324 result->transferInit(); |
3771
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2325 |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2326 /** |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2327 * New in Orthanc 1.6.0: The "size" is given as an argument to the |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2328 * "read()" method. This can avoid huge memory consumption if |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2329 * parsing an invalid DICOM file, which can notably been observed |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2330 * by executing the integration test "test_upload_compressed" on |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2331 * valgrind running Orthanc. |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2332 **/ |
74889e6f6d68
fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3769
diff
changeset
|
2333 if (!result->read(is, EXS_Unknown, EGL_noChange, size).good()) |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2334 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2335 throw OrthancException(ErrorCode_BadFileFormat, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2336 "Cannot parse an invalid DICOM file (size: " + |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2337 boost::lexical_cast<std::string>(size) + " bytes)"); |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2338 } |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2339 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2340 result->loadAllDataIntoMemory(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2341 result->transferEnd(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2342 |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2343 return result.release(); |
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
2344 } |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2345 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2346 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2347 void FromDcmtkBridge::FromJson(DicomMap& target, |
5011
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2348 const Json::Value& source, |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2349 const char* fieldName) |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2350 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2351 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
|
2352 { |
5011
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2353 if (fieldName != NULL) |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2354 { |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2355 throw OrthancException(ErrorCode_BadFileFormat, std::string("Expecting an object in field '") + std::string(fieldName) + std::string("'")); |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2356 } |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2357 else |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2358 { |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2359 throw OrthancException(ErrorCode_BadFileFormat, "Expecting an object"); |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2360 } |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2361 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2362 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2363 target.Clear(); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2364 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2365 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
|
2366 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2367 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
|
2368 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2369 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
|
2370 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2371 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
|
2372 { |
5011
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2373 throw OrthancException(ErrorCode_BadFileFormat, std::string("Expecting a string in field '") + members[i] + std::string("'")); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2374 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2375 |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
2376 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
|
2377 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
2378 } |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2379 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2380 |
5011
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2381 |
c014ab79fca5
fixed /move documentation + improved error reporting
Alain Mazy <am@osimis.io>
parents:
4981
diff
changeset
|
2382 |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2383 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
|
2384 Encoding source, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2385 bool hasSourceCodeExtensions, |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2386 Encoding target) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2387 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2388 // 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
|
2389 // each string-like element |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2390 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2391 if (source == target) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2392 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2393 return; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2394 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2395 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2396 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
|
2397 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2398 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
|
2399 if (element) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2400 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2401 if (element->isLeaf()) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2402 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2403 char *c = NULL; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2404 if (element->isaString() && |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2405 element->getString(c).good() && |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2406 c != NULL) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2407 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2408 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
|
2409 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
|
2410 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
|
2411 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2412 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2413 else |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2414 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2415 // "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
|
2416 // 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
|
2417 // 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
|
2418 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
|
2419 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2420 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
|
2421 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2422 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
|
2423 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2424 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2425 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2426 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2172
diff
changeset
|
2427 } |
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
|
2428 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
2429 |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2430 void FromDcmtkBridge::InitializeCodecs() |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2431 { |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2432 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
2433 CLOG(INFO, DICOM) << "Registering JPEG Lossless codecs in DCMTK"; |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2434 DJLSDecoderRegistration::registerCodecs(); |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2435 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2436 DJLSEncoderRegistration::registerCodecs(); |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2437 # endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2438 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2439 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2440 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
2441 CLOG(INFO, DICOM) << "Registering JPEG codecs in DCMTK"; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2442 DJDecoderRegistration::registerCodecs(); |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2443 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2444 DJEncoderRegistration::registerCodecs(); |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2445 # endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2446 #endif |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2447 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4695
diff
changeset
|
2448 CLOG(INFO, DICOM) << "Registering RLE codecs in DCMTK"; |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2449 DcmRLEDecoderRegistration::registerCodecs(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2450 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2451 DcmRLEEncoderRegistration::registerCodecs(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2452 #endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2453 } |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2454 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2455 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2456 void FromDcmtkBridge::FinalizeCodecs() |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2457 { |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2458 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2459 // Unregister JPEG-LS codecs |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2460 DJLSDecoderRegistration::cleanup(); |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2461 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2462 DJLSEncoderRegistration::cleanup(); |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2463 # endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2464 #endif |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2465 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2466 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2467 // Unregister JPEG codecs |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2468 DJDecoderRegistration::cleanup(); |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2469 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
3743
33c19a6643e1
creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3730
diff
changeset
|
2470 DJEncoderRegistration::cleanup(); |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2471 # endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2472 #endif |
3748
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2473 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2474 DcmRLEDecoderRegistration::cleanup(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2475 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2476 DcmRLEEncoderRegistration::cleanup(); |
ca36e3f1112c
transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3743
diff
changeset
|
2477 #endif |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2364
diff
changeset
|
2478 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2479 |
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 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2482 // Forward declaration |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2483 static bool ApplyVisitorToElement(DcmElement& element, |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2484 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2485 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2486 const std::vector<size_t>& parentIndexes, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2487 Encoding encoding, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2488 bool hasCodeExtensions); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2489 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2490 static void ApplyVisitorToDataset(DcmItem& dataset, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2491 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2492 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2493 const std::vector<size_t>& parentIndexes, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2494 Encoding encoding, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2495 bool hasCodeExtensions) |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2496 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2497 assert(parentTags.size() == parentIndexes.size()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2498 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2499 std::set<DcmTagKey> toRemove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2500 |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2501 for (unsigned long i = 0; i < dataset.card(); i++) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2502 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2503 DcmElement* element = dataset.getElement(i); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2504 if (element == NULL) |
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 throw OrthancException(ErrorCode_InternalError); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2507 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2508 else |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2509 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2510 if (!ApplyVisitorToElement(*element, visitor, parentTags, parentIndexes, encoding, hasCodeExtensions)) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2511 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2512 toRemove.insert(element->getTag()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2513 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2514 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2515 } |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2516 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2517 // Remove all the tags that were planned for removal (cf. ITagVisitor::Action_Remove) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2518 for (std::set<DcmTagKey>::const_iterator |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2519 it = toRemove.begin(); it != toRemove.end(); ++it) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2520 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2521 std::unique_ptr<DcmElement> tmp(dataset.remove(*it)); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2522 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2523 } |
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 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2526 // Returns "true" iff the element must be kept. If "false" is |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2527 // returned, the element will be removed. |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2528 static bool ApplyVisitorToLeaf(DcmElement& element, |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2529 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2530 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2531 const std::vector<size_t>& parentIndexes, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2532 const DicomTag& tag, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2533 Encoding encoding, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2534 bool hasCodeExtensions) |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2535 { |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2536 // 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
|
2537 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2538 assert(element.isLeaf()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2539 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2540 DcmEVR evr = element.getTag().getEVR(); |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2541 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2542 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2543 /** |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2544 * Fix the EVR for types internal to DCMTK |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2545 **/ |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2546 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2547 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
|
2548 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2549 evr = EVR_OB; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2550 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2551 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2552 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
|
2553 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
|
2554 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2555 evr = EVR_UN; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2556 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2557 |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2558 if (evr == EVR_UN) |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2559 { |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2560 // New in Orthanc 1.9.5 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2561 DictionaryLocker locker; |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2562 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2563 const DcmDictEntry* entry = locker->findEntry(element.getTag().getXTag(), |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2564 element.getTag().getPrivateCreator()); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2565 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2566 if (entry != NULL) |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2567 { |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2568 evr = entry->getEVR(); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2569 } |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2570 } |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2571 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2572 const ValueRepresentation vr = FromDcmtkBridge::Convert(evr); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2573 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2574 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2575 /** |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2576 * Deal with binary data (including PixelData). |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2577 **/ |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2578 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2579 if (evr == EVR_OB || // other byte |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2580 evr == EVR_OW || // other word |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2581 evr == EVR_UN) // unknown value representation |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2582 { |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
2583 Uint16* data16 = NULL; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2584 Uint8* data = NULL; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2585 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2586 ITagVisitor::Action action; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2587 |
4528
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2588 if ((element.getTag() == DCM_PixelData || // (*) New in Orthanc 1.9.1 |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2589 evr == EVR_OW) && |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
2590 element.getUint16Array(data16) == EC_Normal) |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
2591 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2592 action = visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data16, element.getLength()); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
2593 } |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
2594 else if (evr != EVR_OW && |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
2595 element.getUint8Array(data) == EC_Normal) |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2596 { |
4528
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2597 /** |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2598 * WARNING: The call to "getUint8Array()" crashes |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2599 * (segmentation fault) on big-endian architectures if applied |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2600 * to pixel data, during the call to "swapIfNecessary()" in |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2601 * "DcmPolymorphOBOW::getUint8Array()" (this method is not |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2602 * reimplemented in derived class "DcmPixelData"). However, |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2603 * "getUint16Array()" works correctly, hence (*). |
93a51d228d80
fix segmentation fault during anonymization on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4527
diff
changeset
|
2604 **/ |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2605 action = visitor.VisitBinary(parentTags, parentIndexes, tag, vr, data, element.getLength()); |
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 else |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2608 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2609 action = visitor.VisitNotSupported(parentTags, parentIndexes, tag, vr); |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2610 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2611 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2612 switch (action) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2613 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2614 case ITagVisitor::Action_None: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2615 return true; // We're done |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2616 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2617 case ITagVisitor::Action_Remove: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2618 return false; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2619 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2620 case ITagVisitor::Action_Replace: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2621 throw OrthancException(ErrorCode_NotImplemented, "Iterator cannot replace binary data"); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2622 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2623 default: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2624 throw OrthancException(ErrorCode_ParameterOutOfRange); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2625 } |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2626 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2627 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2628 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2629 /** |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2630 * 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
|
2631 **/ |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2632 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2633 char *c = NULL; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2634 if (element.isaString() && |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2635 element.getString(c).good()) |
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 std::string utf8; |
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 (c != NULL) // This case corresponds to the empty string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2640 { |
3448
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2641 if (element.getTag() == DCM_SpecificCharacterSet) |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2642 { |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2643 utf8.assign(c); |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2644 } |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2645 else |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2646 { |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2647 std::string s(c); |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2648 utf8 = Toolbox::ConvertToUtf8(s, encoding, hasCodeExtensions); |
b3bdd6dc10f2
don't change encoding of SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3302
diff
changeset
|
2649 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2650 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2651 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2652 std::string newValue; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2653 ITagVisitor::Action action = visitor.VisitString |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2654 (newValue, parentTags, parentIndexes, tag, vr, utf8); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2655 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2656 switch (action) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2657 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2658 case ITagVisitor::Action_None: |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2659 return true; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2660 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2661 case ITagVisitor::Action_Remove: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2662 return false; |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2663 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2664 case ITagVisitor::Action_Replace: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2665 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2666 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
|
2667 if (element.putString(s.c_str()) != EC_Normal) |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2668 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2669 throw OrthancException(ErrorCode_InternalError, |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2670 "Iterator cannot replace value of tag: " + tag.Format()); |
2499
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 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2673 return true; |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2674 } |
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 default: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2677 throw OrthancException(ErrorCode_InternalError); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2678 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2679 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2680 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2681 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2682 ITagVisitor::Action action; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2683 |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2684 try |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2685 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2686 // 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
|
2687 switch (evr) |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2688 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2689 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2690 /** |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2691 * Plain string values. |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2692 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2693 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2694 case EVR_DS: // decimal string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2695 case EVR_IS: // integer string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2696 case EVR_AS: // age string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2697 case EVR_DA: // date string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2698 case EVR_DT: // date time string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2699 case EVR_TM: // time string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2700 case EVR_AE: // application entity title |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2701 case EVR_CS: // code string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2702 case EVR_SH: // short string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2703 case EVR_LO: // long string |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2704 case EVR_ST: // short text |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2705 case EVR_LT: // long text |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2706 case EVR_UT: // unlimited text |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2707 case EVR_PN: // person name |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2708 case EVR_UI: // unique identifier |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2709 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2710 Uint8* data = NULL; |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2711 |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2712 if (element.getUint8Array(data) == EC_Normal) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2713 { |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2714 const Uint32 length = element.getLength(); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2715 Uint32 l = 0; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2716 while (l < length && |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2717 data[l] != 0) |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2718 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2719 l++; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2720 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2721 |
4951
e100fd9db29b
enlarged support of tags with UN value representation in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
2722 std::string ignored; |
e100fd9db29b
enlarged support of tags with UN value representation in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
2723 std::string s(reinterpret_cast<const char*>(data), l); |
e100fd9db29b
enlarged support of tags with UN value representation in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
2724 action = visitor.VisitString(ignored, parentTags, parentIndexes, tag, vr, |
e100fd9db29b
enlarged support of tags with UN value representation in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
2725 Toolbox::ConvertToUtf8(s, encoding, hasCodeExtensions)); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2726 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2727 else |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2728 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2729 action = visitor.VisitNotSupported(parentTags, parentIndexes, tag, vr); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2730 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2731 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2732 if (action == ITagVisitor::Action_Replace) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2733 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2734 LOG(WARNING) << "Iterator cannot replace this string tag: " |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2735 << FromDcmtkBridge::GetTagName(element) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2736 << " (" << tag.Format() << ")"; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2737 return true; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2738 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2739 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2740 break; |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2741 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2742 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2743 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2744 * Numeric types |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2745 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2746 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2747 case EVR_SL: // signed long |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2748 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2749 DcmSignedLong& content = dynamic_cast<DcmSignedLong&>(element); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2750 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2751 std::vector<int64_t> values; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2752 values.reserve(content.getVM()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2753 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2754 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
|
2755 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2756 Sint32 f; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2757 if (content.getSint32(f, i).good()) |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2758 { |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2759 values.push_back(f); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2760 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2761 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2762 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2763 action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2764 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2765 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2766 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2767 case EVR_SS: // signed short |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2768 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2769 DcmSignedShort& content = dynamic_cast<DcmSignedShort&>(element); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2770 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2771 std::vector<int64_t> values; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2772 values.reserve(content.getVM()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2773 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2774 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
|
2775 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2776 Sint16 f; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2777 if (content.getSint16(f, i).good()) |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2778 { |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2779 values.push_back(f); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2780 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2781 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2782 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2783 action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2784 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2785 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2786 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2787 case EVR_UL: // unsigned long |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2788 #if DCMTK_VERSION_NUMBER >= 362 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2789 case EVR_OL: |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2790 #endif |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2791 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2792 DcmUnsignedLong& content = dynamic_cast<DcmUnsignedLong&>(element); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2793 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2794 std::vector<int64_t> values; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2795 values.reserve(content.getVM()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2796 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2797 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
|
2798 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2799 Uint32 f; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2800 if (content.getUint32(f, i).good()) |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2801 { |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2802 values.push_back(f); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2803 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2804 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2805 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2806 action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2807 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2808 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2809 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2810 case EVR_US: // unsigned short |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2811 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2812 DcmUnsignedShort& content = dynamic_cast<DcmUnsignedShort&>(element); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2813 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2814 std::vector<int64_t> values; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2815 values.reserve(content.getVM()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2816 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2817 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
|
2818 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2819 Uint16 f; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2820 if (content.getUint16(f, i).good()) |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2821 { |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2822 values.push_back(f); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2823 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2824 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2825 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2826 action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2827 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2828 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2829 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2830 case EVR_FL: // float single-precision |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2831 case EVR_OF: |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2832 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2833 DcmFloatingPointSingle& content = dynamic_cast<DcmFloatingPointSingle&>(element); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2834 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2835 std::vector<double> values; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2836 values.reserve(content.getVM()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2837 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2838 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
|
2839 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2840 Float32 f; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2841 if (content.getFloat32(f, i).good()) |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2842 { |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2843 values.push_back(f); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2844 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2845 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2846 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2847 action = visitor.VisitDoubles(parentTags, parentIndexes, tag, vr, values); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2848 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2849 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2850 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2851 case EVR_FD: // float double-precision |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2852 #if DCMTK_VERSION_NUMBER >= 361 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2853 case EVR_OD: |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2854 #endif |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2855 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2856 DcmFloatingPointDouble& content = dynamic_cast<DcmFloatingPointDouble&>(element); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2857 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2858 std::vector<double> values; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2859 values.reserve(content.getVM()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2860 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2861 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
|
2862 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2863 Float64 f; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2864 if (content.getFloat64(f, i).good()) |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2865 { |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2866 values.push_back(f); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2867 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2868 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2869 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2870 action = visitor.VisitDoubles(parentTags, parentIndexes, tag, vr, values); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2871 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2872 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2873 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2874 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2875 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2876 * Attribute tag. |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2877 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2878 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2879 case EVR_AT: |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2880 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2881 DcmAttributeTag& content = dynamic_cast<DcmAttributeTag&>(element); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2882 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2883 std::vector<DicomTag> values; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2884 values.reserve(content.getVM()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2885 |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2886 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
|
2887 { |
3194
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2888 DcmTagKey f; |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2889 if (content.getTagVal(f, i).good()) |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2890 { |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2891 DicomTag t(f.getGroup(), f.getElement()); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2892 values.push_back(t); |
47ef29168698
support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3156
diff
changeset
|
2893 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2894 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2895 |
3195 | 2896 assert(vr == ValueRepresentation_AttributeTag); |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2897 action = visitor.VisitAttributes(parentTags, parentIndexes, tag, values); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2898 break; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2899 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2900 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2901 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2902 /** |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2903 * 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
|
2904 * "element.isLeaf()". |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2905 **/ |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2906 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2907 case EVR_SQ: // sequence of items |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2908 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2909 return true; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2910 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2911 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2912 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2913 /** |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2914 * Internal to DCMTK. |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2915 **/ |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2916 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2917 case EVR_xs: // SS or US depending on context |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2918 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
|
2919 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
|
2920 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
|
2921 case EVR_item: // used internally for items |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2922 case EVR_metainfo: // used internally for meta info datasets |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2923 case EVR_dataset: // used internally for datasets |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2924 case EVR_fileFormat: // used internally for DICOM files |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2925 case EVR_dicomDir: // used internally for DICOMDIR objects |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2926 case EVR_dirRecord: // used internally for DICOMDIR records |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2927 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
|
2928 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
|
2929 case EVR_PixelData: // used internally for uncompressed pixeld data |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2930 case EVR_OverlayData: // used internally for overlay data |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2931 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2932 action = visitor.VisitNotSupported(parentTags, parentIndexes, tag, vr); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2933 break; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2934 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2935 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2936 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2937 /** |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2938 * Default case. |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3195
diff
changeset
|
2939 **/ |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2940 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2941 default: |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2942 return true; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2943 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2944 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2945 switch (action) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2946 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2947 case ITagVisitor::Action_None: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2948 return true; // We're done |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2949 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2950 case ITagVisitor::Action_Remove: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2951 return false; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2952 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2953 case ITagVisitor::Action_Replace: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2954 throw OrthancException(ErrorCode_NotImplemented, "Iterator cannot replace non-string-like data"); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2955 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2956 default: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2957 throw OrthancException(ErrorCode_ParameterOutOfRange); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2958 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2959 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2960 catch (boost::bad_lexical_cast&) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2961 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2962 return true; |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2963 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2964 catch (std::bad_cast&) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2965 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2966 return true; |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2967 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2968 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2969 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2970 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2971 // Returns "true" iff the element must be kept. If "false" is |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2972 // returned, the element will be removed. |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2973 static bool ApplyVisitorToElement(DcmElement& element, |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2974 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2975 const std::vector<DicomTag>& parentTags, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2976 const std::vector<size_t>& parentIndexes, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2977 Encoding encoding, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
2978 bool hasCodeExtensions) |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2979 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2980 assert(parentTags.size() == parentIndexes.size()); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2981 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2982 DicomTag tag(FromDcmtkBridge::Convert(element.getTag())); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2983 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2984 if (element.isLeaf()) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2985 { |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4697
diff
changeset
|
2986 return ApplyVisitorToLeaf(element, visitor, parentTags, parentIndexes, tag, encoding, hasCodeExtensions); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2987 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2988 else |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2989 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2990 // "All subclasses of DcmElement except for DcmSequenceOfItems |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2991 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2992 // 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
|
2993 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element); |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
2994 |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2995 ITagVisitor::Action action = visitor.VisitSequence(parentTags, parentIndexes, tag, sequence.card()); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2996 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2997 switch (action) |
3195 | 2998 { |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2999 case ITagVisitor::Action_None: |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3000 if (sequence.card() != 0) // Minor optimization to avoid creating "tags" and "indexes" if not needed |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3001 { |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3002 std::vector<DicomTag> tags = parentTags; |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3003 std::vector<size_t> indexes = parentIndexes; |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3004 tags.push_back(tag); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3005 indexes.push_back(0); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3006 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3007 for (unsigned long i = 0; i < sequence.card(); i++) |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3008 { |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3009 indexes.back() = static_cast<size_t>(i); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3010 DcmItem* child = sequence.getItem(i); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3011 ApplyVisitorToDataset(*child, visitor, tags, indexes, encoding, hasCodeExtensions); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3012 } |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3013 } |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3014 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3015 return true; // Keep |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3016 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3017 case ITagVisitor::Action_Remove: |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3018 return false; |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3019 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3020 case ITagVisitor::Action_Replace: |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3021 throw OrthancException(ErrorCode_NotImplemented, "Iterator cannot replace sequences"); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3022 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3023 default: |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3024 throw OrthancException(ErrorCode_ParameterOutOfRange); |
3195 | 3025 } |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
3026 |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3027 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3028 } |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3029 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3030 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3031 void FromDcmtkBridge::Apply(DcmItem& dataset, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3032 ITagVisitor& visitor, |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3033 Encoding defaultEncoding) |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3034 { |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3035 std::vector<DicomTag> parentTags; |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3036 std::vector<size_t> parentIndexes; |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
3037 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
3038 Encoding encoding = DetectEncoding(hasCodeExtensions, dataset, defaultEncoding); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
3039 ApplyVisitorToDataset(dataset, visitor, parentTags, parentIndexes, encoding, hasCodeExtensions); |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2470
diff
changeset
|
3040 } |
3882
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3041 |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3042 |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3043 |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3044 bool FromDcmtkBridge::LookupOrthancTransferSyntax(DicomTransferSyntax& target, |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3045 DcmFileFormat& dicom) |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3046 { |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3047 if (dicom.getDataset() == NULL) |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3048 { |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3049 throw OrthancException(ErrorCode_InternalError); |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3050 } |
4334
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3051 else |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3052 { |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3053 return LookupOrthancTransferSyntax(target, *dicom.getDataset()); |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3054 } |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3055 } |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3056 |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3057 |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3058 bool FromDcmtkBridge::LookupOrthancTransferSyntax(DicomTransferSyntax& target, |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3059 DcmDataset& dataset) |
b2366bc023f8
Fix access to videos as a single raw frame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
3060 { |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3061 E_TransferSyntax xfer = dataset.getCurrentXfer(); |
3882
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3062 if (xfer == EXS_Unknown) |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3063 { |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3064 dataset.updateOriginalXfer(); |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3065 xfer = dataset.getOriginalXfer(); |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3066 if (xfer == EXS_Unknown) |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3067 { |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3068 throw OrthancException(ErrorCode_BadFileFormat, |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3069 "Cannot determine the transfer syntax of the DICOM instance"); |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3070 } |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3071 } |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3072 |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3073 return FromDcmtkBridge::LookupOrthancTransferSyntax(target, xfer); |
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3881
diff
changeset
|
3074 } |
4501
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3075 |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3076 |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3077 void FromDcmtkBridge::LogMissingTagsForStore(DcmDataset& dicom) |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3078 { |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3079 std::string patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid; |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3080 |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3081 const char* c = NULL; |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3082 if (dicom.findAndGetString(DCM_PatientID, c).good() && |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3083 c != NULL) |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3084 { |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3085 patientId.assign(c); |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3086 } |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3087 |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3088 c = NULL; |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3089 if (dicom.findAndGetString(DCM_StudyInstanceUID, c).good() && |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3090 c != NULL) |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3091 { |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3092 studyInstanceUid.assign(c); |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3093 } |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3094 |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3095 c = NULL; |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3096 if (dicom.findAndGetString(DCM_SeriesInstanceUID, c).good() && |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3097 c != NULL) |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3098 { |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3099 seriesInstanceUid.assign(c); |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3100 } |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3101 |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3102 c = NULL; |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3103 if (dicom.findAndGetString(DCM_SOPInstanceUID, c).good() && |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3104 c != NULL) |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3105 { |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3106 sopInstanceUid.assign(c); |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3107 } |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3108 |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3109 DicomMap::LogMissingTagsForStore(patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid); |
11c2ddb4e2ca
FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
3110 } |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3111 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3112 |
4770
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3113 void FromDcmtkBridge::IDicomPathVisitor::ApplyInternal(FromDcmtkBridge::IDicomPathVisitor& visitor, |
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3114 DcmItem& item, |
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3115 const DicomPath& pattern, |
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3116 const DicomPath& actualPath) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3117 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3118 const size_t level = actualPath.GetPrefixLength(); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3119 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3120 if (level == pattern.GetPrefixLength()) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3121 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3122 visitor.Visit(item, actualPath); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3123 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3124 else |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3125 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3126 assert(level < pattern.GetPrefixLength()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3127 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3128 const DicomTag& tmp = pattern.GetPrefixTag(level); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3129 DcmTagKey tag(tmp.GetGroup(), tmp.GetElement()); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3130 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3131 DcmSequenceOfItems *sequence = NULL; |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3132 if (item.findAndGetSequence(tag, sequence).good() && |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3133 sequence != NULL) |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3134 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3135 for (unsigned long i = 0; i < sequence->card(); i++) |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3136 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3137 if (pattern.IsPrefixUniversal(level) || |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3138 pattern.GetPrefixIndex(level) == static_cast<size_t>(i)) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3139 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3140 DcmItem *child = sequence->getItem(i); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3141 if (child != NULL) |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3142 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3143 DicomPath childPath = actualPath; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3144 childPath.AddIndexedTagToPrefix(pattern.GetPrefixTag(level), static_cast<size_t>(i)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3145 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3146 ApplyInternal(visitor, *child, pattern, childPath); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3147 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3148 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3149 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3150 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3151 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3152 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3153 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3154 |
4770
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3155 void FromDcmtkBridge::IDicomPathVisitor::Apply(IDicomPathVisitor& visitor, |
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3156 DcmDataset& dataset, |
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3157 const DicomPath& path) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3158 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3159 DicomPath actualPath(path.GetFinalTag()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3160 ApplyInternal(visitor, dataset, path, actualPath); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3161 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3162 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3163 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3164 void FromDcmtkBridge::RemovePath(DcmDataset& dataset, |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3165 const DicomPath& path) |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3166 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3167 class Visitor : public FromDcmtkBridge::IDicomPathVisitor |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3168 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3169 public: |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3170 virtual void Visit(DcmItem& item, |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3171 const DicomPath& path) ORTHANC_OVERRIDE |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3172 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3173 DcmTagKey key(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3174 std::unique_ptr<DcmElement> removed(item.remove(key)); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3175 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3176 }; |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3177 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3178 Visitor visitor; |
4770
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3179 IDicomPathVisitor::Apply(visitor, dataset, path); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3180 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3181 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3182 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3183 void FromDcmtkBridge::ClearPath(DcmDataset& dataset, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3184 const DicomPath& path, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3185 bool onlyIfExists) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3186 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3187 class Visitor : public FromDcmtkBridge::IDicomPathVisitor |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3188 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3189 public: |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3190 bool onlyIfExists_; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3191 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3192 public: |
4690 | 3193 explicit Visitor(bool onlyIfExists) : |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3194 onlyIfExists_(onlyIfExists) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3195 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3196 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3197 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3198 virtual void Visit(DcmItem& item, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3199 const DicomPath& path) ORTHANC_OVERRIDE |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3200 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3201 DcmTagKey key(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3202 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3203 if (onlyIfExists_ && |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3204 !item.tagExists(key)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3205 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3206 // The tag is non-existing, do not clear it |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3207 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3208 else |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3209 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3210 if (!item.insertEmptyElement(key, OFTrue /* replace old value */).good()) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3211 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3212 throw OrthancException(ErrorCode_InternalError); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3213 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3214 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3215 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3216 }; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3217 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3218 Visitor visitor(onlyIfExists); |
4770
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3219 IDicomPathVisitor::Apply(visitor, dataset, path); |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3220 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3221 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3222 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3223 void FromDcmtkBridge::ReplacePath(DcmDataset& dataset, |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3224 const DicomPath& path, |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3225 const DcmElement& element, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3226 DicomReplaceMode mode) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3227 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3228 class Visitor : public FromDcmtkBridge::IDicomPathVisitor |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3229 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3230 private: |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3231 std::unique_ptr<DcmElement> element_; |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3232 DicomReplaceMode mode_; |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3233 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3234 public: |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3235 Visitor(const DcmElement& element, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3236 DicomReplaceMode mode) : |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3237 element_(dynamic_cast<DcmElement*>(element.clone())), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3238 mode_(mode) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3239 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3240 if (element_.get() == NULL) |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3241 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3242 throw OrthancException(ErrorCode_InternalError, "Cannot clone DcmElement"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3243 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3244 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3245 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3246 virtual void Visit(DcmItem& item, |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3247 const DicomPath& path) ORTHANC_OVERRIDE |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3248 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3249 std::unique_ptr<DcmElement> cloned(dynamic_cast<DcmElement*>(element_->clone())); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3250 if (cloned.get() == NULL) |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3251 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3252 throw OrthancException(ErrorCode_InternalError, "Cannot clone DcmElement"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3253 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3254 else |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3255 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3256 DcmTagKey key(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3257 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3258 if (!item.tagExists(key)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3259 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3260 switch (mode_) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3261 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3262 case DicomReplaceMode_InsertIfAbsent: |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3263 break; // Fine, we can proceed with insertion |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3264 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3265 case DicomReplaceMode_ThrowIfAbsent: |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3266 throw OrthancException(ErrorCode_InexistentItem, "Cannot replace inexistent tag: " + GetTagName(*element_)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3267 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3268 case DicomReplaceMode_IgnoreIfAbsent: |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3269 return; // Don't proceed with insertion |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3270 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3271 default: |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3272 throw OrthancException(ErrorCode_ParameterOutOfRange); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3273 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3274 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3275 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3276 if (!item.insert(cloned.release(), OFTrue /* replace old */).good()) |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3277 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3278 throw OrthancException(ErrorCode_InternalError, "Cannot replace an element: " + GetTagName(*element_)); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3279 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3280 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3281 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3282 }; |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3283 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3284 DcmTagKey key(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3285 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3286 if (element.getTag() != key) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3287 { |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3288 throw OrthancException(ErrorCode_ParameterOutOfRange, |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3289 "The final tag must be the same as the tag of the element during a replacement"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3290 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3291 else |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3292 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
3293 Visitor visitor(element, mode); |
4770
248408d2b336
hiding FromDcmtkBridge::Apply() on IDicomPathVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
3294 IDicomPathVisitor::Apply(visitor, dataset, path); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3295 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4663
diff
changeset
|
3296 } |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3297 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3298 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3299 bool FromDcmtkBridge::LookupSequenceItem(DicomMap& target, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3300 DcmDataset& dataset, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3301 const DicomPath& path, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3302 size_t sequenceIndex) |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3303 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3304 class Visitor : public FromDcmtkBridge::IDicomPathVisitor |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3305 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3306 private: |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3307 bool found_; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3308 DicomMap& target_; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3309 size_t sequenceIndex_; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3310 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3311 public: |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3312 Visitor(DicomMap& target, |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3313 size_t sequenceIndex) : |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3314 found_(false), |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3315 target_(target), |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3316 sequenceIndex_(sequenceIndex) |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3317 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3318 } |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3319 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3320 virtual void Visit(DcmItem& item, |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3321 const DicomPath& path) ORTHANC_OVERRIDE |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3322 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3323 DcmTagKey tag(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3324 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3325 DcmSequenceOfItems *sequence = NULL; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3326 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3327 if (item.findAndGetSequence(tag, sequence).good() && |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3328 sequence != NULL && |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3329 sequenceIndex_ < sequence->card()) |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3330 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3331 std::set<DicomTag> ignoreTagLength; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3332 ExtractDicomSummary(target_, *sequence->getItem(sequenceIndex_), 0, ignoreTagLength); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3333 found_ = true; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3334 } |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3335 } |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3336 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3337 bool HasFound() const |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3338 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3339 return found_; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3340 } |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3341 }; |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3342 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3343 Visitor visitor(target, sequenceIndex); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3344 IDicomPathVisitor::Apply(visitor, dataset, path); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3345 return visitor.HasFound(); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4770
diff
changeset
|
3346 } |
4953
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3347 |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3348 |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3349 bool FromDcmtkBridge::LookupStringValue(std::string& target, |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3350 DcmDataset& dataset, |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3351 const DicomTag& key) |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3352 { |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3353 DcmTagKey dcmkey(key.GetGroup(), key.GetElement()); |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3354 |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3355 const char* str = NULL; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3356 const Uint8* data = NULL; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3357 unsigned long size = 0; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3358 |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3359 if (dataset.findAndGetString(dcmkey, str).good() && |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3360 str != NULL) |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3361 { |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3362 target.assign(str); |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3363 return true; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3364 } |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3365 else if (dataset.findAndGetUint8Array(dcmkey, data, &size).good() && |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3366 data != NULL && |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3367 size > 0) |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3368 { |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3369 /** |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3370 * This special case is necessary for borderline DICOM files |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3371 * that have DICOM tags have the "UN" value representation. New |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3372 * in Orthanc 1.10.1. |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3373 * https://groups.google.com/g/orthanc-users/c/86fobx3ZyoM/m/KBG17un6AQAJ |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3374 **/ |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3375 unsigned long l = 0; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3376 while (l < size && |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3377 data[l] != 0) |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3378 { |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3379 l++; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3380 } |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3381 |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3382 target.assign(reinterpret_cast<const char*>(data), l); |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3383 return true; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3384 } |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3385 else |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3386 { |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3387 return false; |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3388 } |
60cb4b379485
added FromDcmtkBridge::LookupStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4951
diff
changeset
|
3389 } |
0 | 3390 } |
3730
ae31ba2b09a6
toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3727
diff
changeset
|
3391 |
ae31ba2b09a6
toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3727
diff
changeset
|
3392 |
ae31ba2b09a6
toolbox: LookupTransferSyntax()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3727
diff
changeset
|
3393 #include "./FromDcmtkBridge_TransferSyntaxes.impl.h" |