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