annotate OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 5560:c80dbbae3f60

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