annotate OrthancServer/FromDcmtkBridge.cpp @ 2244:a3a65de1840f

shared copyright with osimis
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Jan 2017 12:09:40 +0100
parents 3dd44baebc36
children e7a590cf72f9
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
2244
a3a65de1840f shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2232
diff changeset
5 * Copyright (C) 2017 Osimis, 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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
11 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
12 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
13 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
16 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
20 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
21 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
22 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * 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
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
448
9d830dcc7730 missing copyright information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 419
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "PrecompiledHeadersServer.h"
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
35
71
aa65ced5f0f0 fix for visual studio
jodogne
parents: 62
diff changeset
36 #ifndef NOMINMAX
aa65ced5f0f0 fix for visual studio
jodogne
parents: 62
diff changeset
37 #define NOMINMAX
aa65ced5f0f0 fix for visual studio
jodogne
parents: 62
diff changeset
38 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include "FromDcmtkBridge.h"
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
41 #include "ToDcmtkBridge.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
42 #include "../Core/Logging.h"
2172
84d1d392a9ab GenerateUuid() not available in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2152
diff changeset
43 #include "../Core/SystemToolbox.h"
107
3b45473c0a73 replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 106
diff changeset
44 #include "../Core/Toolbox.h"
2142
5a8840920121 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
45 #include "../Core/TemporaryFile.h"
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
46 #include "../Core/OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
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>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
1927
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1924
diff changeset
55 #include <dcmtk/dcmdata/dcdeftag.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 #include <dcmtk/dcmdata/dcdicent.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 #include <dcmtk/dcmdata/dcdict.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 #include <dcmtk/dcmdata/dcfilefo.h>
1927
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1924
diff changeset
59 #include <dcmtk/dcmdata/dcostrmb.h>
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1924
diff changeset
60 #include <dcmtk/dcmdata/dcpixel.h>
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
61 #include <dcmtk/dcmdata/dcuid.h>
1935
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
62 #include <dcmtk/dcmdata/dcistrmb.h>
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
63
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
64 #include <dcmtk/dcmdata/dcvrae.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
65 #include <dcmtk/dcmdata/dcvras.h>
1927
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1924
diff changeset
66 #include <dcmtk/dcmdata/dcvrat.h>
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
67 #include <dcmtk/dcmdata/dcvrcs.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
68 #include <dcmtk/dcmdata/dcvrda.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
69 #include <dcmtk/dcmdata/dcvrds.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
70 #include <dcmtk/dcmdata/dcvrdt.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 #include <dcmtk/dcmdata/dcvrfd.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 #include <dcmtk/dcmdata/dcvrfl.h>
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
73 #include <dcmtk/dcmdata/dcvris.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
74 #include <dcmtk/dcmdata/dcvrlo.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
75 #include <dcmtk/dcmdata/dcvrlt.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
76 #include <dcmtk/dcmdata/dcvrpn.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
77 #include <dcmtk/dcmdata/dcvrsh.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 #include <dcmtk/dcmdata/dcvrsl.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 #include <dcmtk/dcmdata/dcvrss.h>
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
80 #include <dcmtk/dcmdata/dcvrst.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
81 #include <dcmtk/dcmdata/dcvrtm.h>
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
82 #include <dcmtk/dcmdata/dcvrui.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 #include <dcmtk/dcmdata/dcvrul.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 #include <dcmtk/dcmdata/dcvrus.h>
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
85 #include <dcmtk/dcmdata/dcvrut.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
682
efc4928be6fb Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 677
diff changeset
87
1930
1c147c3c3121 fix static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
88 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1
1c147c3c3121 fix static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
89 #include <EmbeddedResources.h>
1c147c3c3121 fix static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
90 #endif
1c147c3c3121 fix static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
91
1c147c3c3121 fix static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
92
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
93 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
95 static inline uint16_t GetCharValue(char c)
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
96 {
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
97 if (c >= '0' && c <= '9')
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
98 return c - '0';
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
99 else if (c >= 'a' && c <= 'f')
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
100 return c - 'a' + 10;
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
101 else if (c >= 'A' && c <= 'F')
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
102 return c - 'A' + 10;
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
103 else
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
104 return 0;
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
105 }
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
106
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
107 static inline uint16_t GetTagValue(const char* c)
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
108 {
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
109 return ((GetCharValue(c[0]) << 12) +
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
110 (GetCharValue(c[1]) << 8) +
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
111 (GetCharValue(c[2]) << 4) +
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
112 GetCharValue(c[3]));
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
113 }
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 176
diff changeset
114
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
115
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
116 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
117 static void LoadEmbeddedDictionary(DcmDataDictionary& dictionary,
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
118 EmbeddedResources::FileResourceId resource)
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
119 {
2017
08ce34cfacad refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
120 std::string content;
08ce34cfacad refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
121 EmbeddedResources::GetFileResource(content, resource);
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
122
2143
fd5875662670 creation of namespace SystemToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
123 TemporaryFile tmp;
2017
08ce34cfacad refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
124 tmp.Write(content);
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
125
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
126 if (!dictionary.loadDictionary(tmp.GetPath().c_str()))
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
127 {
2017
08ce34cfacad refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
128 LOG(ERROR) << "Cannot read embedded dictionary. Under Windows, make sure that "
08ce34cfacad refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
129 << "your TEMP directory does not contain special characters.";
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
130 throw OrthancException(ErrorCode_InternalError);
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
131 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
132 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
133
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
134 #else
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
135 static void LoadExternalDictionary(DcmDataDictionary& dictionary,
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
136 const std::string& directory,
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
137 const std::string& filename)
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
138 {
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
139 boost::filesystem::path p = directory;
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
140 p = p / filename;
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
141
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
142 LOG(WARNING) << "Loading the external DICOM dictionary " << p;
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
143
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
144 if (!dictionary.loadDictionary(p.string().c_str()))
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
145 {
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
146 throw OrthancException(ErrorCode_InternalError);
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
147 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
148 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
149 #endif
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
150
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
151
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
152 namespace
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
153 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
154 class DictionaryLocker
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
155 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
156 private:
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
157 DcmDataDictionary& dictionary_;
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
158
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
159 public:
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
160 DictionaryLocker() : dictionary_(dcmDataDict.wrlock())
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
161 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
162 }
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
163
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
164 ~DictionaryLocker()
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
165 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
166 dcmDataDict.unlock();
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
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
169 DcmDataDictionary& operator*()
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 return dictionary_;
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
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
174 DcmDataDictionary* operator->()
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
175 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
176 return &dictionary_;
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
177 }
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
178 };
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
179 }
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
180
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
181
2151
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
182 void FromDcmtkBridge::InitializeDictionary(bool loadPrivateDictionary)
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
183 {
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
184 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
185 DictionaryLocker locker;
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 locker->clear();
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
188
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
189 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
190 LOG(WARNING) << "Loading the embedded dictionaries";
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
191 /**
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
192 * 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
193 * 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
194 * dictionary is not loaded by storescu.
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
195 **/
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
196 //LoadEmbeddedDictionary(*locker, EmbeddedResources::DICTIONARY_DICONDE);
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
197
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
198 LoadEmbeddedDictionary(*locker, EmbeddedResources::DICTIONARY_DICOM);
2151
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
199
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
200 if (loadPrivateDictionary)
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
201 {
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
202 LOG(INFO) << "Loading the embedded dictionary of private tags";
2151
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
203 LoadEmbeddedDictionary(*locker, EmbeddedResources::DICTIONARY_PRIVATE);
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
204 }
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
205 else
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
206 {
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
207 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
208 }
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
209
1976
325772dadcd6 Macro "__linux" (now obsolete) replaced by macro "__linux__"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1936
diff changeset
210 #elif defined(__linux__) || defined(__FreeBSD_kernel__)
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
211 std::string path = DCMTK_DICTIONARY_DIR;
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
212
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
213 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
214 if (env != NULL)
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
215 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
216 path = std::string(env);
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
217 }
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
218
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
219 LoadExternalDictionary(*locker, path, "dicom.dic");
2151
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
220
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
221 if (loadPrivateDictionary)
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
222 {
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
223 LoadExternalDictionary(*locker, path, "private.dic");
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
224 }
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
225 else
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
226 {
8cbb55089a1d New configuration option: "LoadPrivateDictionary"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
227 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
228 }
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
229
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
230 #else
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
231 #error Support your platform here
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
232 #endif
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
233 }
1656
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
234
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
235 /* make sure data dictionary is loaded */
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
236 if (!dcmDataDict.isDictionaryLoaded())
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
237 {
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
238 LOG(ERROR) << "No DICOM dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE;
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
239 throw OrthancException(ErrorCode_InternalError);
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
240 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
241
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
242 {
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
243 // Test the dictionary with a simple DICOM tag
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
244 DcmTag key(0x0010, 0x1030); // This is PatientWeight
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
245 if (key.getEVR() != EVR_DS)
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
246 {
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
247 LOG(ERROR) << "The DICOM dictionary has not been correctly read";
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
248 throw OrthancException(ErrorCode_InternalError);
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
249 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
250 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
251 }
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
252
d3ba98d6b6e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
253
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
254 void FromDcmtkBridge::RegisterDictionaryTag(const DicomTag& tag,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
255 ValueRepresentation vr,
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
256 const std::string& name,
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
257 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
258 unsigned int maxMultiplicity,
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
259 const std::string& privateCreator)
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
260 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
261 if (minMultiplicity < 1)
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
262 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
263 throw OrthancException(ErrorCode_ParameterOutOfRange);
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
264 }
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
265
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
266 bool arbitrary = false;
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
267 if (maxMultiplicity == 0)
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
268 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
269 maxMultiplicity = DcmVariableVM;
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
270 arbitrary = true;
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
271 }
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
272 else if (maxMultiplicity < minMultiplicity)
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
273 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
274 throw OrthancException(ErrorCode_ParameterOutOfRange);
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
275 }
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
276
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
277 DcmEVR evr = ToDcmtkBridge::Convert(vr);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
278
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
279 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
280 << name << " (multiplicity: " << minMultiplicity << "-"
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
281 << (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
282
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
283 std::auto_ptr<DcmDictEntry> entry;
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
284 if (privateCreator.empty())
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
285 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
286 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
287 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
288 char buf[128];
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
289 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
290 "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
291 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
292 LOG(WARNING) << buf;
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
293 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
294
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
295 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
296 tag.GetElement(),
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
297 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
298 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
299 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
300 NULL /* version */,
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
301 OFTrue /* doCopyString */,
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
302 NULL /* private creator */));
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
303 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
304 else
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
305 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
306 // "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
307 // (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
308 // (FFFF,eeee)."
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
309 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
310 tag.GetGroup() == 0x0001 ||
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
311 tag.GetGroup() == 0x0003 ||
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
312 tag.GetGroup() == 0x0005 ||
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
313 tag.GetGroup() == 0x0007 ||
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
314 tag.GetGroup() == 0xffff)
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
315 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
316 char buf[128];
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
317 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
318 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
319 LOG(ERROR) << buf;
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
320 throw OrthancException(ErrorCode_ParameterOutOfRange);
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
321 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
322
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
323 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
324 tag.GetElement(),
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
325 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
326 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
327 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
328 "private" /* version */,
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
329 OFTrue /* doCopyString */,
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
330 privateCreator.c_str()));
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
331 }
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
332
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
333 entry->setGroupRangeRestriction(DcmDictRange_Unspecified);
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
334 entry->setElementRangeRestriction(DcmDictRange_Unspecified);
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 {
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
337 DictionaryLocker locker;
2116
2fabd1073728 prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
338
2fabd1073728 prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
339 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
340 {
2fabd1073728 prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
341 LOG(ERROR) << "Cannot register two tags with the same symbolic name \"" << name << "\"";
2fabd1073728 prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
342 throw OrthancException(ErrorCode_AlreadyExistingTag);
2fabd1073728 prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
343 }
2fabd1073728 prevent registering two tags with the same symbolic name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
344
1657
5360cdba70d8 New function "OrthancPluginRegisterDictionaryTag()" to declare DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1656
diff changeset
345 locker->addEntry(entry.release());
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 }
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
1936
dba0db0a94b4 generalization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
350 Encoding FromDcmtkBridge::DetectEncoding(DcmItem& dataset,
1928
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
351 Encoding defaultEncoding)
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
352 {
1928
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
353 Encoding encoding = defaultEncoding;
957
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
354
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
355 OFString tmp;
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
356 if (dataset.findAndGetOFString(DCM_SpecificCharacterSet, tmp).good())
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
357 {
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
358 std::string characterSet = Toolbox::StripSpaces(std::string(tmp.c_str()));
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
359
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
360 if (characterSet.empty())
957
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
361 {
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
362 // Empty specific character set tag: Use the default encoding
1087
e07b90fb00eb more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1086
diff changeset
363 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
364 else if (GetDicomEncoding(encoding, characterSet.c_str()))
1087
e07b90fb00eb more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1086
diff changeset
365 {
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
366 // The specific character set is supported by the Orthanc core
1087
e07b90fb00eb more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1086
diff changeset
367 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
368 else
1087
e07b90fb00eb more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1086
diff changeset
369 {
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
370 LOG(WARNING) << "Value of Specific Character Set (0008,0005) is not supported: " << characterSet
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
371 << ", fallback to ASCII (remove all special characters)";
957
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
372 encoding = Encoding_Ascii;
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
373 }
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
374 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
375 else
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
376 {
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
377 // No specific character set tag: Use the default encoding
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1087
diff changeset
378 }
957
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
379
63973b76a51f detection of encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
380 return encoding;
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
381 }
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
382
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
383
2125
b9bd52c72ba2 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2116
diff changeset
384 void FromDcmtkBridge::ExtractDicomSummary(DicomMap& target,
b9bd52c72ba2 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2116
diff changeset
385 DcmItem& dataset,
b9bd52c72ba2 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2116
diff changeset
386 unsigned int maxStringLength,
b9bd52c72ba2 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2116
diff changeset
387 Encoding defaultEncoding)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 {
1928
84c7eaeb5244 Configuration::GetDefaultEncoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1927
diff changeset
389 Encoding encoding = DetectEncoding(dataset, defaultEncoding);
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
390
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 target.Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 for (unsigned long i = 0; i < dataset.card(); i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 DcmElement* element = dataset.getElement(i);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 if (element && element->isLeaf())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 target.SetValue(element->getTag().getGTag(),
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 element->getTag().getETag(),
1929
cda5b0ab4ce5 ORTHANC_MAXIMUM_TAG_LENGTH made explicit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1928
diff changeset
399 ConvertLeafElement(*element, DicomToJsonFlags_Default, maxStringLength, encoding));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 957
diff changeset
405 DicomTag FromDcmtkBridge::Convert(const DcmTag& tag)
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 957
diff changeset
406 {
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 957
diff changeset
407 return DicomTag(tag.getGTag(), tag.getETag());
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 957
diff changeset
408 }
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 957
diff changeset
409
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 957
diff changeset
410
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 DicomTag FromDcmtkBridge::GetTag(const DcmElement& element)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 return DicomTag(element.getGTag(), element.getETag());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
417 DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element,
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
418 DicomToJsonFlags flags,
1929
cda5b0ab4ce5 ORTHANC_MAXIMUM_TAG_LENGTH made explicit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1928
diff changeset
419 unsigned int maxStringLength,
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
420 Encoding encoding)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 if (!element.isLeaf())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 {
1582
bd1889029cbb encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
424 // This function is only applicable to leaf elements
bd1889029cbb encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
425 throw OrthancException(ErrorCode_BadParameterType);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
428 char *c = NULL;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
429 if (element.isaString() &&
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
430 element.getString(c).good())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
432 if (c == NULL) // This case corresponds to the empty string
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 {
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
434 return new DicomValue("", false);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 {
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
438 std::string s(c);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
439 std::string utf8 = Toolbox::ConvertToUtf8(s, encoding);
1854
e2c3d752ee1a prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1831
diff changeset
440
1929
cda5b0ab4ce5 ORTHANC_MAXIMUM_TAG_LENGTH made explicit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1928
diff changeset
441 if (maxStringLength != 0 &&
cda5b0ab4ce5 ORTHANC_MAXIMUM_TAG_LENGTH made explicit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1928
diff changeset
442 utf8.size() > maxStringLength)
1854
e2c3d752ee1a prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1831
diff changeset
443 {
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
444 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
445 }
e2c3d752ee1a prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1831
diff changeset
446 else
e2c3d752ee1a prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1831
diff changeset
447 {
e2c3d752ee1a prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1831
diff changeset
448 return new DicomValue(utf8, false);
e2c3d752ee1a prevent too long tags to be inserted
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1831
diff changeset
449 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452
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
453
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
454 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
455 {
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
456 // 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
457 // 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
458 // "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
459 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
460
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
461 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
462 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
463 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
464 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
465 {
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
466 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
467
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
468 // 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
469 // 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
470 // 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
471
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
472 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
473 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
474 {
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
475 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
476 {
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
477 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
478 }
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
479 else if (maxStringLength != 0 &&
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
480 element.getLength() > maxStringLength)
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
481 {
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
482 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
483 }
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
484 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
485 {
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
486 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
487 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
488 }
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
489 }
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
490 }
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
491 }
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
492
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
493
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 try
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 // http://support.dcmtk.org/docs/dcvr_8h-source.html
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 switch (element.getVR())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 /**
1738
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
501 * Deal with binary data (including PixelData).
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 **/
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
503
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
504 case EVR_OB: // other byte
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
505 case EVR_OF: // other float
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
506 case EVR_OW: // other word
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
507 case EVR_UN: // unknown value representation
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
508 case EVR_ox: // OB or OW depending on context
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
509 case EVR_DS: // decimal string
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
510 case EVR_IS: // integer string
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
511 case EVR_AS: // age string
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
512 case EVR_DA: // date string
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
513 case EVR_DT: // date time string
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
514 case EVR_TM: // time string
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
515 case EVR_AE: // application entity title
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
516 case EVR_CS: // code string
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
517 case EVR_SH: // short string
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
518 case EVR_LO: // long string
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
519 case EVR_ST: // short text
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
520 case EVR_LT: // long text
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
521 case EVR_UT: // unlimited text
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
522 case EVR_PN: // person name
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
523 case EVR_UI: // unique identifier
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
524 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
525 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
526 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
527 if (!(flags & DicomToJsonFlags_ConvertBinaryToNull))
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
528 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
529 Uint8* data = NULL;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
530 if (element.getUint8Array(data) == EC_Normal)
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
531 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
532 return new DicomValue(reinterpret_cast<const char*>(data), element.getLength(), true);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
533 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
534 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
536 return new DicomValue;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
537 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
538
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
539 /**
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
540 * Numeric types
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
541 **/
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
543 case EVR_SL: // signed long
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
544 {
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
545 Sint32 f;
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
546 if (dynamic_cast<DcmSignedLong&>(element).getSint32(f).good())
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
547 return new DicomValue(boost::lexical_cast<std::string>(f), false);
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
548 else
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
549 return new DicomValue;
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
550 }
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
551
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
552 case EVR_SS: // signed short
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
553 {
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
554 Sint16 f;
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
555 if (dynamic_cast<DcmSignedShort&>(element).getSint16(f).good())
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
556 return new DicomValue(boost::lexical_cast<std::string>(f), false);
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
557 else
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
558 return new DicomValue;
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
559 }
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
560
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
561 case EVR_UL: // unsigned long
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
562 {
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
563 Uint32 f;
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
564 if (dynamic_cast<DcmUnsignedLong&>(element).getUint32(f).good())
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
565 return new DicomValue(boost::lexical_cast<std::string>(f), false);
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
566 else
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
567 return new DicomValue;
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
568 }
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
569
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
570 case EVR_US: // unsigned short
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
571 {
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
572 Uint16 f;
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
573 if (dynamic_cast<DcmUnsignedShort&>(element).getUint16(f).good())
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
574 return new DicomValue(boost::lexical_cast<std::string>(f), false);
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
575 else
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
576 return new DicomValue;
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
577 }
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
578
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
579 case EVR_FL: // float single-precision
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
580 {
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
581 Float32 f;
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
582 if (dynamic_cast<DcmFloatingPointSingle&>(element).getFloat32(f).good())
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
583 return new DicomValue(boost::lexical_cast<std::string>(f), false);
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
584 else
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
585 return new DicomValue;
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
586 }
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
587
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
588 case EVR_FD: // float double-precision
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
589 {
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
590 Float64 f;
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
591 if (dynamic_cast<DcmFloatingPointDouble&>(element).getFloat64(f).good())
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
592 return new DicomValue(boost::lexical_cast<std::string>(f), false);
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
593 else
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
594 return new DicomValue;
1131
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
595 }
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
596
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
597
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
598 /**
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
599 * Attribute tag.
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
600 **/
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
601
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
602 case EVR_AT:
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
603 {
1147
ae9a83a6fa47 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1131
diff changeset
604 DcmTagKey tag;
ae9a83a6fa47 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1131
diff changeset
605 if (dynamic_cast<DcmAttributeTag&>(element).getTagVal(tag, 0).good())
ae9a83a6fa47 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1131
diff changeset
606 {
ae9a83a6fa47 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1131
diff changeset
607 DicomTag t(tag.getGroup(), tag.getElement());
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
608 return new DicomValue(t.Format(), false);
1147
ae9a83a6fa47 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1131
diff changeset
609 }
1131
ac6bd50a8c83 fix issue 16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1093
diff changeset
610 else
1147
ae9a83a6fa47 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1131
diff changeset
611 {
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
612 return new DicomValue;
1147
ae9a83a6fa47 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1131
diff changeset
613 }
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
614 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 /**
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
618 * 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
619 * "element.isLeaf()".
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
620 **/
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
622 case EVR_SQ: // sequence of items
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
623 return new DicomValue;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
626 /**
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
627 * Internal to DCMTK.
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
628 **/
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
630 case EVR_xs: // SS or US depending on context
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
631 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
632 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
633 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
634 case EVR_item: // used internally for items
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
635 case EVR_metainfo: // used internally for meta info datasets
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
636 case EVR_dataset: // used internally for datasets
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
637 case EVR_fileFormat: // used internally for DICOM files
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
638 case EVR_dicomDir: // used internally for DICOMDIR objects
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
639 case EVR_dirRecord: // used internally for DICOMDIR records
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
640 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
641 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
642 case EVR_PixelData: // used internally for uncompressed pixeld data
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
643 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
644 return new DicomValue;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
647 /**
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
648 * Default case.
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
649 **/
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
651 default:
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
652 return new DicomValue;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 catch (boost::bad_lexical_cast)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 {
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
657 return new DicomValue;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 }
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
659 catch (std::bad_cast)
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
660 {
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
661 return new DicomValue;
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
662 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
666 static Json::Value& PrepareNode(Json::Value& parent,
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
667 DcmElement& element,
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
668 DicomToJsonFormat format)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 {
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
670 assert(parent.type() == Json::objectValue);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671
35
f6d12037f886 full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
672 DicomTag tag(FromDcmtkBridge::GetTag(element));
305
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
673 const std::string formattedTag = tag.Format();
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
674
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
675 if (format == DicomToJsonFormat_Short)
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
676 {
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
677 parent[formattedTag] = Json::nullValue;
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
678 return parent[formattedTag];
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
679 }
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
680
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
681 // 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
682 std::string tagName = FromDcmtkBridge::GetTagName(element);
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
683
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
684 switch (format)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 {
1860
c7d70f659190 DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1854
diff changeset
686 case DicomToJsonFormat_Human:
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
687 parent[tagName] = Json::nullValue;
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
688 return parent[tagName];
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
689
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
690 case DicomToJsonFormat_Full:
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
691 {
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
692 parent[formattedTag] = Json::objectValue;
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
693 Json::Value& node = parent[formattedTag];
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
694
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
695 if (element.isLeaf())
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
696 {
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
697 node["Name"] = tagName;
35
f6d12037f886 full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
698
2076
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2074
diff changeset
699 if (element.getTag().getPrivateCreator() != NULL)
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
700 {
2076
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2074
diff changeset
701 node["PrivateCreator"] = element.getTag().getPrivateCreator();
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
702 }
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
703
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
704 return node;
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
705 }
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
706 else
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
707 {
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
708 node["Name"] = tagName;
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
709 node["Type"] = "Sequence";
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
710 node["Value"] = Json::nullValue;
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
711 return node["Value"];
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
712 }
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
713 }
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
714
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
715 default:
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
716 throw OrthancException(ErrorCode_ParameterOutOfRange);
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
717 }
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
718 }
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
719
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
720
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
721 static void LeafValueToJson(Json::Value& target,
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
722 const DicomValue& value,
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
723 DicomToJsonFormat format,
1738
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
724 DicomToJsonFlags flags,
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
725 unsigned int maxStringLength)
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
726 {
1738
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
727 Json::Value* targetValue = NULL;
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
728 Json::Value* targetType = NULL;
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
729
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
730 switch (format)
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
731 {
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
732 case DicomToJsonFormat_Short:
1860
c7d70f659190 DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1854
diff changeset
733 case DicomToJsonFormat_Human:
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
734 {
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
735 assert(target.type() == Json::nullValue);
1738
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
736 targetValue = &target;
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
737 break;
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
738 }
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
739
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
740 case DicomToJsonFormat_Full:
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741 {
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
742 assert(target.type() == Json::objectValue);
1738
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
743 target["Value"] = Json::nullValue;
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
744 target["Type"] = Json::nullValue;
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
745 targetType = &target["Type"];
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
746 targetValue = &target["Value"];
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
747 break;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 }
1688
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 default:
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
751 throw OrthancException(ErrorCode_ParameterOutOfRange);
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
752 }
1738
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
753
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
754 assert(targetValue != NULL);
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
755 assert(targetValue->type() == Json::nullValue);
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
756 assert(targetType == NULL || targetType->type() == Json::nullValue);
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
757
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
758 if (value.IsNull())
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
759 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
760 if (targetType != NULL)
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
761 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
762 *targetType = "Null";
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
763 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
764 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
765 else if (value.IsBinary())
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
766 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
767 if (flags & DicomToJsonFlags_ConvertBinaryToAscii)
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
768 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
769 *targetValue = Toolbox::ConvertToAscii(value.GetContent());
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
770 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
771 else
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
772 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
773 std::string s;
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
774 value.FormatDataUriScheme(s);
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
775 *targetValue = s;
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
776 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
777
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
778 if (targetType != NULL)
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
779 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
780 *targetType = "Binary";
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
781 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
782 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
783 else if (maxStringLength == 0 ||
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
784 value.GetContent().size() <= maxStringLength)
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
785 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
786 *targetValue = value.GetContent();
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
787
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
788 if (targetType != NULL)
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
789 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
790 *targetType = "String";
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
791 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
792 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
793 else
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
794 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
795 if (targetType != NULL)
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
796 {
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
797 *targetType = "TooLong";
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
798 }
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
799 }
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
800 }
35
f6d12037f886 full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
801
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
802
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
803 void FromDcmtkBridge::ElementToJson(Json::Value& parent,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
804 DcmElement& element,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
805 DicomToJsonFormat format,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
806 DicomToJsonFlags flags,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
807 unsigned int maxStringLength,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
808 Encoding encoding)
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
809 {
1691
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1690
diff changeset
810 if (parent.type() == Json::nullValue)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1690
diff changeset
811 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1690
diff changeset
812 parent = Json::objectValue;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1690
diff changeset
813 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1690
diff changeset
814
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1690
diff changeset
815 assert(parent.type() == Json::objectValue);
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
816 Json::Value& target = PrepareNode(parent, element, format);
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
817
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
818 if (element.isLeaf())
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
819 {
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
820 // The "0" below lets "LeafValueToJson()" take care of "TooLong" values
0c09d1af22f3 "/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
821 std::auto_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement(element, flags, 0, encoding));
1738
15a788a63846 DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
822 LeafValueToJson(target, *v, format, flags, maxStringLength);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 {
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
826 assert(target.type() == Json::nullValue);
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
827 target = Json::arrayValue;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829 // "All subclasses of DcmElement except for DcmSequenceOfItems
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
831 // etc. are not." The following dynamic_cast is thus OK.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 for (unsigned long i = 0; i < sequence.card(); i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 DcmItem* child = sequence.getItem(i);
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
837 Json::Value& v = target.append(Json::objectValue);
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
838 DatasetToJson(v, *child, format, flags, maxStringLength, encoding);
1687
4d80fc990dae refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1686
diff changeset
839 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
844 void FromDcmtkBridge::DatasetToJson(Json::Value& parent,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
845 DcmItem& item,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
846 DicomToJsonFormat format,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
847 DicomToJsonFlags flags,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
848 unsigned int maxStringLength,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
849 Encoding encoding)
1686
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
850 {
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
851 assert(parent.type() == Json::objectValue);
1686
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
852
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
853 for (unsigned long i = 0; i < item.card(); i++)
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
854 {
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
855 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
856 if (element == NULL)
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
857 {
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
858 throw OrthancException(ErrorCode_InternalError);
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
859 }
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
860
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
861 DicomTag tag(FromDcmtkBridge::Convert(element->getTag()));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
862
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
863 /*element->getTag().isPrivate()*/
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
864 if (tag.IsPrivate() &&
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
865 !(flags & DicomToJsonFlags_IncludePrivateTags))
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
866 {
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
867 continue;
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
868 }
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
869
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
870 if (!(flags & DicomToJsonFlags_IncludeUnknownTags))
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
871 {
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
872 DictionaryLocker locker;
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
873 if (locker->findEntry(element->getTag(), NULL) == NULL)
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
874 {
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
875 continue;
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
876 }
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
877 }
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
878
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
879 DcmEVR evr = element->getTag().getEVR();
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
880 if (evr == EVR_OB ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
881 evr == EVR_OF ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
882 evr == EVR_OW ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
883 evr == EVR_UN ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
884 evr == EVR_ox)
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
885 {
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
886 // This is a binary tag
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
887 if ((tag == DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludePixelData)) ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
888 (tag != DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludeBinary)))
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
889 {
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
890 continue;
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
891 }
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
892 }
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
893
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
894 FromDcmtkBridge::ElementToJson(parent, *element, format, flags, maxStringLength, encoding);
1686
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
895 }
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
896 }
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
897
14a32b2fa63e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
898
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
899 void FromDcmtkBridge::ExtractDicomAsJson(Json::Value& target,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
900 DcmDataset& dataset,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
901 DicomToJsonFormat format,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
902 DicomToJsonFlags flags,
2131
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2129
diff changeset
903 unsigned int maxStringLength,
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2129
diff changeset
904 Encoding defaultEncoding)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905 {
2131
bb199bccdc45 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2129
diff changeset
906 Encoding encoding = DetectEncoding(dataset, defaultEncoding);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
907
1688
27d70e9ee2e4 DicomToJsonFormat enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1687
diff changeset
908 target = Json::objectValue;
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
909 DatasetToJson(target, dataset, format, flags, maxStringLength, encoding);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
913 void FromDcmtkBridge::ExtractHeaderAsJson(Json::Value& target,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
914 DcmMetaInfo& dataset,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
915 DicomToJsonFormat format,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
916 DicomToJsonFlags flags,
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2125
diff changeset
917 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
918 {
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1818
diff changeset
919 target = Json::objectValue;
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1818
diff changeset
920 DatasetToJson(target, dataset, format, flags, maxStringLength, Encoding_Ascii);
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1818
diff changeset
921 }
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1818
diff changeset
922
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1818
diff changeset
923
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
924
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
925 static std::string GetTagNameInternal(DcmTag& tag)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926 {
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
927 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
928 // 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
929 // 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
930 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
931 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
932 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
933 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
934 return n;
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
935 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
936 // End of patches
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
937 }
106
332fec038d52 patch for dcmtk dictionaries
jodogne
parents: 80
diff changeset
938
305
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
939 #if 0
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
940 // This version explicitly calls the dictionary
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 const DcmDataDictionary& dict = dcmDataDict.rdlock();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 const DcmDictEntry* entry = dict.findEntry(tag, NULL);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
944 std::string s(DcmTag_ERROR_TagName);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 if (entry != NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 s = std::string(entry->getTagName());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 dcmDataDict.unlock();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951 return s;
305
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
952 #else
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
953 const char* name = tag.getTagName();
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
954 if (name == NULL)
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
955 {
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
956 return DcmTag_ERROR_TagName;
305
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
957 }
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
958 else
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
959 {
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
960 return std::string(name);
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
961 }
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
962 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
966 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
967 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
968 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
969 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
970
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
971 if (!privateCreator.empty())
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
972 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
973 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
974 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
975
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
976 return GetTagNameInternal(tag);
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
977 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
978
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
979
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
980 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
981 {
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
982 // 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
983 // 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
984 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
985
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
986 return GetTagNameInternal(tag);
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
987 }
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
988
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
989
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
990
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
991 DicomTag FromDcmtkBridge::ParseTag(const char* name)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
992 {
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
993 if (strlen(name) == 9 &&
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
994 isxdigit(name[0]) &&
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
995 isxdigit(name[1]) &&
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
996 isxdigit(name[2]) &&
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
997 isxdigit(name[3]) &&
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 957
diff changeset
998 (name[4] == '-' || name[4] == ',') &&
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
999 isxdigit(name[5]) &&
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1000 isxdigit(name[6]) &&
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1001 isxdigit(name[7]) &&
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1002 isxdigit(name[8]))
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1003 {
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1004 uint16_t group = GetTagValue(name);
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1005 uint16_t element = GetTagValue(name + 5);
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1006 return DicomTag(group, element);
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1007 }
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1008
1861
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1009 if (strlen(name) == 8 &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1010 isxdigit(name[0]) &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1011 isxdigit(name[1]) &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1012 isxdigit(name[2]) &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1013 isxdigit(name[3]) &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1014 isxdigit(name[4]) &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1015 isxdigit(name[5]) &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1016 isxdigit(name[6]) &&
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1017 isxdigit(name[7]))
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1018 {
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1019 uint16_t group = GetTagValue(name);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1020 uint16_t element = GetTagValue(name + 4);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1021 return DicomTag(group, element);
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1022 }
a7bea843a7bc "OrthancPluginLookupDictionary()" to get information about some DICOM tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
1023
305
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1024 #if 0
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 const DcmDataDictionary& dict = dcmDataDict.rdlock();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 const DcmDictEntry* entry = dict.findEntry(name);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 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 dcmDataDict.unlock();
1582
bd1889029cbb encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
1031 throw OrthancException(ErrorCode_UnknownDicomTag);
0
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 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 DcmTagKey key = entry->getKey();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 DicomTag tag(key.getGroup(), key.getElement());
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 dcmDataDict.unlock();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 return tag;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 }
305
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1040 #else
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1041 DcmTag tag;
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1042 if (DcmTag::findTagFromName(name, tag).good())
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1043 {
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1044 return DicomTag(tag.getGTag(), tag.getETag());
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1045 }
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1046 else
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1047 {
1582
bd1889029cbb encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1557
diff changeset
1048 throw OrthancException(ErrorCode_UnknownDicomTag);
305
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1049 }
86bb79522f19 name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
1050 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053
1655
e40fd0d925c5 /tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1054 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
1055 {
e40fd0d925c5 /tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1056 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
1057 return tmp.isUnknownVR();
e40fd0d925c5 /tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1058 }
e40fd0d925c5 /tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1059
e40fd0d925c5 /tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
1060
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 void FromDcmtkBridge::ToJson(Json::Value& result,
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1062 const DicomMap& values,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1063 bool simplify)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 if (result.type() != Json::objectValue)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 {
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
1067 throw OrthancException(ErrorCode_BadParameterType);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1068 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1070 result.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1071
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 for (DicomMap::Map::const_iterator
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 465
diff changeset
1073 it = values.map_.begin(); it != values.map_.end(); ++it)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1074 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
1075 // 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
1076 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
1077
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1078 if (simplify)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1079 {
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1080 if (it->second->IsNull())
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1081 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
1082 result[tagName] = Json::nullValue;
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1083 }
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1084 else
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1085 {
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1086 // TODO IsBinary
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
1087 result[tagName] = it->second->GetContent();
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1088 }
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1089 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1090 else
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1091 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1092 Json::Value value = Json::objectValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1093
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2076
diff changeset
1094 value["Name"] = tagName;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1095
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1096 if (it->second->IsNull())
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1097 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1098 value["Type"] = "Null";
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1099 value["Value"] = Json::nullValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1100 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1101 else
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1102 {
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1103 // TODO IsBinary
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1104 value["Type"] = "String";
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
1105 value["Value"] = it->second->GetContent();
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1106 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1107
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1108 result[it->first.Format()] = value;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
1109 }
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 }
176
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1112
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1113
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 784
diff changeset
1114 std::string FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType level)
176
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1115 {
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1116 char uid[100];
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1117
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1118 switch (level)
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1119 {
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 784
diff changeset
1120 case ResourceType_Patient:
311
26efccdff583 anonymisation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 308
diff changeset
1121 // The "PatientID" field is of type LO (Long String), 64
26efccdff583 anonymisation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 308
diff changeset
1122 // 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
1123 // as a random PatientID.
2172
84d1d392a9ab GenerateUuid() not available in sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2152
diff changeset
1124 return SystemToolbox::GenerateUuid();
306
326d5a4a5af3 modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 305
diff changeset
1125
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 784
diff changeset
1126 case ResourceType_Instance:
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1127 return dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT);
176
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1128
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 784
diff changeset
1129 case ResourceType_Series:
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1130 return dcmGenerateUniqueIdentifier(uid, SITE_SERIES_UID_ROOT);
176
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1131
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 784
diff changeset
1132 case ResourceType_Study:
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1133 return dcmGenerateUniqueIdentifier(uid, SITE_STUDY_UID_ROOT);
176
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1134
302
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1135 default:
238134081136 modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1136 throw OrthancException(ErrorCode_ParameterOutOfRange);
176
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1137 }
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1138 }
81f11fb357f2 uid generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
1139
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1140 bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer,
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
1141 DcmDataset& dataSet)
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1142 {
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1143 // Determine the transfer syntax which shall be used to write the
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1144 // information to the file. We always switch to the Little Endian
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1145 // syntax, with explicit length.
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1146
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1147 // 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
1148
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
1149
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
1150 /**
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
1151 * 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
1152 * "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
1153 * 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
1154 * (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
1155 **/
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
1156 E_TransferSyntax xfer = dataSet.getOriginalXfer();
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
1157 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
1158 {
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
1159 // 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
1160 // 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
1161 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
1162 }
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
1163
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1164 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength;
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1165
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
1166 // Create the meta-header information
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
1167 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
1168 ff.validateMetaInfo(xfer);
1316
1c8dfedefefe Fix anonymization generating non-portable DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
1169 ff.removeInvalidGroups();
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1170
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
1171 // Create a memory buffer with the proper size
1876
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1172 {
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1173 const uint32_t estimatedSize = ff.calcElementLength(xfer, encodingType); // (*)
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1174 buffer.resize(estimatedSize);
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1175 }
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1176
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1177 DcmOutputBufferStream ob(&buffer[0], buffer.size());
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1178
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
1179 // Fill the memory buffer with the meta-header and the dataset
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
1180 ff.transferInit();
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
1181 OFCondition c = ff.write(ob, xfer, encodingType, NULL,
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
1182 /*opt_groupLength*/ EGL_recalcGL,
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
1183 /*opt_paddingType*/ EPD_withoutPadding);
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
1184 ff.transferEnd();
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1185
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1186 if (c.good())
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1187 {
1876
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1188 // The DICOM file is successfully written, truncate the target
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1189 // buffer if its size was overestimated by (*)
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1190 ob.flush();
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1191
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1192 size_t effectiveSize = static_cast<size_t>(ob.tell());
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1193 if (effectiveSize < buffer.size())
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1194 {
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1195 buffer.resize(effectiveSize);
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1196 }
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1197
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1198 return true;
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1199 }
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1200 else
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1201 {
1876
9b458e4484a1 truncation of serialized DICOM buffers if calcElementLength was overestimated
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1861
diff changeset
1202 // Error
291
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1203 buffer.clear();
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1204 return false;
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1205 }
4d7469f72a0b embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
1206 }
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1316
diff changeset
1207
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1316
diff changeset
1208
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1209 ValueRepresentation FromDcmtkBridge::LookupValueRepresentation(const DicomTag& tag)
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1316
diff changeset
1210 {
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1316
diff changeset
1211 DcmTag t(tag.GetGroup(), tag.GetElement());
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1212 return Convert(t.getEVR());
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1213 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1214
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1215 ValueRepresentation FromDcmtkBridge::Convert(const DcmEVR vr)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1216 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1217 switch (vr)
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1218 {
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1219 case EVR_AE:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1220 return ValueRepresentation_ApplicationEntity;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1221
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1222 case EVR_AS:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1223 return ValueRepresentation_AgeString;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1224
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1225 case EVR_AT:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1226 return ValueRepresentation_AttributeTag;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1227
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1228 case EVR_CS:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1229 return ValueRepresentation_CodeString;
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1230
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1231 case EVR_DA:
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1232 return ValueRepresentation_Date;
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1233
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1234 case EVR_DS:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1235 return ValueRepresentation_DecimalString;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1236
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1237 case EVR_DT:
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1238 return ValueRepresentation_DateTime;
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1239
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1240 case EVR_FL:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1241 return ValueRepresentation_FloatingPointSingle;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1242
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1243 case EVR_FD:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1244 return ValueRepresentation_FloatingPointDouble;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1245
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1246 case EVR_IS:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1247 return ValueRepresentation_IntegerString;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1248
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1249 case EVR_LO:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1250 return ValueRepresentation_LongString;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1251
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1252 case EVR_LT:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1253 return ValueRepresentation_LongText;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1254
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1255 case EVR_OB:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1256 return ValueRepresentation_OtherByte;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1257
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1258 // Not supported as of DCMTK 3.6.0
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1259 /*case EVR_OD:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1260 return ValueRepresentation_OtherDouble;*/
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1261
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1262 case EVR_OF:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1263 return ValueRepresentation_OtherFloat;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1264
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1265 // Not supported as of DCMTK 3.6.0
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1266 /*case EVR_OL:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1267 return ValueRepresentation_OtherLong;*/
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1268
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1269 case EVR_OW:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1270 return ValueRepresentation_OtherWord;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1271
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1272 case EVR_PN:
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
1273 return ValueRepresentation_PersonName;
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1274
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1275 case EVR_SH:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1276 return ValueRepresentation_ShortString;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1277
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1278 case EVR_SL:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1279 return ValueRepresentation_SignedLong;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1280
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1281 case EVR_SQ:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1282 return ValueRepresentation_Sequence;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1283
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1284 case EVR_SS:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1285 return ValueRepresentation_SignedShort;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1286
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1287 case EVR_ST:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1288 return ValueRepresentation_ShortText;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1289
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1290 case EVR_TM:
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1291 return ValueRepresentation_Time;
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1292
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1293 // Not supported as of DCMTK 3.6.0
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1294 /*case EVR_UC:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1295 return ValueRepresentation_UnlimitedCharacters;*/
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1296
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1297 case EVR_UI:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1298 return ValueRepresentation_UniqueIdentifier;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1299
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1300 case EVR_UL:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1301 return ValueRepresentation_UnsignedLong;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1302
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1303 case EVR_UN:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1304 return ValueRepresentation_Unknown;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1305
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1306 // Not supported as of DCMTK 3.6.0
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1307 /*case EVR_UR:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1308 return ValueRepresentation_UniversalResource;*/
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1309
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1310 case EVR_US:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1311 return ValueRepresentation_UnsignedShort;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1312
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1313 case EVR_UT:
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1314 return ValueRepresentation_UnlimitedText;
1792
b769623c806c safety check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1765
diff changeset
1315
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1316 default:
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
1317 return ValueRepresentation_NotSupported;
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1318 }
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1316
diff changeset
1319 }
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1316
diff changeset
1320
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1321
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1322 static bool IsBinaryTag(const DcmTag& key)
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1323 {
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1324 return (key.isUnknownVR() ||
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1325 key.getEVR() == EVR_OB ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1326 key.getEVR() == EVR_OF ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1327 key.getEVR() == EVR_OW ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1328 key.getEVR() == EVR_UN ||
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1329 key.getEVR() == EVR_ox);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1330 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1331
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1332
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1333 DcmElement* FromDcmtkBridge::CreateElementForTag(const DicomTag& tag)
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1334 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1335 DcmTag key(tag.GetGroup(), tag.GetElement());
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1336
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1337 if (tag.IsPrivate() ||
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1338 IsBinaryTag(key))
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1339 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1340 return new DcmOtherByteOtherWord(key);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1341 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1342
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1343 switch (key.getEVR())
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1344 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1345 // http://support.dcmtk.org/docs/dcvr_8h-source.html
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1346
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1347 /**
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1348 * Binary types, handled above
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1349 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1350
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1351 case EVR_OB: // other byte
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1352 case EVR_OF: // other float
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1353 case EVR_OW: // other word
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1354 case EVR_UN: // unknown value representation
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1355 case EVR_ox: // OB or OW depending on context
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1356 throw OrthancException(ErrorCode_InternalError);
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1357
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1358
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1359 /**
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1360 * String types.
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1361 * http://support.dcmtk.org/docs/classDcmByteString.html
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1362 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1363
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1364 case EVR_AS: // age string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1365 return new DcmAgeString(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1366
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1367 case EVR_AE: // application entity title
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1368 return new DcmApplicationEntity(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1369
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1370 case EVR_CS: // code string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1371 return new DcmCodeString(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1372
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1373 case EVR_DA: // date string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1374 return new DcmDate(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1375
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1376 case EVR_DT: // date time string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1377 return new DcmDateTime(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1378
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1379 case EVR_DS: // decimal string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1380 return new DcmDecimalString(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1381
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1382 case EVR_IS: // integer string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1383 return new DcmIntegerString(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1384
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1385 case EVR_TM: // time string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1386 return new DcmTime(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1387
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1388 case EVR_UI: // unique identifier
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1389 return new DcmUniqueIdentifier(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1390
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1391 case EVR_ST: // short text
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1392 return new DcmShortText(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1393
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1394 case EVR_LO: // long string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1395 return new DcmLongString(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1396
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1397 case EVR_LT: // long text
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1398 return new DcmLongText(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1399
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1400 case EVR_UT: // unlimited text
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1401 return new DcmUnlimitedText(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1402
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1403 case EVR_SH: // short string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1404 return new DcmShortString(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1405
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1406 case EVR_PN: // person name
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1407 return new DcmPersonName(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1408
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1409
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1410 /**
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1411 * Numerical types
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1412 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1413
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1414 case EVR_SL: // signed long
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1415 return new DcmSignedLong(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1416
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1417 case EVR_SS: // signed short
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1418 return new DcmSignedShort(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1419
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1420 case EVR_UL: // unsigned long
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1421 return new DcmUnsignedLong(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1422
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1423 case EVR_US: // unsigned short
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1424 return new DcmUnsignedShort(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1425
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1426 case EVR_FL: // float single-precision
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1427 return new DcmFloatingPointSingle(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1428
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1429 case EVR_FD: // float double-precision
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1430 return new DcmFloatingPointDouble(key);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1431
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1432
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1433 /**
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1434 * Sequence types, should never occur at this point.
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1435 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1436
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1437 case EVR_SQ: // sequence of items
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1438 throw OrthancException(ErrorCode_ParameterOutOfRange);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1439
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1440
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1441 /**
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1442 * TODO
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1443 **/
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1444
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1445 case EVR_AT: // attribute tag
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1446 throw OrthancException(ErrorCode_NotImplemented);
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1447
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1448
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1738
diff changeset
1449 /**
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1450 * Internal to DCMTK.
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1451 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1452
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1453 case EVR_xs: // SS or US depending on context
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1454 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
1455 case EVR_na: // na="not applicable", for data which has no VR
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1456 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1457 case EVR_item: // used internally for items
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1458 case EVR_metainfo: // used internally for meta info datasets
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1459 case EVR_dataset: // used internally for datasets
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1460 case EVR_fileFormat: // used internally for DICOM files
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1461 case EVR_dicomDir: // used internally for DICOMDIR objects
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1462 case EVR_dirRecord: // used internally for DICOMDIR records
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1463 case EVR_pixelSQ: // used internally for pixel sequences in a compressed image
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1464 case EVR_pixelItem: // used internally for pixel items in a compressed image
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1465 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
1466 case EVR_PixelData: // used internally for uncompressed pixeld data
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1467 case EVR_OverlayData: // used internally for overlay data
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1468 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
1469 default:
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1470 break;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1471 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1472
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1473 throw OrthancException(ErrorCode_InternalError);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1474 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1475
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1476
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 void FromDcmtkBridge::FillElementWithString(DcmElement& element,
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1479 const DicomTag& tag,
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1480 const std::string& utf8Value,
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1481 bool decodeDataUriScheme,
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1482 Encoding dicomEncoding)
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1483 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1484 std::string binary;
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1485 const std::string* decoded = &utf8Value;
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1486
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1487 if (decodeDataUriScheme &&
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1488 boost::starts_with(utf8Value, "data:application/octet-stream;base64,"))
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1489 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1490 std::string mime;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1976
diff changeset
1491 if (!Toolbox::DecodeDataUriScheme(mime, binary, utf8Value))
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1976
diff changeset
1492 {
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1976
diff changeset
1493 throw OrthancException(ErrorCode_BadFileFormat);
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
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1496 decoded = &binary;
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1497 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1498 else if (dicomEncoding != Encoding_Utf8)
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 binary = Toolbox::ConvertFromUtf8(utf8Value, dicomEncoding);
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1501 decoded = &binary;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1502 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1503
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1504 DcmTag key(tag.GetGroup(), tag.GetElement());
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1505
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1506 if (tag.IsPrivate() ||
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1507 IsBinaryTag(key))
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1508 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1509 if (element.putUint8Array((const Uint8*) decoded->c_str(), decoded->size()).good())
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1510 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1511 return;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1512 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1513 else
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1514 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1515 throw OrthancException(ErrorCode_InternalError);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1516 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1517 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1518
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1519 bool ok = false;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1520
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1521 try
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1522 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1523 switch (key.getEVR())
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1524 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1525 // http://support.dcmtk.org/docs/dcvr_8h-source.html
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1526
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1527 /**
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1528 * TODO.
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1529 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1530
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1531 case EVR_OB: // other byte
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1532 case EVR_OF: // other float
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1533 case EVR_OW: // other word
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1534 case EVR_AT: // attribute tag
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1535 throw OrthancException(ErrorCode_NotImplemented);
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1536
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1537 case EVR_UN: // unknown value representation
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1538 throw OrthancException(ErrorCode_ParameterOutOfRange);
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
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 * String types.
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1543 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1544
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1545 case EVR_DS: // decimal string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1546 case EVR_IS: // integer string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1547 case EVR_AS: // age string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1548 case EVR_DA: // date string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1549 case EVR_DT: // date time string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1550 case EVR_TM: // time string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1551 case EVR_AE: // application entity title
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1552 case EVR_CS: // code string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1553 case EVR_SH: // short string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1554 case EVR_LO: // long string
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1555 case EVR_ST: // short text
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1556 case EVR_LT: // long text
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1557 case EVR_UT: // unlimited text
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1558 case EVR_PN: // person name
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1559 case EVR_UI: // unique identifier
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 ok = element.putString(decoded->c_str()).good();
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1562 break;
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
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1566 /**
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1567 * Numerical types
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1568 **/
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1569
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1570 case EVR_SL: // signed long
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1571 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1572 ok = element.putSint32(boost::lexical_cast<Sint32>(*decoded)).good();
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1573 break;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1574 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1575
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1576 case EVR_SS: // signed short
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1577 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1578 ok = element.putSint16(boost::lexical_cast<Sint16>(*decoded)).good();
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1579 break;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1580 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1581
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1582 case EVR_UL: // unsigned long
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1583 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1584 ok = element.putUint32(boost::lexical_cast<Uint32>(*decoded)).good();
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1585 break;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1586 }
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 case EVR_US: // unsigned short
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 ok = element.putUint16(boost::lexical_cast<Uint16>(*decoded)).good();
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1591 break;
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_FL: // float single-precision
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.putFloat32(boost::lexical_cast<float>(*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_FD: // float double-precision
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.putFloat64(boost::lexical_cast<double>(*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
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1607 /**
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1608 * Sequence types, should never occur at this point.
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1609 **/
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 case EVR_SQ: // sequence of items
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1612 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1613 ok = false;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1614 break;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1615 }
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
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1618 /**
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1619 * Internal to DCMTK.
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
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1622 case EVR_ox: // OB or OW depending on context
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1623 case EVR_xs: // SS or US depending on context
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1624 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
1625 case EVR_na: // na="not applicable", for data which has no VR
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1626 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1627 case EVR_item: // used internally for items
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1628 case EVR_metainfo: // used internally for meta info datasets
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1629 case EVR_dataset: // used internally for datasets
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1630 case EVR_fileFormat: // used internally for DICOM files
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1631 case EVR_dicomDir: // used internally for DICOMDIR objects
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1632 case EVR_dirRecord: // used internally for DICOMDIR records
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1633 case EVR_pixelSQ: // used internally for pixel sequences in a compressed image
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1634 case EVR_pixelItem: // used internally for pixel items in a compressed image
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1635 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
1636 case EVR_PixelData: // used internally for uncompressed pixeld data
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1637 case EVR_OverlayData: // used internally for overlay data
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1638 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
1639 default:
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1640 break;
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 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1643 catch (boost::bad_lexical_cast&)
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1644 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1645 ok = false;
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 if (!ok)
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1649 {
2216
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1650 LOG(ERROR) << "While creating a DICOM instance, tag (" << tag.Format()
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1651 << ") has out-of-range value: \"" << *decoded << "\"";
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1652 throw OrthancException(ErrorCode_BadFileFormat);
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1653 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1654 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1655
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1656
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1657 DcmElement* FromDcmtkBridge::FromJson(const DicomTag& tag,
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
1658 const Json::Value& value,
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1659 bool decodeDataUriScheme,
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
1660 Encoding dicomEncoding)
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1661 {
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1662 std::auto_ptr<DcmElement> element;
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1663
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1664 switch (value.type())
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1665 {
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1666 case Json::stringValue:
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1667 element.reset(CreateElementForTag(tag));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1668 FillElementWithString(*element, tag, value.asString(), decodeDataUriScheme, dicomEncoding);
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1669 break;
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1670
2216
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1671 case Json::nullValue:
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1672 element.reset(CreateElementForTag(tag));
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1673 FillElementWithString(*element, tag, "", decodeDataUriScheme, dicomEncoding);
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1674 break;
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1675
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1676 case Json::arrayValue:
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1677 {
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1678 DcmTag key(tag.GetGroup(), tag.GetElement());
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1679 if (key.getEVR() != EVR_SQ)
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1680 {
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1681 throw OrthancException(ErrorCode_BadParameterType);
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1682 }
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1683
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1684 DcmSequenceOfItems* sequence = new DcmSequenceOfItems(key, value.size());
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1685 element.reset(sequence);
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1686
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1687 for (Json::Value::ArrayIndex i = 0; i < value.size(); i++)
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1688 {
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1689 std::auto_ptr<DcmItem> item(new DcmItem);
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1691 Json::Value::Members members = value[i].getMemberNames();
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1692 for (Json::Value::ArrayIndex j = 0; j < members.size(); j++)
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1693 {
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1792
diff changeset
1694 item->insert(FromJson(ParseTag(members[j]), value[i][members[j]], decodeDataUriScheme, dicomEncoding));
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1695 }
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1696
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1697 sequence->append(item.release());
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1698 }
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1699
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1700 break;
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1701 }
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1702
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1703 default:
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
1704 throw OrthancException(ErrorCode_BadParameterType);
1689
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1705 }
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1706
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1707 return element.release();
26083d84d237 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1688
diff changeset
1708 }
1765
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
1709
57b9e6890482 New configuration option: "Dictionary" to declare custom DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
1710
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
1711 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
1712 {
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1713 DcmElement *element = NULL;
1927
b60f27664b8f simplification in FromDcmtkBridge
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1924
diff changeset
1714 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
1715 {
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1716 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
1717 }
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1718
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1719 DcmPixelData& pixelData = dynamic_cast<DcmPixelData&>(*element);
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1720 DcmPixelSequence* pixelSequence = 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
1721 if (!pixelData.getEncapsulatedRepresentation
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1722 (dataset.getOriginalXfer(), NULL, pixelSequence).good())
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1723 {
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1724 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
1725 }
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1726 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
1727 {
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1728 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
1729 }
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1730 }
1934
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1731
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1732
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1733 Encoding FromDcmtkBridge::ExtractEncoding(const Json::Value& json,
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1734 Encoding defaultEncoding)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1735 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1736 if (json.type() != Json::objectValue)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1737 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1738 throw OrthancException(ErrorCode_BadParameterType);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1739 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1740
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1741 Encoding encoding = defaultEncoding;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1742
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1743 const Json::Value::Members tags = json.getMemberNames();
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1744
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1745 // Look for SpecificCharacterSet (0008,0005) in the JSON file
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1746 for (size_t i = 0; i < tags.size(); i++)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1747 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1748 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1749 if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1750 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1751 const Json::Value& value = json[tags[i]];
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1752 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
1753 (value.asString().length() != 0 &&
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1754 !GetDicomEncoding(encoding, value.asCString())))
1934
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1755 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1756 LOG(ERROR) << "Unknown encoding while creating DICOM from JSON: " << value;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1757 throw OrthancException(ErrorCode_BadRequest);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1758 }
2216
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1759
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1760 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
1761 {
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1762 return defaultEncoding;
9a8fab016145 sample worklist plugin fine-tuning the C-Find query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2209
diff changeset
1763 }
1934
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1764 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1765 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1766
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1767 return encoding;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1768 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1769
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1770
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1771 static void SetString(DcmDataset& target,
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1772 const DcmTag& tag,
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1773 const std::string& value)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1774 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1775 if (!target.putAndInsertString(tag, value.c_str()).good())
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1776 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1777 throw OrthancException(ErrorCode_InternalError);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1778 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1779 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1780
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1781
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1782 DcmDataset* FromDcmtkBridge::FromJson(const Json::Value& json, // Encoded using UTF-8
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1783 bool generateIdentifiers,
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1784 bool decodeDataUriScheme,
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1785 Encoding defaultEncoding)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1786 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1787 std::auto_ptr<DcmDataset> result(new DcmDataset);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1788 Encoding encoding = ExtractEncoding(json, defaultEncoding);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1789
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1790 SetString(*result, DCM_SpecificCharacterSet, GetDicomSpecificCharacterSet(encoding));
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1791
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1792 const Json::Value::Members tags = json.getMemberNames();
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1793
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1794 bool hasPatientId = false;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1795 bool hasStudyInstanceUid = false;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1796 bool hasSeriesInstanceUid = false;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1797 bool hasSopInstanceUid = false;
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 for (size_t i = 0; i < tags.size(); i++)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1800 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1801 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1802 const Json::Value& value = json[tags[i]];
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 if (tag == DICOM_TAG_PATIENT_ID)
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 hasPatientId = true;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1807 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1808 else if (tag == DICOM_TAG_STUDY_INSTANCE_UID)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1809 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1810 hasStudyInstanceUid = true;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1811 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1812 else if (tag == DICOM_TAG_SERIES_INSTANCE_UID)
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 hasSeriesInstanceUid = true;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1815 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1816 else if (tag == DICOM_TAG_SOP_INSTANCE_UID)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1817 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1818 hasSopInstanceUid = true;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1819 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1820
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1821 if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1822 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1823 std::auto_ptr<DcmElement> element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding));
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1824 const DcmTagKey& tag = element->getTag();
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1825
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1826 result->findAndDeleteElement(tag);
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1827
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1828 DcmElement* tmp = element.release();
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1829 if (!result->insert(tmp, false, false).good())
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1830 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1831 delete tmp;
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1832 throw OrthancException(ErrorCode_InternalError);
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 }
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 if (!hasPatientId &&
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1838 generateIdentifiers)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1839 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1840 SetString(*result, DCM_PatientID, GenerateUniqueIdentifier(ResourceType_Patient));
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
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1843 if (!hasStudyInstanceUid &&
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1844 generateIdentifiers)
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 SetString(*result, DCM_StudyInstanceUID, GenerateUniqueIdentifier(ResourceType_Study));
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 if (!hasSeriesInstanceUid &&
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1850 generateIdentifiers)
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1851 {
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1852 SetString(*result, DCM_SeriesInstanceUID, GenerateUniqueIdentifier(ResourceType_Series));
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1853 }
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1854
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1855 if (!hasSopInstanceUid &&
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1856 generateIdentifiers)
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_SOPInstanceUID, GenerateUniqueIdentifier(ResourceType_Instance));
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
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1861 return result.release();
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1930
diff changeset
1862 }
1935
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1863
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1864
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1865 DcmFileFormat* FromDcmtkBridge::LoadFromMemoryBuffer(const void* buffer,
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1866 size_t size)
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1867 {
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1868 DcmInputBufferStream is;
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1869 if (size > 0)
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1870 {
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1871 is.setBuffer(buffer, size);
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1872 }
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1873 is.setEos();
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1874
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1875 std::auto_ptr<DcmFileFormat> result(new DcmFileFormat);
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1876
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1877 result->transferInit();
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1878 if (!result->read(is).good())
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1879 {
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1880 throw OrthancException(ErrorCode_BadFileFormat);
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1881 }
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1882
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1883 result->loadAllDataIntoMemory();
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1884 result->transferEnd();
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1885
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1886 return result.release();
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1887 }
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1888
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1889
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1890 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
1891 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
1892 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1893 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
1894 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1895 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
1896 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1897
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1898 target.Clear();
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1899
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1900 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
1901
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1902 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
1903 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1904 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
1905
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1906 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
1907 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1908 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
1909 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1910
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
1911 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
1912 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1913 }
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1914
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1915
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1916 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
1917 Encoding source,
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1918 Encoding target)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1919 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1920 // 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
1921 // each string-like element
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1922
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1923 if (source == target)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1924 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1925 return;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1926 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1927
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1928 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
1929 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1930 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
1931 if (element)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1932 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1933 if (element->isLeaf())
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1934 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1935 char *c = NULL;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1936 if (element->isaString() &&
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1937 element->getString(c).good() &&
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1938 c != NULL)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1939 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1940 std::string a = Toolbox::ConvertToUtf8(c, source);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1941 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
1942 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
1943 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1944 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1945 else
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1946 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1947 // "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
1948 // 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
1949 // 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
1950 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
1951
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1952 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
1953 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1954 ChangeStringEncoding(*sequence.getItem(j), source, target);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1955 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1956 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1957 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1958 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2172
diff changeset
1959 }
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
1960
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1961
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1962 bool FromDcmtkBridge::LookupTransferSyntax(std::string& result,
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1963 DcmFileFormat& dicom)
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1964 {
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1965 const char* value = NULL;
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1966
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1967 if (dicom.getMetaInfo() != NULL &&
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1968 dicom.getMetaInfo()->findAndGetString(DCM_TransferSyntaxUID, value).good() &&
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1969 value != NULL)
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1970 {
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1971 result.assign(value);
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1972 return true;
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1973 }
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1974 else
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1975 {
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1976 return false;
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1977 }
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1978 }
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1979
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1980
2232
3dd44baebc36 macro ORTHANC_ENABLE_LUA for orthanc-wsi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2218
diff changeset
1981 #if ORTHANC_ENABLE_LUA == 1
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1982 void FromDcmtkBridge::ExecuteToDicom(DicomMap& target,
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1983 LuaFunctionCall& call)
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1984 {
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1985 Json::Value output;
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1986 call.ExecuteToJson(output, true /* keep strings */);
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1987
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1988 target.Clear();
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1989
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1990 if (output.type() == Json::arrayValue &&
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1991 output.size() == 0)
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1992 {
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1993 // This case happens for empty tables
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1994 return;
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1995 }
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1996
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1997 if (output.type() != Json::objectValue)
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1998 {
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
1999 LOG(ERROR) << "Lua: IncomingFindRequestFilter must return a table";
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2000 throw OrthancException(ErrorCode_LuaBadOutput);
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2001 }
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2002
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2003 Json::Value::Members members = output.getMemberNames();
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2004
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2005 for (size_t i = 0; i < members.size(); i++)
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2006 {
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2007 if (output[members[i]].type() != Json::stringValue)
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2008 {
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2009 LOG(ERROR) << "Lua: IncomingFindRequestFilter must return a table mapping names of DICOM tags to strings";
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2010 throw OrthancException(ErrorCode_LuaBadOutput);
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2011 }
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2012
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2013 DicomTag tag(ParseTag(members[i]));
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2014 target.SetValue(tag, output[members[i]].asString(), false);
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2015 }
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2216
diff changeset
2016 }
2232
3dd44baebc36 macro ORTHANC_ENABLE_LUA for orthanc-wsi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2218
diff changeset
2017 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2018 }