annotate OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 4706:dbee8bd8ee1f

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