annotate OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 4268:0ae2ca210077

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