Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 4870:43e613a7756b
upgrade to year 2022
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jan 2022 11:15:42 +0100 |
parents | 02d77189d8ba |
children | d7d5d63985c8 |
rev | line source |
---|---|
790 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1160
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4845
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4845
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
790 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
11 * the License, or (at your option) any later version. |
790 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
16 * Lesser General Public License for more details. |
790 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
790 | 21 **/ |
22 | |
23 | |
24 | |
25 /*========================================================================= | |
26 | |
27 This file is based on portions of the following project: | |
28 | |
29 Program: GDCM (Grassroots DICOM). A DICOM library | |
30 Module: http://gdcm.sourceforge.net/Copyright.html | |
31 | |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
32 Copyright (c) 2006-2011 Mathieu Malaterre |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
33 Copyright (c) 1993-2005 CREATIS |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
34 (CREATIS = Centre de Recherche et d'Applications en Traitement de l'Image) |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
35 All rights reserved. |
790 | 36 |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
37 Redistribution and use in source and binary forms, with or without |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
38 modification, are permitted provided that the following conditions are met: |
790 | 39 |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
40 * Redistributions of source code must retain the above copyright notice, |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
41 this list of conditions and the following disclaimer. |
790 | 42 |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
43 * Redistributions in binary form must reproduce the above copyright notice, |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
44 this list of conditions and the following disclaimer in the documentation |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
45 and/or other materials provided with the distribution. |
790 | 46 |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
47 * Neither name of Mathieu Malaterre, or CREATIS, nor the names of any |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
48 contributors (CNRS, INSERM, UCB, Universite Lyon I), may be used to |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
49 endorse or promote products derived from this software without specific |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
50 prior written permission. |
790 | 51 |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
52 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
53 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
54 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
55 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
56 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
57 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
58 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
59 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
60 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
61 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
790 | 62 |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
63 =========================================================================*/ |
790 | 64 |
65 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
66 #include "../PrecompiledHeaders.h" |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
817
diff
changeset
|
67 |
790 | 68 #ifndef NOMINMAX |
69 #define NOMINMAX | |
70 #endif | |
71 | |
72 #include "ParsedDicomFile.h" | |
73 | |
74 #include "FromDcmtkBridge.h" | |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
75 #include "Internals/DicomFrameIndex.h" |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
76 #include "Internals/DicomImageDecoder.h" |
790 | 77 #include "ToDcmtkBridge.h" |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
78 |
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
79 #include "../Images/PamReader.h" |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
80 #include "../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
81 #include "../OrthancException.h" |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
82 #include "../SerializationToolbox.h" |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
83 #include "../Toolbox.h" |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
84 |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
85 #if ORTHANC_SANDBOXED == 0 |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
86 # include "../SystemToolbox.h" |
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
87 #endif |
790 | 88 |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
89 #if ORTHANC_ENABLE_JPEG == 1 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
90 # include "../Images/JpegReader.h" |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
91 #endif |
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
92 |
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
93 #if ORTHANC_ENABLE_PNG == 1 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
94 # include "../Images/PngReader.h" |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
95 #endif |
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
96 |
790 | 97 #include <list> |
98 #include <limits> | |
99 | |
100 #include <boost/lexical_cast.hpp> | |
101 | |
102 #include <dcmtk/dcmdata/dcchrstr.h> | |
103 #include <dcmtk/dcmdata/dcdicent.h> | |
104 #include <dcmtk/dcmdata/dcdict.h> | |
105 #include <dcmtk/dcmdata/dcfilefo.h> | |
106 #include <dcmtk/dcmdata/dcuid.h> | |
107 #include <dcmtk/dcmdata/dcmetinf.h> | |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
108 #include <dcmtk/dcmdata/dcdeftag.h> |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
109 #include <dcmtk/dcmdata/dcswap.h> |
790 | 110 |
111 #include <dcmtk/dcmdata/dcvrae.h> | |
112 #include <dcmtk/dcmdata/dcvras.h> | |
113 #include <dcmtk/dcmdata/dcvrcs.h> | |
114 #include <dcmtk/dcmdata/dcvrda.h> | |
115 #include <dcmtk/dcmdata/dcvrds.h> | |
116 #include <dcmtk/dcmdata/dcvrdt.h> | |
117 #include <dcmtk/dcmdata/dcvrfd.h> | |
118 #include <dcmtk/dcmdata/dcvrfl.h> | |
119 #include <dcmtk/dcmdata/dcvris.h> | |
120 #include <dcmtk/dcmdata/dcvrlo.h> | |
121 #include <dcmtk/dcmdata/dcvrlt.h> | |
122 #include <dcmtk/dcmdata/dcvrpn.h> | |
123 #include <dcmtk/dcmdata/dcvrsh.h> | |
124 #include <dcmtk/dcmdata/dcvrsl.h> | |
125 #include <dcmtk/dcmdata/dcvrss.h> | |
126 #include <dcmtk/dcmdata/dcvrst.h> | |
127 #include <dcmtk/dcmdata/dcvrtm.h> | |
128 #include <dcmtk/dcmdata/dcvrui.h> | |
129 #include <dcmtk/dcmdata/dcvrul.h> | |
130 #include <dcmtk/dcmdata/dcvrus.h> | |
131 #include <dcmtk/dcmdata/dcvrut.h> | |
132 #include <dcmtk/dcmdata/dcpixel.h> | |
133 #include <dcmtk/dcmdata/dcpixseq.h> | |
134 #include <dcmtk/dcmdata/dcpxitem.h> | |
135 | |
136 | |
137 #include <boost/math/special_functions/round.hpp> | |
138 #include <dcmtk/dcmdata/dcostrmb.h> | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
139 #include <boost/algorithm/string/predicate.hpp> |
790 | 140 |
141 | |
1945
76ff6eecf07f
fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1941
diff
changeset
|
142 #if DCMTK_VERSION_NUMBER <= 360 |
76ff6eecf07f
fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1941
diff
changeset
|
143 # define EXS_JPEGProcess1 EXS_JPEGProcess1TransferSyntax |
76ff6eecf07f
fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1941
diff
changeset
|
144 #endif |
76ff6eecf07f
fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1941
diff
changeset
|
145 |
76ff6eecf07f
fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1941
diff
changeset
|
146 |
790 | 147 |
148 namespace Orthanc | |
149 { | |
794 | 150 struct ParsedDicomFile::PImpl |
151 { | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
152 std::unique_ptr<DcmFileFormat> file_; |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
153 std::unique_ptr<DicomFrameIndex> frameIndex_; |
794 | 154 }; |
155 | |
156 | |
2394
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
157 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
158 static void ParseTagAndGroup(DcmTagKey& key, |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
159 const std::string& tag) |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
160 { |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
161 DicomTag t = FromDcmtkBridge::ParseTag(tag); |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
162 key = DcmTagKey(t.GetGroup(), t.GetElement()); |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
163 } |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
164 |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
165 |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
166 static unsigned int GetPixelDataBlockCount(DcmPixelData& pixelData, |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
167 E_TransferSyntax transferSyntax) |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
168 { |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
169 DcmPixelSequence* pixelSequence = NULL; |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
170 if (pixelData.getEncapsulatedRepresentation |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
171 (transferSyntax, NULL, pixelSequence).good() && pixelSequence) |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
172 { |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
173 return pixelSequence->card(); |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
174 } |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
175 else |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
176 { |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
177 return 1; |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
178 } |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
179 } |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
180 |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
181 |
790 | 182 static void SendPathValueForDictionary(RestApiOutput& output, |
183 DcmItem& dicom) | |
184 { | |
185 Json::Value v = Json::arrayValue; | |
186 | |
187 for (unsigned long i = 0; i < dicom.card(); i++) | |
188 { | |
189 DcmElement* element = dicom.getElement(i); | |
190 if (element) | |
191 { | |
192 char buf[16]; | |
193 sprintf(buf, "%04x-%04x", element->getTag().getGTag(), element->getTag().getETag()); | |
194 v.append(buf); | |
195 } | |
196 } | |
197 | |
198 output.AnswerJson(v); | |
199 } | |
200 | |
201 | |
202 static void SendSequence(RestApiOutput& output, | |
203 DcmSequenceOfItems& sequence) | |
204 { | |
205 // This element is a sequence | |
206 Json::Value v = Json::arrayValue; | |
207 | |
208 for (unsigned long i = 0; i < sequence.card(); i++) | |
209 { | |
210 v.append(boost::lexical_cast<std::string>(i)); | |
211 } | |
212 | |
213 output.AnswerJson(v); | |
214 } | |
215 | |
216 | |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
217 namespace |
790 | 218 { |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
219 class DicomFieldStream : public IHttpStreamAnswer |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
220 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
221 private: |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
222 DcmElement& element_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
223 uint32_t length_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
224 uint32_t offset_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
225 std::string chunk_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
226 size_t chunkSize_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
227 |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
228 public: |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
229 DicomFieldStream(DcmElement& element, |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
230 E_TransferSyntax transferSyntax) : |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
231 element_(element), |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
232 length_(element.getLength(transferSyntax)), |
1616 | 233 offset_(0), |
234 chunkSize_(0) | |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
235 { |
1521 | 236 static const size_t CHUNK_SIZE = 64 * 1024; // Use chunks of max 64KB |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
237 chunk_.resize(CHUNK_SIZE); |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
238 } |
790 | 239 |
1523
c388502a066d
testing FilesystemHttpSender
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1521
diff
changeset
|
240 virtual HttpCompression SetupHttpCompression(bool /*gzipAllowed*/, |
c388502a066d
testing FilesystemHttpSender
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1521
diff
changeset
|
241 bool /*deflateAllowed*/) |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2910
diff
changeset
|
242 ORTHANC_OVERRIDE |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
243 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
244 // No support for compression |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
245 return HttpCompression_None; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
246 } |
790 | 247 |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2910
diff
changeset
|
248 virtual bool HasContentFilename(std::string& filename) ORTHANC_OVERRIDE |
790 | 249 { |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
250 return false; |
790 | 251 } |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
252 |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2910
diff
changeset
|
253 virtual std::string GetContentType() ORTHANC_OVERRIDE |
790 | 254 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
255 return EnumerationToString(MimeType_Binary); |
790 | 256 } |
257 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2910
diff
changeset
|
258 virtual uint64_t GetContentLength() ORTHANC_OVERRIDE |
790 | 259 { |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
260 return length_; |
790 | 261 } |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
262 |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2910
diff
changeset
|
263 virtual bool ReadNextChunk() ORTHANC_OVERRIDE |
790 | 264 { |
1520 | 265 assert(offset_ <= length_); |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
266 |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
267 if (offset_ == length_) |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
268 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
269 return false; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
270 } |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
271 else |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
272 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
273 if (length_ - offset_ < chunk_.size()) |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
274 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
275 chunkSize_ = length_ - offset_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
276 } |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
277 else |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
278 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
279 chunkSize_ = chunk_.size(); |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
280 } |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
281 |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
282 OFCondition cond = element_.getPartialValue(&chunk_[0], offset_, chunkSize_); |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
283 |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
284 offset_ += chunkSize_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
285 |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
286 if (!cond.good()) |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
287 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
288 throw OrthancException(ErrorCode_InternalError, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
289 "Error while sending a DICOM field: " + |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
290 std::string(cond.text())); |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
291 } |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
292 |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
293 return true; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
294 } |
790 | 295 } |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
296 |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2910
diff
changeset
|
297 virtual const char *GetChunkContent() ORTHANC_OVERRIDE |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
298 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
299 return chunk_.c_str(); |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
300 } |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
301 |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2910
diff
changeset
|
302 virtual size_t GetChunkSize() ORTHANC_OVERRIDE |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
303 { |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
304 return chunkSize_; |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
305 } |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
306 }; |
790 | 307 } |
308 | |
309 | |
310 static bool AnswerPixelData(RestApiOutput& output, | |
311 DcmItem& dicom, | |
312 E_TransferSyntax transferSyntax, | |
313 const std::string* blockUri) | |
314 { | |
315 DcmTag k(DICOM_TAG_PIXEL_DATA.GetGroup(), | |
316 DICOM_TAG_PIXEL_DATA.GetElement()); | |
317 | |
318 DcmElement *element = NULL; | |
319 if (!dicom.findAndGetElement(k, element).good() || | |
320 element == NULL) | |
321 { | |
322 return false; | |
323 } | |
324 | |
325 try | |
326 { | |
327 DcmPixelData& pixelData = dynamic_cast<DcmPixelData&>(*element); | |
328 if (blockUri == NULL) | |
329 { | |
1913
41e402cd7b3a
do not generate RC files for non-Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
330 // The user asks how many blocks are present in this pixel data |
790 | 331 unsigned int blocks = GetPixelDataBlockCount(pixelData, transferSyntax); |
332 | |
333 Json::Value result(Json::arrayValue); | |
334 for (unsigned int i = 0; i < blocks; i++) | |
335 { | |
336 result.append(boost::lexical_cast<std::string>(i)); | |
337 } | |
338 | |
339 output.AnswerJson(result); | |
340 return true; | |
341 } | |
342 | |
343 | |
344 unsigned int block = boost::lexical_cast<unsigned int>(*blockUri); | |
345 | |
346 if (block < GetPixelDataBlockCount(pixelData, transferSyntax)) | |
347 { | |
348 DcmPixelSequence* pixelSequence = NULL; | |
349 if (pixelData.getEncapsulatedRepresentation | |
350 (transferSyntax, NULL, pixelSequence).good() && pixelSequence) | |
351 { | |
352 // This is the case for JPEG transfer syntaxes | |
353 if (block < pixelSequence->card()) | |
354 { | |
355 DcmPixelItem* pixelItem = NULL; | |
356 if (pixelSequence->getItem(pixelItem, block).good() && pixelItem) | |
357 { | |
358 if (pixelItem->getLength() == 0) | |
359 { | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
360 output.AnswerBuffer(NULL, 0, MimeType_Binary); |
790 | 361 return true; |
362 } | |
363 | |
364 Uint8* buffer = NULL; | |
365 if (pixelItem->getUint8Array(buffer).good() && buffer) | |
366 { | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
367 output.AnswerBuffer(buffer, pixelItem->getLength(), MimeType_Binary); |
790 | 368 return true; |
369 } | |
370 } | |
371 } | |
372 } | |
373 else | |
374 { | |
375 // This is the case for raw, uncompressed image buffers | |
376 assert(*blockUri == "0"); | |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
377 DicomFieldStream stream(*element, transferSyntax); |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
378 output.AnswerStream(stream); |
790 | 379 } |
380 } | |
381 } | |
382 catch (boost::bad_lexical_cast&) | |
383 { | |
384 // The URI entered by the user is not a number | |
385 } | |
386 catch (std::bad_cast&) | |
387 { | |
388 // This should never happen | |
389 } | |
390 | |
391 return false; | |
392 } | |
393 | |
394 | |
395 static void SendPathValueForLeaf(RestApiOutput& output, | |
396 const std::string& tag, | |
397 DcmItem& dicom, | |
398 E_TransferSyntax transferSyntax) | |
399 { | |
400 DcmTagKey k; | |
401 ParseTagAndGroup(k, tag); | |
402 | |
403 DcmSequenceOfItems* sequence = NULL; | |
404 if (dicom.findAndGetSequence(k, sequence).good() && | |
405 sequence != NULL && | |
406 sequence->getVR() == EVR_SQ) | |
407 { | |
408 SendSequence(output, *sequence); | |
409 return; | |
410 } | |
411 | |
412 DcmElement* element = NULL; | |
413 if (dicom.findAndGetElement(k, element).good() && | |
414 element != NULL && | |
415 //element->getVR() != EVR_UNKNOWN && // This would forbid private tags | |
416 element->getVR() != EVR_SQ) | |
417 { | |
1519
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
418 DicomFieldStream stream(*element, transferSyntax); |
8bd0d897763f
refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
419 output.AnswerStream(stream); |
790 | 420 } |
421 } | |
2394
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
422 #endif |
790 | 423 |
2394
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
424 |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
425 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 |
790 | 426 void ParsedDicomFile::SendPathValue(RestApiOutput& output, |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
427 const UriComponents& uri) const |
790 | 428 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
429 DcmItem* dicom = GetDcmtkObjectConst().getDataset(); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
430 E_TransferSyntax transferSyntax = GetDcmtkObjectConst().getDataset()->getCurrentXfer(); |
790 | 431 |
432 // Special case: Accessing the pixel data | |
433 if (uri.size() == 1 || | |
434 uri.size() == 2) | |
435 { | |
436 DcmTagKey tag; | |
437 ParseTagAndGroup(tag, uri[0]); | |
438 | |
439 if (tag.getGroup() == DICOM_TAG_PIXEL_DATA.GetGroup() && | |
440 tag.getElement() == DICOM_TAG_PIXEL_DATA.GetElement()) | |
441 { | |
442 AnswerPixelData(output, *dicom, transferSyntax, uri.size() == 1 ? NULL : &uri[1]); | |
443 return; | |
444 } | |
445 } | |
446 | |
447 // Go down in the tag hierarchy according to the URI | |
448 for (size_t pos = 0; pos < uri.size() / 2; pos++) | |
449 { | |
450 size_t index; | |
451 try | |
452 { | |
453 index = boost::lexical_cast<size_t>(uri[2 * pos + 1]); | |
454 } | |
455 catch (boost::bad_lexical_cast&) | |
456 { | |
457 return; | |
458 } | |
459 | |
460 DcmTagKey k; | |
461 DcmItem *child = NULL; | |
462 ParseTagAndGroup(k, uri[2 * pos]); | |
463 if (!dicom->findAndGetSequenceItem(k, child, index).good() || | |
464 child == NULL) | |
465 { | |
466 return; | |
467 } | |
468 | |
469 dicom = child; | |
470 } | |
471 | |
472 // We have reached the end of the URI | |
473 if (uri.size() % 2 == 0) | |
474 { | |
475 SendPathValueForDictionary(output, *dicom); | |
476 } | |
477 else | |
478 { | |
479 SendPathValueForLeaf(output, uri.back(), *dicom, transferSyntax); | |
480 } | |
481 } | |
2394
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
482 #endif |
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
483 |
790 | 484 |
485 void ParsedDicomFile::Remove(const DicomTag& tag) | |
486 { | |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
487 RemovePath(DicomPath(tag)); |
790 | 488 } |
489 | |
490 | |
2310
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
491 void ParsedDicomFile::Clear(const DicomTag& tag, |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
492 bool onlyIfExists) |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
493 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
494 ClearPath(DicomPath(tag), onlyIfExists); |
2310
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
495 } |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
496 |
790 | 497 |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
498 void ParsedDicomFile::RemovePrivateTagsInternal(const std::set<DicomTag>* toKeep) |
790 | 499 { |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
500 InvalidateCache(); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
501 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
502 DcmDataset& dataset = *GetDcmtkObject().getDataset(); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
503 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
504 // Loop over the dataset to detect its private tags |
790 | 505 typedef std::list<DcmElement*> Tags; |
506 Tags privateTags; | |
507 | |
508 for (unsigned long i = 0; i < dataset.card(); i++) | |
509 { | |
510 DcmElement* element = dataset.getElement(i); | |
511 DcmTag tag(element->getTag()); | |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
512 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
513 // Is this a private tag? |
1694 | 514 if (tag.isPrivate()) |
790 | 515 { |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
516 bool remove = true; |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
517 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
518 // Check whether this private tag is to be kept |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
519 if (toKeep != NULL) |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
520 { |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
521 DicomTag tmp = FromDcmtkBridge::Convert(tag); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
522 if (toKeep->find(tmp) != toKeep->end()) |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
523 { |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
524 remove = false; // Keep it |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
525 } |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
526 } |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
527 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
528 if (remove) |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
529 { |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
530 privateTags.push_back(element); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
531 } |
790 | 532 } |
533 } | |
534 | |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
535 // Loop over the detected private tags to remove them |
790 | 536 for (Tags::iterator it = privateTags.begin(); |
537 it != privateTags.end(); ++it) | |
538 { | |
539 DcmElement* tmp = dataset.remove(*it); | |
540 if (tmp != NULL) | |
541 { | |
542 delete tmp; | |
543 } | |
544 } | |
545 } | |
546 | |
547 | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
548 static void InsertInternal(DcmDataset& dicom, |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
549 DcmElement* element) |
790 | 550 { |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
551 OFCondition cond = dicom.insert(element, false, false); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
552 if (!cond.good()) |
790 | 553 { |
554 // This field already exists | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
555 delete element; |
790 | 556 throw OrthancException(ErrorCode_InternalError); |
557 } | |
558 } | |
559 | |
560 | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
561 void ParsedDicomFile::Insert(const DicomTag& tag, |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
562 const Json::Value& value, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
563 bool decodeDataUriScheme, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
564 const std::string& privateCreator) |
790 | 565 { |
2797
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
566 if (tag.GetElement() == 0x0000) |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
567 { |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
568 // Prevent manually modifying generic group length tags: This is |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
569 // handled by DCMTK serialization |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
570 return; |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
571 } |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
572 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
573 if (GetDcmtkObject().getDataset()->tagExists(ToDcmtkBridge::Convert(tag))) |
1980
ebce5f456b8e
new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1979
diff
changeset
|
574 { |
ebce5f456b8e
new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1979
diff
changeset
|
575 throw OrthancException(ErrorCode_AlreadyExistingTag); |
ebce5f456b8e
new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1979
diff
changeset
|
576 } |
ebce5f456b8e
new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1979
diff
changeset
|
577 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
578 if (decodeDataUriScheme && |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
579 value.type() == Json::stringValue && |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
580 (tag == DICOM_TAG_ENCAPSULATED_DOCUMENT || |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
581 tag == DICOM_TAG_PIXEL_DATA)) |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
582 { |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
583 if (EmbedContentInternal(value.asString())) |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
584 { |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
585 return; |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
586 } |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
587 } |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
588 |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
589 InvalidateCache(); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
590 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
591 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
592 Encoding encoding = DetectEncoding(hasCodeExtensions); |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
593 std::unique_ptr<DcmElement> element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
594 InsertInternal(*GetDcmtkObject().getDataset(), element.release()); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
595 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
596 |
790 | 597 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
598 void ParsedDicomFile::ReplacePlainString(const DicomTag& tag, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
599 const std::string& utf8Value) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
600 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
601 if (tag.IsPrivate()) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
602 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
603 throw OrthancException(ErrorCode_InternalError, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
604 "Cannot apply this function to private tags: " + tag.Format()); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
605 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
606 else |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
607 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
608 Replace(tag, utf8Value, false, DicomReplaceMode_InsertIfAbsent, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
609 "" /* not a private tag, so no private creator */); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
610 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
611 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
612 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
613 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
614 void ParsedDicomFile::SetIfAbsent(const DicomTag& tag, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
615 const std::string& utf8Value) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
616 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
617 std::string currentValue; |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
618 if (!GetTagValue(currentValue, tag)) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
619 { |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
620 ReplacePlainString(tag, utf8Value); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
621 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
622 } |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
623 |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
624 void ParsedDicomFile::RemovePrivateTags() |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
625 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
626 RemovePrivateTagsInternal(NULL); |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
627 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
628 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
629 void ParsedDicomFile::RemovePrivateTags(const std::set<DicomTag> &toKeep) |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
630 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
631 RemovePrivateTagsInternal(&toKeep); |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
632 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
633 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
634 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
635 static bool CanReplaceProceed(DcmDataset& dicom, |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
636 const DcmTagKey& tag, |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
637 DicomReplaceMode mode) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
638 { |
1979 | 639 if (dicom.findAndDeleteElement(tag).good()) |
790 | 640 { |
1979 | 641 // This tag was existing, it has been deleted |
642 return true; | |
643 } | |
644 else | |
645 { | |
646 // This tag was absent, act wrt. the specified "mode" | |
790 | 647 switch (mode) |
648 { | |
649 case DicomReplaceMode_InsertIfAbsent: | |
1979 | 650 return true; |
790 | 651 |
652 case DicomReplaceMode_ThrowIfAbsent: | |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
653 throw OrthancException(ErrorCode_InexistentItem, "Cannot replace inexistent tag: " + |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
654 FromDcmtkBridge::GetTagName(DicomTag(tag.getGroup(), tag.getElement()), "")); |
790 | 655 |
656 case DicomReplaceMode_IgnoreIfAbsent: | |
1979 | 657 return false; |
658 | |
659 default: | |
660 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
790 | 661 } |
662 } | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
663 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
664 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
665 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
666 void ParsedDicomFile::UpdateStorageUid(const DicomTag& tag, |
1695 | 667 const std::string& utf8Value, |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
668 bool decodeDataUriScheme) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
669 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
670 if (tag != DICOM_TAG_SOP_CLASS_UID && |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
671 tag != DICOM_TAG_SOP_INSTANCE_UID) |
790 | 672 { |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
673 return; |
790 | 674 } |
675 | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
676 std::string binary; |
1695 | 677 const std::string* decoded = &utf8Value; |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
678 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
679 if (decodeDataUriScheme && |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
680 boost::starts_with(utf8Value, URI_SCHEME_PREFIX_BINARY)) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
681 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
682 std::string mime; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
683 if (!Toolbox::DecodeDataUriScheme(mime, binary, utf8Value)) |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
684 { |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
685 throw OrthancException(ErrorCode_BadFileFormat); |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
686 } |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
687 |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
688 decoded = &binary; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
689 } |
1695 | 690 else |
691 { | |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
692 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
693 Encoding encoding = DetectEncoding(hasCodeExtensions); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
694 if (encoding != Encoding_Utf8) |
1695 | 695 { |
696 binary = Toolbox::ConvertFromUtf8(utf8Value, encoding); | |
697 decoded = &binary; | |
698 } | |
699 } | |
790 | 700 |
701 /** | |
702 * dcmodify will automatically correct 'Media Storage SOP Class | |
703 * UID' and 'Media Storage SOP Instance UID' in the metaheader, if | |
704 * you make changes to the related tags in the dataset ('SOP Class | |
705 * UID' and 'SOP Instance UID') via insert or modify mode | |
706 * options. You can disable this behaviour by using the -nmu | |
707 * option. | |
708 **/ | |
709 | |
710 if (tag == DICOM_TAG_SOP_CLASS_UID) | |
711 { | |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
712 ReplacePlainString(DICOM_TAG_MEDIA_STORAGE_SOP_CLASS_UID, *decoded); |
790 | 713 } |
714 | |
715 if (tag == DICOM_TAG_SOP_INSTANCE_UID) | |
716 { | |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
717 ReplacePlainString(DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID, *decoded); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
718 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
719 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
720 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
721 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
722 void ParsedDicomFile::Replace(const DicomTag& tag, |
1695 | 723 const std::string& utf8Value, |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
724 bool decodeDataUriScheme, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
725 DicomReplaceMode mode, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
726 const std::string& privateCreator) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
727 { |
2797
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
728 if (tag.GetElement() == 0x0000) |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
729 { |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
730 // Prevent manually modifying generic group length tags: This is |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
731 // handled by DCMTK serialization |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
732 return; |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
733 } |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
734 else |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
735 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
736 InvalidateCache(); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
737 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
738 DcmDataset& dicom = *GetDcmtkObject().getDataset(); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
739 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
740 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
741 // Either the tag was previously existing (and now removed), or |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
742 // the replace mode was set to "InsertIfAbsent" |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
743 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
744 if (decodeDataUriScheme && |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
745 (tag == DICOM_TAG_ENCAPSULATED_DOCUMENT || |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
746 tag == DICOM_TAG_PIXEL_DATA)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
747 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
748 if (EmbedContentInternal(utf8Value)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
749 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
750 return; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
751 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
752 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
753 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
754 std::unique_ptr<DcmElement> element(FromDcmtkBridge::CreateElementForTag(tag, privateCreator)); |
1979 | 755 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
756 if (!utf8Value.empty()) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
757 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
758 bool hasCodeExtensions; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
759 Encoding encoding = DetectEncoding(hasCodeExtensions); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
760 FromDcmtkBridge::FillElementWithString(*element, utf8Value, decodeDataUriScheme, encoding); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
761 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
762 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
763 InsertInternal(dicom, element.release()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
764 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
765 if (tag == DICOM_TAG_SOP_CLASS_UID || |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
766 tag == DICOM_TAG_SOP_INSTANCE_UID) |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
767 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
768 if (decodeDataUriScheme && |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
769 boost::starts_with(utf8Value, URI_SCHEME_PREFIX_BINARY)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
770 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
771 std::string mime, decoded; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
772 if (!Toolbox::DecodeDataUriScheme(mime, decoded, utf8Value)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
773 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
774 throw OrthancException(ErrorCode_BadFileFormat); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
775 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
776 else |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
777 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
778 UpdateStorageUid(tag, decoded, false); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
779 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
780 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
781 else |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
782 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
783 UpdateStorageUid(tag, utf8Value, false); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
784 } |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
785 } |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
786 } |
1979 | 787 } |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
788 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
789 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
790 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
791 void ParsedDicomFile::Replace(const DicomTag& tag, |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
792 const Json::Value& value, |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
793 bool decodeDataUriScheme, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
794 DicomReplaceMode mode, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
795 const std::string& privateCreator) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
796 { |
2797
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
797 if (tag.GetElement() == 0x0000) |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
798 { |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
799 // Prevent manually modifying generic group length tags: This is |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
800 // handled by DCMTK serialization |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
801 return; |
9a0c6a046cc2
Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
802 } |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
803 else if (value.type() == Json::stringValue) |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
804 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
805 Replace(tag, value.asString(), decodeDataUriScheme, mode, privateCreator); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
806 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
807 else |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
808 { |
1979 | 809 if (tag == DICOM_TAG_SOP_CLASS_UID || |
810 tag == DICOM_TAG_SOP_INSTANCE_UID) | |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
811 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
812 // Must be a string |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
813 throw OrthancException(ErrorCode_BadParameterType); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
814 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
815 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
816 InvalidateCache(); |
1979 | 817 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
818 DcmDataset& dicom = *GetDcmtkObject().getDataset(); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
819 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
820 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
821 // Either the tag was previously existing (and now removed), or |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
822 // the replace mode was set to "InsertIfAbsent" |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
823 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
824 bool hasCodeExtensions; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
825 Encoding encoding = DetectEncoding(hasCodeExtensions); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
826 InsertInternal(dicom, FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1689
diff
changeset
|
827 } |
790 | 828 } |
829 } | |
830 | |
831 | |
2394
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
832 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
833 void ParsedDicomFile::Answer(RestApiOutput& output) const |
790 | 834 { |
835 std::string serialized; | |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
836 if (FromDcmtkBridge::SaveToMemoryBuffer(serialized, *GetDcmtkObjectConst().getDataset())) |
790 | 837 { |
3901
603a7b86fa5f
route "/instances/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
838 output.AnswerBuffer(serialized, MimeType_Dicom); |
790 | 839 } |
840 } | |
2394
75c779ca948c
fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
841 #endif |
790 | 842 |
843 | |
844 bool ParsedDicomFile::GetTagValue(std::string& value, | |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
845 const DicomTag& tag) const |
790 | 846 { |
847 DcmTagKey k(tag.GetGroup(), tag.GetElement()); | |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
848 DcmDataset& dataset = *GetDcmtkObjectConst().getDataset(); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
849 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
850 if (tag.IsPrivate() || |
1655
e40fd0d925c5
/tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1641
diff
changeset
|
851 FromDcmtkBridge::IsUnknownTag(tag) || |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
852 tag == DICOM_TAG_PIXEL_DATA || |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
853 tag == DICOM_TAG_ENCAPSULATED_DOCUMENT) |
790 | 854 { |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
855 const Uint8* data = NULL; // This is freed in the destructor of the dataset |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
856 long unsigned int count = 0; |
790 | 857 |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
858 if (dataset.findAndGetUint8Array(k, data, &count).good()) |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
859 { |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
860 if (count > 0) |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
861 { |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
862 assert(data != NULL); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
863 value.assign(reinterpret_cast<const char*>(data), count); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
864 } |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
865 else |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
866 { |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
867 value.clear(); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
868 } |
790 | 869 |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
870 return true; |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
871 } |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
872 else |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
873 { |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
874 return false; |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
875 } |
790 | 876 } |
877 else | |
878 { | |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
879 DcmElement* element = NULL; |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
880 if (!dataset.findAndGetElement(k, element).good() || |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
881 element == NULL) |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
882 { |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
883 return false; |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
884 } |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
885 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
886 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
887 Encoding encoding = DetectEncoding(hasCodeExtensions); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
888 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
889 std::set<DicomTag> tmp; |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
890 std::unique_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
891 (*element, DicomToJsonFlags_Default, |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
892 0, encoding, hasCodeExtensions, tmp)); |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
893 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
894 if (v.get() == NULL || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
895 v->IsNull()) |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
896 { |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
897 value = ""; |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
898 } |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
899 else |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
900 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
901 // TODO v->IsBinary() |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
902 value = v->GetContent(); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
903 } |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
904 |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
905 return true; |
790 | 906 } |
907 } | |
908 | |
909 | |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
910 DicomInstanceHasher ParsedDicomFile::GetHasher() const |
790 | 911 { |
912 std::string patientId, studyUid, seriesUid, instanceUid; | |
913 | |
3446
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
914 if (!GetTagValue(patientId, DICOM_TAG_PATIENT_ID)) |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
915 { |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
916 /** |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
917 * If "PatientID" is absent, be tolerant by considering it |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
918 * equals the empty string, then proceed. In Orthanc <= 1.5.6, |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
919 * an exception "Bad file format" was generated. |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
920 * https://groups.google.com/d/msg/orthanc-users/aphG_h1AHVg/rfOTtTPTAgAJ |
3853 | 921 * https://hg.orthanc-server.com/orthanc/rev/4c45e018bd3de3cfa21d6efc6734673aaaee4435 |
3446
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
922 **/ |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
923 patientId.clear(); |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
924 } |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
925 |
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
926 if (!GetTagValue(studyUid, DICOM_TAG_STUDY_INSTANCE_UID) || |
790 | 927 !GetTagValue(seriesUid, DICOM_TAG_SERIES_INSTANCE_UID) || |
928 !GetTagValue(instanceUid, DICOM_TAG_SOP_INSTANCE_UID)) | |
929 { | |
3446
52da6e9335dd
Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3430
diff
changeset
|
930 throw OrthancException(ErrorCode_BadFileFormat, "missing StudyInstanceUID, SeriesInstanceUID or SOPInstanceUID"); |
790 | 931 } |
932 | |
933 return DicomInstanceHasher(patientId, studyUid, seriesUid, instanceUid); | |
934 } | |
935 | |
936 | |
937 void ParsedDicomFile::SaveToMemoryBuffer(std::string& buffer) | |
938 { | |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
939 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, *GetDcmtkObject().getDataset())) |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
940 { |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
941 throw OrthancException(ErrorCode_InternalError, "Cannot write DICOM file to memory"); |
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
942 } |
790 | 943 } |
944 | |
945 | |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
946 #if ORTHANC_SANDBOXED == 0 |
790 | 947 void ParsedDicomFile::SaveToFile(const std::string& path) |
948 { | |
949 // TODO Avoid using a temporary memory buffer, write directly on disk | |
950 std::string content; | |
951 SaveToMemoryBuffer(content); | |
2140 | 952 SystemToolbox::WriteFile(content, path); |
790 | 953 } |
2512
4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2499
diff
changeset
|
954 #endif |
790 | 955 |
956 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
957 ParsedDicomFile::ParsedDicomFile(bool createIdentifiers) : pimpl_(new PImpl) |
790 | 958 { |
794 | 959 pimpl_->file_.reset(new DcmFileFormat); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
960 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
961 if (createIdentifiers) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
962 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
963 ReplacePlainString(DICOM_TAG_PATIENT_ID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Patient)); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
964 ReplacePlainString(DICOM_TAG_STUDY_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Study)); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
965 ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Series)); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
966 ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance)); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
967 } |
790 | 968 } |
969 | |
791 | 970 |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
971 void ParsedDicomFile::CreateFromDicomMap(const DicomMap& source, |
3276
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
972 Encoding defaultEncoding, |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3948
diff
changeset
|
973 bool permissive, |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
974 const std::string& defaultPrivateCreator, |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
975 const std::map<uint16_t, std::string>& privateCreators) |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
976 { |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
977 pimpl_->file_.reset(new DcmFileFormat); |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3948
diff
changeset
|
978 InvalidateCache(); |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
979 |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
980 const DicomValue* tmp = source.TestAndGetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET); |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
981 |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
982 if (tmp == NULL) |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
983 { |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
984 SetEncoding(defaultEncoding); |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
985 } |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
986 else if (tmp->IsBinary()) |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
987 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
988 throw OrthancException(ErrorCode_ParameterOutOfRange, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
989 "Invalid binary string in the SpecificCharacterSet (0008,0005) tag"); |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
990 } |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
991 else if (tmp->IsNull() || |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
992 tmp->GetContent().empty()) |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
993 { |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
994 SetEncoding(defaultEncoding); |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
995 } |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
996 else |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
997 { |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
998 Encoding encoding; |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
999 |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
1000 if (GetDicomEncoding(encoding, tmp->GetContent().c_str())) |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1001 { |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
1002 SetEncoding(encoding); |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1003 } |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1004 else |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1005 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1006 throw OrthancException(ErrorCode_ParameterOutOfRange, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1007 "Unsupported value for the SpecificCharacterSet (0008,0005) tag: \"" + |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1008 tmp->GetContent() + "\""); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1009 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1010 } |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
1011 |
3651
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1012 for (DicomMap::Content::const_iterator |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1013 it = source.content_.begin(); it != source.content_.end(); ++it) |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1014 { |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
1015 if (it->first != DICOM_TAG_SPECIFIC_CHARACTER_SET && |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
1016 !it->second->IsNull()) |
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
1017 { |
3276
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1018 try |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1019 { |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3948
diff
changeset
|
1020 // Same as "ReplacePlainString()", but with support for private creator |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3948
diff
changeset
|
1021 const std::string& utf8Value = it->second->GetContent(); |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1022 |
4039 | 1023 std::map<uint16_t, std::string>::const_iterator found = privateCreators.find(it->first.GetGroup()); |
1024 | |
1025 if (it->first.IsPrivate() && | |
1026 found != privateCreators.end()) | |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1027 { |
4039 | 1028 Replace(it->first, utf8Value, false, DicomReplaceMode_InsertIfAbsent, found->second); |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1029 } |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1030 else |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1031 { |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1032 Replace(it->first, utf8Value, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator); |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1033 } |
3276
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1034 } |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1035 catch (OrthancException&) |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1036 { |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1037 if (!permissive) |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1038 { |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1039 throw; |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1040 } |
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1041 } |
2846
d386abc18133
simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2797
diff
changeset
|
1042 } |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1043 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1044 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1045 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1046 ParsedDicomFile::ParsedDicomFile(const DicomMap& map, |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1047 Encoding defaultEncoding, |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1048 bool permissive) : |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1049 pimpl_(new PImpl) |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1050 { |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1051 std::map<uint16_t, std::string> noPrivateCreators; |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1052 CreateFromDicomMap(map, defaultEncoding, permissive, "" /* no default private creator */, noPrivateCreators); |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1053 } |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1054 |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
1055 |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1056 ParsedDicomFile::ParsedDicomFile(const DicomMap& map, |
3276
9b0e67161600
More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
1057 Encoding defaultEncoding, |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3948
diff
changeset
|
1058 bool permissive, |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1059 const std::string& defaultPrivateCreator, |
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1060 const std::map<uint16_t, std::string>& privateCreators) : |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1061 pimpl_(new PImpl) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1062 { |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4013
diff
changeset
|
1063 CreateFromDicomMap(map, defaultEncoding, permissive, defaultPrivateCreator, privateCreators); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1064 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1065 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1066 |
1800
30e97a1f4093
callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
1067 ParsedDicomFile::ParsedDicomFile(const void* content, |
30e97a1f4093
callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
1068 size_t size) : pimpl_(new PImpl) |
791 | 1069 { |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1070 pimpl_->file_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(content, size)); |
791 | 1071 } |
1072 | |
794 | 1073 ParsedDicomFile::ParsedDicomFile(const std::string& content) : pimpl_(new PImpl) |
791 | 1074 { |
1075 if (content.size() == 0) | |
1076 { | |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1077 pimpl_->file_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(NULL, 0)); |
791 | 1078 } |
1079 else | |
1080 { | |
1935
e251606c1433
FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1934
diff
changeset
|
1081 pimpl_->file_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(&content[0], content.size())); |
791 | 1082 } |
1083 } | |
792 | 1084 |
1085 | |
4200 | 1086 ParsedDicomFile::ParsedDicomFile(const ParsedDicomFile& other, |
2521
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
1087 bool keepSopInstanceUid) : |
794 | 1088 pimpl_(new PImpl) |
792 | 1089 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1090 pimpl_->file_.reset(dynamic_cast<DcmFileFormat*>(other.GetDcmtkObjectConst().clone())); |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1091 |
2521
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
1092 if (!keepSopInstanceUid) |
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
1093 { |
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
1094 // Create a new instance-level identifier |
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
1095 ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance)); |
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
1096 } |
792 | 1097 } |
1098 | |
1099 | |
1788
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1100 ParsedDicomFile::ParsedDicomFile(DcmDataset& dicom) : pimpl_(new PImpl) |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1101 { |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1102 pimpl_->file_.reset(new DcmFileFormat(&dicom)); |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1103 } |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1104 |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1105 |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1106 ParsedDicomFile::ParsedDicomFile(DcmFileFormat& dicom) : pimpl_(new PImpl) |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1107 { |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1108 pimpl_->file_.reset(new DcmFileFormat(dicom)); |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1109 } |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1110 |
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1111 |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
1112 ParsedDicomFile::ParsedDicomFile(DcmFileFormat* dicom) : pimpl_(new PImpl) |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
1113 { |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
1114 pimpl_->file_.reset(dicom); // No cloning |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
1115 } |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
1116 |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3901
diff
changeset
|
1117 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1118 DcmFileFormat& ParsedDicomFile::GetDcmtkObjectConst() const |
793 | 1119 { |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1120 if (pimpl_->file_.get() == NULL) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1121 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1122 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1123 "ReleaseDcmtkObject() was called"); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1124 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1125 else |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1126 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1127 return *pimpl_->file_; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1128 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1129 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1130 |
4297 | 1131 ParsedDicomFile *ParsedDicomFile::AcquireDcmtkObject(DcmFileFormat *dicom) // No clone here |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1132 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1133 return new ParsedDicomFile(dicom); |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1134 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1135 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1136 DcmFileFormat &ParsedDicomFile::GetDcmtkObject() |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1137 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1138 return GetDcmtkObjectConst(); |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1139 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1140 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1141 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1142 DcmFileFormat* ParsedDicomFile::ReleaseDcmtkObject() |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1143 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1144 if (pimpl_->file_.get() == NULL) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1145 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1146 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1147 "ReleaseDcmtkObject() was called"); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1148 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1149 else |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1150 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1151 pimpl_->frameIndex_.reset(NULL); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1152 return pimpl_->file_.release(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1153 } |
793 | 1154 } |
1155 | |
1156 | |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1157 ParsedDicomFile* ParsedDicomFile::Clone(bool keepSopInstanceUid) const |
793 | 1158 { |
2521
6db878376018
support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2512
diff
changeset
|
1159 return new ParsedDicomFile(*this, keepSopInstanceUid); |
793 | 1160 } |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1161 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1162 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1163 bool ParsedDicomFile::EmbedContentInternal(const std::string& dataUriScheme) |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1164 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1165 std::string mimeString, content; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1166 if (!Toolbox::DecodeDataUriScheme(mimeString, content, dataUriScheme)) |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
1167 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1168 return false; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
1169 } |
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1980
diff
changeset
|
1170 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1171 Toolbox::ToLowerCase(mimeString); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1172 MimeType mime = StringToMimeType(mimeString); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1173 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1174 switch (mime) |
1562 | 1175 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1176 case MimeType_Png: |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
1177 #if ORTHANC_ENABLE_PNG == 1 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1178 EmbedImage(mime, content); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1179 break; |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
1180 #else |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1181 throw OrthancException(ErrorCode_NotImplemented, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1182 "Orthanc was compiled without support of PNG"); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1183 #endif |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1184 |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1185 case MimeType_Jpeg: |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1186 #if ORTHANC_ENABLE_JPEG == 1 |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1187 EmbedImage(mime, content); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1188 break; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1189 #else |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1190 throw OrthancException(ErrorCode_NotImplemented, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1191 "Orthanc was compiled without support of JPEG"); |
2380
96b3ec054b69
reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2310
diff
changeset
|
1192 #endif |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1193 |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1194 case MimeType_Pam: |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1195 EmbedImage(mime, content); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1196 break; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1197 |
4845
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1198 case MimeType_Binary: |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1199 EmbedImage(mime, content); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1200 break; |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1201 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1202 case MimeType_Pdf: |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1203 EmbedPdf(content); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1204 break; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1205 |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1206 default: |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1207 throw OrthancException(ErrorCode_NotImplemented, |
2989 | 1208 "Unsupported MIME type for the content of a new DICOM file: " + |
1209 std::string(EnumerationToString(mime))); | |
1562 | 1210 } |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1211 |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1212 return true; |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1213 } |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1214 |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1215 |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1216 void ParsedDicomFile::EmbedContent(const std::string& dataUriScheme) |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1217 { |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1218 if (!EmbedContentInternal(dataUriScheme)) |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1219 { |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1220 throw OrthancException(ErrorCode_BadFileFormat); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1221 } |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1222 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1223 |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1224 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1225 void ParsedDicomFile::EmbedImage(MimeType mime, |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1226 const std::string& content) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1227 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1228 switch (mime) |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1229 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1230 |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1231 #if ORTHANC_ENABLE_JPEG == 1 |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1232 case MimeType_Jpeg: |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1233 { |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1234 JpegReader reader; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1235 reader.ReadFromMemory(content); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1236 EmbedImage(reader); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1237 break; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1238 } |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1239 #endif |
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1240 |
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1241 #if ORTHANC_ENABLE_PNG == 1 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1242 case MimeType_Png: |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1243 { |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1244 PngReader reader; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1245 reader.ReadFromMemory(content); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1246 EmbedImage(reader); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1247 break; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1248 } |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1249 #endif |
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1250 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1251 case MimeType_Pam: |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1252 { |
4211
afad57ac30ef
enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4203
diff
changeset
|
1253 // "true" means "enforce memory alignment": This is slower, |
afad57ac30ef
enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4203
diff
changeset
|
1254 // but possibly avoids crash related to non-aligned memory access |
afad57ac30ef
enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4203
diff
changeset
|
1255 PamReader reader(true); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1256 reader.ReadFromMemory(content); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1257 EmbedImage(reader); |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1258 break; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1259 } |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1260 |
4845
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1261 case MimeType_Binary: |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1262 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1263 EmbedRawPixelData(content); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1264 break; |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1265 } |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1266 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1267 default: |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1268 throw OrthancException(ErrorCode_NotImplemented); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1269 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1270 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1271 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1272 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1273 void ParsedDicomFile::EmbedImage(const ImageAccessor& accessor) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1274 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1275 if (accessor.GetFormat() != PixelFormat_Grayscale8 && |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1276 accessor.GetFormat() != PixelFormat_Grayscale16 && |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1277 accessor.GetFormat() != PixelFormat_SignedGrayscale16 && |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1278 accessor.GetFormat() != PixelFormat_RGB24 && |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1279 accessor.GetFormat() != PixelFormat_RGBA32) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1280 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1281 throw OrthancException(ErrorCode_NotImplemented); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1282 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1283 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1284 InvalidateCache(); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1285 |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1286 if (accessor.GetFormat() == PixelFormat_RGBA32) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1287 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1288 LOG(WARNING) << "Getting rid of the alpha channel when embedding a RGBA image inside DICOM"; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1289 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1290 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1291 // http://dicomiseasy.blogspot.be/2012/08/chapter-12-pixel-data.html |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1292 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1293 Remove(DICOM_TAG_PIXEL_DATA); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1294 ReplacePlainString(DICOM_TAG_COLUMNS, boost::lexical_cast<std::string>(accessor.GetWidth())); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1295 ReplacePlainString(DICOM_TAG_ROWS, boost::lexical_cast<std::string>(accessor.GetHeight())); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1296 ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "1"); |
2910
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1297 |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1298 // The "Number of frames" must only be present in multi-frame images |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1299 //ReplacePlainString(DICOM_TAG_NUMBER_OF_FRAMES, "1"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1300 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1301 if (accessor.GetFormat() == PixelFormat_SignedGrayscale16) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1302 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1303 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "1"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1304 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1305 else |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1306 { |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1307 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "0"); // Unsigned pixels |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1308 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1309 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1310 unsigned int bytesPerPixel = 0; |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1311 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1312 switch (accessor.GetFormat()) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1313 { |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1314 case PixelFormat_Grayscale8: |
2910
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1315 // By default, grayscale images are MONOCHROME2 |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1316 SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2"); |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1317 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1318 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1319 ReplacePlainString(DICOM_TAG_BITS_STORED, "8"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1320 ReplacePlainString(DICOM_TAG_HIGH_BIT, "7"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1321 bytesPerPixel = 1; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1322 break; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1323 |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1324 case PixelFormat_RGB24: |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1325 case PixelFormat_RGBA32: |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1326 ReplacePlainString(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "RGB"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1327 ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "3"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1328 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1329 ReplacePlainString(DICOM_TAG_BITS_STORED, "8"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1330 ReplacePlainString(DICOM_TAG_HIGH_BIT, "7"); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1331 bytesPerPixel = 3; |
2910
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1332 |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1333 // "Planar configuration" must only present if "Samples per |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1334 // Pixel" is greater than 1 |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1335 ReplacePlainString(DICOM_TAG_PLANAR_CONFIGURATION, "0"); // Color channels are interleaved |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1336 |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1337 break; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1338 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1339 case PixelFormat_Grayscale16: |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1340 case PixelFormat_SignedGrayscale16: |
2910
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1341 // By default, grayscale images are MONOCHROME2 |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1342 SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2"); |
83133583183d
minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1343 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1344 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "16"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1345 ReplacePlainString(DICOM_TAG_BITS_STORED, "16"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1346 ReplacePlainString(DICOM_TAG_HIGH_BIT, "15"); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1347 bytesPerPixel = 2; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1348 break; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1349 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1350 default: |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1351 throw OrthancException(ErrorCode_NotImplemented); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1352 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1353 |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1354 assert(bytesPerPixel != 0); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1935
diff
changeset
|
1355 |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1356 DcmTag key(DICOM_TAG_PIXEL_DATA.GetGroup(), |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1357 DICOM_TAG_PIXEL_DATA.GetElement()); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1358 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1359 std::unique_ptr<DcmPixelData> pixels(new DcmPixelData(key)); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1360 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1361 unsigned int pitch = accessor.GetWidth() * bytesPerPixel; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1362 Uint8* target = NULL; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1363 pixels->createUint8Array(accessor.GetHeight() * pitch, target); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1364 |
4278
9279de56a405
avoid multiple calls to GetWidth() and GetHeight() on pixel loops
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1365 const unsigned int height = accessor.GetHeight(); |
9279de56a405
avoid multiple calls to GetWidth() and GetHeight() on pixel loops
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1366 const unsigned int width = accessor.GetWidth(); |
9279de56a405
avoid multiple calls to GetWidth() and GetHeight() on pixel loops
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1367 |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1368 { |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1369 Uint8* q = target; |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1370 for (unsigned int y = 0; y < height; y++) |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1371 { |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1372 switch (accessor.GetFormat()) |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1373 { |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1374 case PixelFormat_RGB24: |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1375 case PixelFormat_Grayscale8: |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1376 case PixelFormat_Grayscale16: |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1377 case PixelFormat_SignedGrayscale16: |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1378 { |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1379 memcpy(q, reinterpret_cast<const Uint8*>(accessor.GetConstRow(y)), pitch); |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1380 q += pitch; |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1381 break; |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1382 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1383 |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1384 case PixelFormat_RGBA32: |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1385 { |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1386 // The alpha channel is not supported by the DICOM standard |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1387 const Uint8* source = reinterpret_cast<const Uint8*>(accessor.GetConstRow(y)); |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1388 for (unsigned int x = 0; x < width; x++, q += 3, source += 4) |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1389 { |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1390 q[0] = source[0]; |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1391 q[1] = source[1]; |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1392 q[2] = source[2]; |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1393 } |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1394 |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1395 break; |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1396 } |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1397 |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1398 default: |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1399 throw OrthancException(ErrorCode_NotImplemented); |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1400 } |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1401 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1402 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1403 |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1404 static const Endianness ENDIANNESS = Toolbox::DetectEndianness(); |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1405 if (ENDIANNESS == Endianness_Big && |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1406 (accessor.GetFormat() == PixelFormat_Grayscale16 || |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1407 accessor.GetFormat() == PixelFormat_SignedGrayscale16)) |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1408 { |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1409 // New in Orthanc 1.9.1 |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1410 assert(pitch % 2 == 0); |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1411 swapBytes(target, accessor.GetHeight() * pitch, sizeof(uint16_t)); |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1412 } |
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
1413 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1414 if (!GetDcmtkObject().getDataset()->insert(pixels.release(), false, false).good()) |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1415 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1416 throw OrthancException(ErrorCode_InternalError); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1417 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
799
diff
changeset
|
1418 } |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
1419 |
4845
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1420 void ParsedDicomFile::EmbedRawPixelData(const std::string& content) |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1421 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1422 DcmTag key(DICOM_TAG_PIXEL_DATA.GetGroup(), |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1423 DICOM_TAG_PIXEL_DATA.GetElement()); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1424 |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1425 std::unique_ptr<DcmPixelData> pixels(new DcmPixelData(key)); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1426 |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1427 Uint8* target = NULL; |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1428 pixels->createUint8Array(content.size(), target); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1429 memcpy(target, content.c_str(), content.size()); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1430 |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1431 if (!GetDcmtkObject().getDataset()->insert(pixels.release(), false, false).good()) |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1432 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1433 throw OrthancException(ErrorCode_InternalError); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1434 } |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1435 } |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1436 |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
1437 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
1438 Encoding ParsedDicomFile::DetectEncoding(bool& hasCodeExtensions) const |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1439 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
1440 return FromDcmtkBridge::DetectEncoding(hasCodeExtensions, |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1441 *GetDcmtkObjectConst().getDataset(), |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
1442 GetDefaultDicomEncoding()); |
956
2fd5a163776d
primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1443 } |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1444 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1445 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1446 void ParsedDicomFile::SetEncoding(Encoding encoding) |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1447 { |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1448 if (encoding == Encoding_Windows1251) |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1449 { |
1558
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1450 // This Cyrillic codepage is not officially supported by the |
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1451 // DICOM standard. Do not set the SpecificCharacterSet tag. |
124de28b32ed
fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1452 return; |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1453 } |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1454 |
1565
4b23310eb7e8
add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1564
diff
changeset
|
1455 std::string s = GetDicomSpecificCharacterSet(encoding); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1456 ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, s); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1457 } |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1018
diff
changeset
|
1458 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
1459 void ParsedDicomFile::DatasetToJson(Json::Value& target, |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
1460 DicomToJsonFormat format, |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
1461 DicomToJsonFlags flags, |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1462 unsigned int maxStringLength) const |
1160
80671157d051
generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1113
diff
changeset
|
1463 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1464 std::set<DicomTag> ignoreTagLength; |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1465 FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObjectConst().getDataset(), |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4139
diff
changeset
|
1466 format, flags, maxStringLength, ignoreTagLength); |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1467 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1468 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1469 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1470 void ParsedDicomFile::DatasetToJson(Json::Value& target, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1471 DicomToJsonFormat format, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1472 DicomToJsonFlags flags, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1473 unsigned int maxStringLength, |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1474 const std::set<DicomTag>& ignoreTagLength) const |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2394
diff
changeset
|
1475 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1476 FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObjectConst().getDataset(), |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4139
diff
changeset
|
1477 format, flags, maxStringLength, ignoreTagLength); |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
1478 } |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
1479 |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
1480 |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1827
diff
changeset
|
1481 void ParsedDicomFile::HeaderToJson(Json::Value& target, |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1482 DicomToJsonFormat format) const |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1827
diff
changeset
|
1483 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1484 FromDcmtkBridge::ExtractHeaderAsJson(target, *GetDcmtkObjectConst().getMetaInfo(), format, DicomToJsonFlags_None, 0); |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1827
diff
changeset
|
1485 } |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1827
diff
changeset
|
1486 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1827
diff
changeset
|
1487 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1488 bool ParsedDicomFile::HasTag(const DicomTag& tag) const |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1489 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1490 DcmTag key(tag.GetGroup(), tag.GetElement()); |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1491 return GetDcmtkObjectConst().getDataset()->tagExists(key); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1492 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1493 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1494 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1495 void ParsedDicomFile::EmbedPdf(const std::string& pdf) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1496 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1497 if (pdf.size() < 5 || // (*) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1498 strncmp("%PDF-", pdf.c_str(), 5) != 0) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1499 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2924
diff
changeset
|
1500 throw OrthancException(ErrorCode_BadFileFormat, "Not a PDF file"); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1501 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1502 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1503 InvalidateCache(); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1504 |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1505 ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, UID_EncapsulatedPDFStorage); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1506 ReplacePlainString(FromDcmtkBridge::Convert(DCM_Modality), "OT"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1507 ReplacePlainString(FromDcmtkBridge::Convert(DCM_ConversionType), "WSD"); |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1508 ReplacePlainString(FromDcmtkBridge::Convert(DCM_MIMETypeOfEncapsulatedDocument), MIME_PDF); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1509 //ReplacePlainString(FromDcmtkBridge::Convert(DCM_SeriesNumber), "1"); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1510 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1511 std::unique_ptr<DcmPolymorphOBOW> element(new DcmPolymorphOBOW(DCM_EncapsulatedDocument)); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1512 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1513 size_t s = pdf.size(); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1514 if (s & 1) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1515 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1516 // The size of the buffer must be even |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1517 s += 1; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1518 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1519 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1520 Uint8* bytes = NULL; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1521 OFCondition result = element->createUint8Array(s, bytes); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1522 if (!result.good() || bytes == NULL) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1523 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1524 throw OrthancException(ErrorCode_NotEnoughMemory); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1525 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1526 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1527 // Blank pad byte (no access violation, as "pdf.size() >= 5" because of (*) ) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1528 bytes[s - 1] = 0; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1529 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1530 memcpy(bytes, pdf.c_str(), pdf.size()); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1531 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1532 DcmPolymorphOBOW* obj = element.release(); |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1533 result = GetDcmtkObject().getDataset()->insert(obj); |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1534 |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1535 if (!result.good()) |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1536 { |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1537 delete obj; |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1538 throw OrthancException(ErrorCode_NotEnoughMemory); |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1539 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1540 } |
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1523
diff
changeset
|
1541 |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1542 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1543 bool ParsedDicomFile::ExtractPdf(std::string& pdf) const |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1544 { |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1545 std::string sop, mime; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1546 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1547 if (!GetTagValue(sop, DICOM_TAG_SOP_CLASS_UID) || |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1548 !GetTagValue(mime, FromDcmtkBridge::Convert(DCM_MIMETypeOfEncapsulatedDocument)) || |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1549 sop != UID_EncapsulatedPDFStorage || |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2889
diff
changeset
|
1550 mime != MIME_PDF) |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1551 { |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1552 return false; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1553 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1554 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1555 if (!GetTagValue(pdf, DICOM_TAG_ENCAPSULATED_DOCUMENT)) |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1556 { |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1557 return false; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1558 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1559 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1560 // Strip the possible pad byte at the end of file, because the |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1561 // encapsulated documents must always have an even length. The PDF |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1562 // format expects files to end with %%EOF followed by CR/LF. If |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1563 // the last character of the file is not a CR or LF, we assume it |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1564 // is a pad byte and remove it. |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1565 if (pdf.size() > 0) |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1566 { |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1567 char last = *pdf.rbegin(); |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1568 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1569 if (last != 10 && last != 13) |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1570 { |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1571 pdf.resize(pdf.size() - 1); |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1572 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1573 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1574 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1575 return true; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1576 } |
1662
09be34b2f30e
ParsedDicomFile::Convert()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1655
diff
changeset
|
1577 |
09be34b2f30e
ParsedDicomFile::Convert()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1655
diff
changeset
|
1578 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1579 ParsedDicomFile* ParsedDicomFile::CreateFromJson(const Json::Value& json, |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1580 DicomFromJsonFlags flags, |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1581 const std::string& privateCreator) |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1582 { |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1583 const bool generateIdentifiers = (flags & DicomFromJsonFlags_GenerateIdentifiers) ? true : false; |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1584 const bool decodeDataUriScheme = (flags & DicomFromJsonFlags_DecodeDataUriScheme) ? true : false; |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1585 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1586 std::unique_ptr<ParsedDicomFile> result(new ParsedDicomFile(generateIdentifiers)); |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2380
diff
changeset
|
1587 result->SetEncoding(FromDcmtkBridge::ExtractEncoding(json, GetDefaultDicomEncoding())); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1588 |
1934
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
1589 const Json::Value::Members tags = json.getMemberNames(); |
72a2fd7fed8b
FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
1590 |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1591 for (size_t i = 0; i < tags.size(); i++) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1592 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1593 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1594 const Json::Value& value = json[tags[i]]; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1595 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1596 if (tag == DICOM_TAG_PIXEL_DATA || |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1597 tag == DICOM_TAG_ENCAPSULATED_DOCUMENT) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1598 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1599 if (value.type() != Json::stringValue) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1600 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1601 throw OrthancException(ErrorCode_BadRequest); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1602 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1603 else |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1604 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1605 result->EmbedContent(value.asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1606 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1607 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1608 else if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1609 { |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
1610 result->Replace(tag, value, decodeDataUriScheme, DicomReplaceMode_InsertIfAbsent, privateCreator); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1611 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1612 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1613 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1614 return result.release(); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
1615 } |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1616 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1617 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1618 void ParsedDicomFile::GetRawFrame(std::string& target, |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1619 MimeType& mime, |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1620 unsigned int frameId) const |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1621 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1622 if (pimpl_->frameIndex_.get() == NULL) |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1623 { |
3745
113a7b994a12
extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
1624 assert(pimpl_->file_ != NULL && |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1625 GetDcmtkObjectConst().getDataset() != NULL); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1626 pimpl_->frameIndex_.reset(new DicomFrameIndex(*GetDcmtkObjectConst().getDataset())); |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1627 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1628 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1629 pimpl_->frameIndex_->GetRawFrame(target, frameId); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1630 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1631 E_TransferSyntax transferSyntax = GetDcmtkObjectConst().getDataset()->getCurrentXfer(); |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1632 switch (transferSyntax) |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1633 { |
1946
40b7a0176305
fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1945
diff
changeset
|
1634 case EXS_JPEGProcess1: |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1635 mime = MimeType_Jpeg; |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1636 break; |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1637 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1638 case EXS_JPEG2000LosslessOnly: |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1639 case EXS_JPEG2000: |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1640 mime = MimeType_Jpeg2000; |
2016 | 1641 break; |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1642 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1643 default: |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1644 mime = MimeType_Binary; |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1645 break; |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1646 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1647 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1648 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1649 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1650 void ParsedDicomFile::InvalidateCache() |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1651 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1652 pimpl_->frameIndex_.reset(NULL); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1913
diff
changeset
|
1653 } |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1946
diff
changeset
|
1654 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1946
diff
changeset
|
1655 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1946
diff
changeset
|
1656 unsigned int ParsedDicomFile::GetFramesCount() const |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1946
diff
changeset
|
1657 { |
3745
113a7b994a12
extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
1658 assert(pimpl_->file_ != NULL && |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1659 GetDcmtkObjectConst().getDataset() != NULL); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1660 return DicomFrameIndex::GetFramesCount(*GetDcmtkObjectConst().getDataset()); |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1946
diff
changeset
|
1661 } |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1662 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1663 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1664 void ParsedDicomFile::ChangeEncoding(Encoding target) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1665 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
1666 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
1667 Encoding source = DetectEncoding(hasCodeExtensions); |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1668 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1669 if (source != target) // Avoid unnecessary conversion |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1670 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1671 ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, GetDicomSpecificCharacterSet(target)); |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3912
diff
changeset
|
1672 FromDcmtkBridge::ChangeStringEncoding(*GetDcmtkObject().getDataset(), source, hasCodeExtensions, target); |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1673 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1674 } |
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
|
1675 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
1676 |
4139
a4f28efdfccf
"maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
1677 void ParsedDicomFile::ExtractDicomSummary(DicomMap& target, |
a4f28efdfccf
"maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
1678 unsigned int maxTagLength) const |
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
|
1679 { |
4137
6774605d4341
keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4136
diff
changeset
|
1680 std::set<DicomTag> ignoreTagLength; |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1681 FromDcmtkBridge::ExtractDicomSummary(target, *GetDcmtkObjectConst().getDataset(), |
4139
a4f28efdfccf
"maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
1682 maxTagLength, ignoreTagLength); |
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
|
1683 } |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
1684 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2207
diff
changeset
|
1685 |
3577
33cfcc74d1b1
argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3446
diff
changeset
|
1686 void ParsedDicomFile::ExtractDicomSummary(DicomMap& target, |
4139
a4f28efdfccf
"maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
1687 unsigned int maxTagLength, |
3577
33cfcc74d1b1
argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3446
diff
changeset
|
1688 const std::set<DicomTag>& ignoreTagLength) const |
33cfcc74d1b1
argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3446
diff
changeset
|
1689 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1690 FromDcmtkBridge::ExtractDicomSummary(target, *GetDcmtkObjectConst().getDataset(), |
4139
a4f28efdfccf
"maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
1691 maxTagLength, ignoreTagLength); |
3577
33cfcc74d1b1
argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3446
diff
changeset
|
1692 } |
33cfcc74d1b1
argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3446
diff
changeset
|
1693 |
33cfcc74d1b1
argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3446
diff
changeset
|
1694 |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1695 bool ParsedDicomFile::LookupTransferSyntax(DicomTransferSyntax& result) const |
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
|
1696 { |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1697 return FromDcmtkBridge::LookupOrthancTransferSyntax(result, GetDcmtkObjectConst()); |
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
|
1698 } |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1699 |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1700 |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1701 bool ParsedDicomFile::LookupPhotometricInterpretation(PhotometricInterpretation& result) const |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1702 { |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1703 DcmTagKey k(DICOM_TAG_PHOTOMETRIC_INTERPRETATION.GetGroup(), |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1704 DICOM_TAG_PHOTOMETRIC_INTERPRETATION.GetElement()); |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1705 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1706 DcmDataset& dataset = *GetDcmtkObjectConst().getDataset(); |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1707 |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1708 const char *c = NULL; |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1709 if (dataset.findAndGetString(k, c).good() && |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1710 c != NULL) |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1711 { |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1712 result = StringToPhotometricInterpretation(c); |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1713 return true; |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1714 } |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1715 else |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1716 { |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1717 return false; |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1718 } |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
1719 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1720 |
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1721 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1722 void ParsedDicomFile::Apply(ITagVisitor& visitor) const |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1723 { |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1724 FromDcmtkBridge::Apply(*GetDcmtkObjectConst().getDataset(), visitor, GetDefaultDicomEncoding()); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1725 } |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1726 |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1727 |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1728 ImageAccessor* ParsedDicomFile::DecodeFrame(unsigned int frame) const |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1729 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1730 if (GetDcmtkObjectConst().getDataset() == NULL) |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1731 { |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1732 throw OrthancException(ErrorCode_InternalError); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1733 } |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1734 else |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1735 { |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1736 return DicomImageDecoder::Decode(*GetDcmtkObjectConst().getDataset(), frame); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
1737 } |
2499
83b8b6743531
ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1738 } |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1739 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1740 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1741 static bool HasGenericGroupLength(const DicomPath& path) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1742 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1743 for (size_t i = 0; i < path.GetPrefixLength(); i++) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1744 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1745 if (path.GetPrefixTag(i).GetElement() == 0x0000) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1746 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1747 return true; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1748 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1749 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1750 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1751 return (path.GetFinalTag().GetElement() == 0x0000); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1752 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1753 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1754 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1755 void ParsedDicomFile::ReplacePath(const DicomPath& path, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1756 const Json::Value& value, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1757 bool decodeDataUriScheme, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1758 DicomReplaceMode mode, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1759 const std::string& privateCreator) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1760 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1761 if (HasGenericGroupLength(path)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1762 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1763 // Prevent manually modifying generic group length tags: This is |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1764 // handled by DCMTK serialization |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1765 return; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1766 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1767 else if (path.GetPrefixLength() == 0) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1768 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1769 Replace(path.GetFinalTag(), value, decodeDataUriScheme, mode, privateCreator); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1770 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1771 else |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1772 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1773 InvalidateCache(); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1774 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1775 bool hasCodeExtensions; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1776 Encoding encoding = DetectEncoding(hasCodeExtensions); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1777 std::unique_ptr<DcmElement> element( |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1778 FromDcmtkBridge::FromJson(path.GetFinalTag(), value, decodeDataUriScheme, encoding, privateCreator)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1779 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1780 FromDcmtkBridge::ReplacePath(*GetDcmtkObject().getDataset(), path, *element, mode); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1781 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1782 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1783 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1784 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1785 void ParsedDicomFile::RemovePath(const DicomPath& path) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1786 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1787 InvalidateCache(); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1788 FromDcmtkBridge::RemovePath(*GetDcmtkObject().getDataset(), path); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1789 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1790 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1791 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1792 void ParsedDicomFile::ClearPath(const DicomPath& path, |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1793 bool onlyIfExists) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1794 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1795 if (HasGenericGroupLength(path)) |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1796 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1797 // Prevent manually modifying generic group length tags: This is |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1798 // handled by DCMTK serialization |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1799 return; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1800 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1801 else |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1802 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1803 InvalidateCache(); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1804 FromDcmtkBridge::ClearPath(*GetDcmtkObject().getDataset(), path, onlyIfExists); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1805 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1806 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1807 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4588
diff
changeset
|
1808 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1809 bool ParsedDicomFile::LookupSequenceItem(DicomMap& target, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1810 const DicomPath& path, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1811 size_t sequenceIndex) const |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1812 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1813 DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset(); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1814 return FromDcmtkBridge::LookupSequenceItem(target, dataset, path, sequenceIndex); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1815 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1816 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1817 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1818 void ParsedDicomFile::GetDefaultWindowing(double& windowCenter, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1819 double& windowWidth, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1820 unsigned int frame) const |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
1821 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
1822 DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset(); |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1823 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1824 const char* wc = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1825 const char* ww = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1826 DcmItem *item1 = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1827 DcmItem *item2 = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1828 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1829 if (dataset.findAndGetString(DCM_WindowCenter, wc).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1830 dataset.findAndGetString(DCM_WindowWidth, ww).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1831 wc != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1832 ww != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1833 SerializationToolbox::ParseFirstDouble(windowCenter, wc) && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1834 SerializationToolbox::ParseFirstDouble(windowWidth, ww)) |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1835 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1836 return; // OK |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1837 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1838 else if (dataset.findAndGetSequenceItem(DCM_PerFrameFunctionalGroupsSequence, item1, frame).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1839 item1 != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1840 item1->findAndGetSequenceItem(DCM_FrameVOILUTSequence, item2, 0).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1841 item2 != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1842 item2->findAndGetString(DCM_WindowCenter, wc).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1843 item2->findAndGetString(DCM_WindowWidth, ww).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1844 wc != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1845 ww != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1846 SerializationToolbox::ParseFirstDouble(windowCenter, wc) && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1847 SerializationToolbox::ParseFirstDouble(windowWidth, ww)) |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1848 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1849 // New in Orthanc 1.9.7, to deal with Philips multiframe images |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1850 // (cf. private mail from Tomas Kenda on 2021-08-17) |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1851 return; // OK |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1852 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1853 else |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1854 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1855 Uint16 bitsStored = 0; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1856 if (!dataset.findAndGetUint16(DCM_BitsStored, bitsStored).good() || |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1857 bitsStored == 0) |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1858 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1859 bitsStored = 8; // Rough assumption |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1860 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1861 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1862 windowWidth = static_cast<double>(1 << bitsStored); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1863 windowCenter = windowWidth / 2.0f; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1864 } |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
1865 } |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1866 |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
1867 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1868 void ParsedDicomFile::GetRescale(double& rescaleIntercept, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1869 double& rescaleSlope, |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1870 unsigned int frame) const |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1871 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1872 DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset(); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1873 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1874 const char* sopClassUid = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1875 const char* intercept = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1876 const char* slope = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1877 DcmItem *item1 = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1878 DcmItem *item2 = NULL; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1879 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1880 if (dataset.findAndGetString(DCM_SOPClassUID, sopClassUid).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1881 sopClassUid != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1882 std::string(sopClassUid) == std::string(UID_RTDoseStorage)) |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1883 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1884 // We must not take the rescale value into account in the case of doses |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1885 rescaleIntercept = 0; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1886 rescaleSlope = 1; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1887 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1888 else if (dataset.findAndGetString(DCM_RescaleIntercept, intercept).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1889 dataset.findAndGetString(DCM_RescaleSlope, slope).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1890 intercept != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1891 slope != NULL && |
4781 | 1892 SerializationToolbox::ParseDouble(rescaleIntercept, intercept) && |
1893 SerializationToolbox::ParseDouble(rescaleSlope, slope)) | |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1894 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1895 return; // OK |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1896 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1897 else if (dataset.findAndGetSequenceItem(DCM_PerFrameFunctionalGroupsSequence, item1, frame).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1898 item1 != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1899 item1->findAndGetSequenceItem(DCM_PixelValueTransformationSequence, item2, 0).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1900 item2 != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1901 item2->findAndGetString(DCM_RescaleIntercept, intercept).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1902 item2->findAndGetString(DCM_RescaleSlope, slope).good() && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1903 intercept != NULL && |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1904 slope != NULL && |
4781 | 1905 SerializationToolbox::ParseDouble(rescaleIntercept, intercept) && |
1906 SerializationToolbox::ParseDouble(rescaleSlope, slope)) | |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1907 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1908 // New in Orthanc 1.9.7, to deal with Philips multiframe images |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1909 // (cf. private mail from Tomas Kenda on 2021-08-17) |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1910 return; // OK |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1911 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1912 else |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1913 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1914 rescaleIntercept = 0; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1915 rescaleSlope = 1; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1916 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1917 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
1918 |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
1919 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1920 #if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1921 // Alias for binary compatibility with Orthanc Framework 1.7.2 => don't use it anymore |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4278
diff
changeset
|
1922 void ParsedDicomFile::DatasetToJson(Json::Value& target, |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1923 DicomToJsonFormat format, |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1924 DicomToJsonFlags flags, |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1925 unsigned int maxStringLength) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1926 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1927 return const_cast<const ParsedDicomFile&>(*this).DatasetToJson(target, format, flags, maxStringLength); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1928 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1929 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1930 DcmFileFormat& ParsedDicomFile::GetDcmtkObject() const |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1931 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1932 return const_cast<ParsedDicomFile&>(*this).GetDcmtkObject(); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1933 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1934 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1935 void ParsedDicomFile::Apply(ITagVisitor& visitor) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1936 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1937 const_cast<const ParsedDicomFile&>(*this).Apply(visitor); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1938 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1939 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1940 ParsedDicomFile* ParsedDicomFile::Clone(bool keepSopInstanceUid) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1941 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1942 return const_cast<const ParsedDicomFile&>(*this).Clone(keepSopInstanceUid); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1943 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1944 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1945 bool ParsedDicomFile::LookupTransferSyntax(std::string& result) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1946 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1947 return const_cast<const ParsedDicomFile&>(*this).LookupTransferSyntax(result); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1948 } |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1949 |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1950 bool ParsedDicomFile::LookupTransferSyntax(std::string& result) const |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1951 { |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1952 DicomTransferSyntax s; |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1953 if (LookupTransferSyntax(s)) |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1954 { |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1955 result = GetTransferSyntaxUid(s); |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1956 return true; |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1957 } |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1958 else |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1959 { |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1960 return false; |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1961 } |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1962 } |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1963 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1964 bool ParsedDicomFile::GetTagValue(std::string& value, |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1965 const DicomTag& tag) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1966 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1967 return const_cast<const ParsedDicomFile&>(*this).GetTagValue(value, tag); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1968 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
1969 #endif |
790 | 1970 } |