annotate OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 5406:aaf7c49a9ddc am-http-compression

tentative to implement smart HTTP compression with detection of transfer syntax
author Alain Mazy <am@osimis.io>
date Sat, 04 Nov 2023 13:42:30 +0100
parents c5f1865aaa3b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1831
diff changeset
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
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5054
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5054
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 * Lesser General Public License for more details.
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 /*=========================================================================
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 This file is based on portions of the following project:
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 Program: GDCM (Grassroots DICOM). A DICOM library
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 Module: http://gdcm.sourceforge.net/Copyright.html
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 #ifndef NOMINMAX
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 #define NOMINMAX
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 #endif
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 #include "ParsedDicomFile.h"
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 #include "ToDcmtkBridge.h"
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
78
5323
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
79 #include "../DicomFormat/DicomImageInformation.h"
4945
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
80 #include "../Images/Image.h"
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
81 #include "../Images/ImageProcessing.h"
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
82 #include "../Images/PamReader.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
83 #include "../Logging.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
84 #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
85 #include "../SerializationToolbox.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
86 #include "../Toolbox.h"
2512
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2499
diff changeset
87
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2499
diff changeset
88 #if ORTHANC_SANDBOXED == 0
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2499
diff changeset
89 # include "../SystemToolbox.h"
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2499
diff changeset
90 #endif
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
92 #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
93 # include "../Images/JpegReader.h"
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
94 #endif
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
95
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
96 #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
97 # include "../Images/PngReader.h"
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
98 #endif
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
99
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 #include <list>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 #include <limits>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 #include <boost/lexical_cast.hpp>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 #include <dcmtk/dcmdata/dcchrstr.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 #include <dcmtk/dcmdata/dcdicent.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 #include <dcmtk/dcmdata/dcdict.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 #include <dcmtk/dcmdata/dcfilefo.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 #include <dcmtk/dcmdata/dcuid.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 #include <dcmtk/dcmdata/dcmetinf.h>
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
111 #include <dcmtk/dcmdata/dcdeftag.h>
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
112 #include <dcmtk/dcmdata/dcswap.h>
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 #include <dcmtk/dcmdata/dcvrae.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 #include <dcmtk/dcmdata/dcvras.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 #include <dcmtk/dcmdata/dcvrcs.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 #include <dcmtk/dcmdata/dcvrda.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 #include <dcmtk/dcmdata/dcvrds.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 #include <dcmtk/dcmdata/dcvrdt.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 #include <dcmtk/dcmdata/dcvrfd.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 #include <dcmtk/dcmdata/dcvrfl.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 #include <dcmtk/dcmdata/dcvris.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 #include <dcmtk/dcmdata/dcvrlo.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 #include <dcmtk/dcmdata/dcvrlt.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 #include <dcmtk/dcmdata/dcvrpn.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 #include <dcmtk/dcmdata/dcvrsh.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 #include <dcmtk/dcmdata/dcvrsl.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 #include <dcmtk/dcmdata/dcvrss.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 #include <dcmtk/dcmdata/dcvrst.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 #include <dcmtk/dcmdata/dcvrtm.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 #include <dcmtk/dcmdata/dcvrui.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 #include <dcmtk/dcmdata/dcvrul.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 #include <dcmtk/dcmdata/dcvrus.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 #include <dcmtk/dcmdata/dcvrut.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 #include <dcmtk/dcmdata/dcpixel.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 #include <dcmtk/dcmdata/dcpixseq.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 #include <dcmtk/dcmdata/dcpxitem.h>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 #include <boost/math/special_functions/round.hpp>
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 #include <dcmtk/dcmdata/dcostrmb.h>
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
142 #include <boost/algorithm/string/predicate.hpp>
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
1945
76ff6eecf07f fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1941
diff changeset
145 #if DCMTK_VERSION_NUMBER <= 360
76ff6eecf07f fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1941
diff changeset
146 # define EXS_JPEGProcess1 EXS_JPEGProcess1TransferSyntax
76ff6eecf07f fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1941
diff changeset
147 #endif
76ff6eecf07f fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1941
diff changeset
148
76ff6eecf07f fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1941
diff changeset
149
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 namespace Orthanc
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 {
794
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
153 struct ParsedDicomFile::PImpl
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
154 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
155 std::unique_ptr<DcmFileFormat> file_;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
156 std::unique_ptr<DicomFrameIndex> frameIndex_;
794
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
157 };
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
158
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
159
2394
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
160 #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
161 static void ParseTagAndGroup(DcmTagKey& key,
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
162 const std::string& tag)
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 DicomTag t = FromDcmtkBridge::ParseTag(tag);
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
165 key = DcmTagKey(t.GetGroup(), t.GetElement());
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
166 }
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
167
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 static unsigned int GetPixelDataBlockCount(DcmPixelData& pixelData,
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
170 E_TransferSyntax transferSyntax)
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
171 {
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
172 DcmPixelSequence* pixelSequence = NULL;
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
173 if (pixelData.getEncapsulatedRepresentation
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
174 (transferSyntax, NULL, pixelSequence).good() && pixelSequence)
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
175 {
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
176 return pixelSequence->card();
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
177 }
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
178 else
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 return 1;
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
181 }
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
182 }
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
183
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
184
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 static void SendPathValueForDictionary(RestApiOutput& output,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 DcmItem& dicom)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 Json::Value v = Json::arrayValue;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 for (unsigned long i = 0; i < dicom.card(); i++)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 DcmElement* element = dicom.getElement(i);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 if (element)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 char buf[16];
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 sprintf(buf, "%04x-%04x", element->getTag().getGTag(), element->getTag().getETag());
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 v.append(buf);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 output.AnswerJson(v);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 static void SendSequence(RestApiOutput& output,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 DcmSequenceOfItems& sequence)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 // This element is a sequence
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 Json::Value v = Json::arrayValue;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 for (unsigned long i = 0; i < sequence.card(); i++)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 v.append(boost::lexical_cast<std::string>(i));
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 output.AnswerJson(v);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
220 namespace
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 {
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
222 class DicomFieldStream : public IHttpStreamAnswer
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
223 {
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
224 private:
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
225 DcmElement& element_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
226 uint32_t length_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
227 uint32_t offset_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
228 std::string chunk_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
229 size_t chunkSize_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
230
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
231 public:
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
232 DicomFieldStream(DcmElement& element,
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
233 E_TransferSyntax transferSyntax) :
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
234 element_(element),
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
235 length_(element.getLength(transferSyntax)),
1616
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
236 offset_(0),
644c32c07306 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
237 chunkSize_(0)
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
238 {
1521
3606278d305e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1520
diff changeset
239 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
240 chunk_.resize(CHUNK_SIZE);
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
241 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242
1523
c388502a066d testing FilesystemHttpSender
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1521
diff changeset
243 virtual HttpCompression SetupHttpCompression(bool /*gzipAllowed*/,
c388502a066d testing FilesystemHttpSender
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1521
diff changeset
244 bool /*deflateAllowed*/)
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2910
diff changeset
245 ORTHANC_OVERRIDE
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
246 {
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
247 // No support for compression
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
248 return HttpCompression_None;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
249 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2910
diff changeset
251 virtual bool HasContentFilename(std::string& filename) ORTHANC_OVERRIDE
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 {
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
253 return false;
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 }
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
255
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2910
diff changeset
256 virtual std::string GetContentType() ORTHANC_OVERRIDE
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 {
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
258 return EnumerationToString(MimeType_Binary);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2910
diff changeset
261 virtual uint64_t GetContentLength() ORTHANC_OVERRIDE
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 {
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
263 return length_;
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
265
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2910
diff changeset
266 virtual bool ReadNextChunk() ORTHANC_OVERRIDE
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 {
1520
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1519
diff changeset
268 assert(offset_ <= length_);
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
269
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
270 if (offset_ == length_)
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
271 {
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
272 return false;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
273 }
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
274 else
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
275 {
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
276 if (length_ - offset_ < chunk_.size())
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
277 {
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
278 chunkSize_ = length_ - offset_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
279 }
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
280 else
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 chunkSize_ = chunk_.size();
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
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
285 OFCondition cond = element_.getPartialValue(&chunk_[0], offset_, chunkSize_);
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
286
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
287 offset_ += chunkSize_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
288
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
289 if (!cond.good())
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
290 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
291 throw OrthancException(ErrorCode_InternalError,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
292 "Error while sending a DICOM field: " +
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
293 std::string(cond.text()));
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
294 }
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
295
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
296 return true;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
297 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 }
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
299
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2910
diff changeset
300 virtual const char *GetChunkContent() ORTHANC_OVERRIDE
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
301 {
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
302 return chunk_.c_str();
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
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2910
diff changeset
305 virtual size_t GetChunkSize() ORTHANC_OVERRIDE
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
306 {
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
307 return chunkSize_;
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
308 }
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
309 };
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 static bool AnswerPixelData(RestApiOutput& output,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 DcmItem& dicom,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 E_TransferSyntax transferSyntax,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 const std::string* blockUri)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 DcmTag k(DICOM_TAG_PIXEL_DATA.GetGroup(),
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 DICOM_TAG_PIXEL_DATA.GetElement());
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 DcmElement *element = NULL;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 if (!dicom.findAndGetElement(k, element).good() ||
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 element == NULL)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 return false;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 try
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 DcmPixelData& pixelData = dynamic_cast<DcmPixelData&>(*element);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 if (blockUri == NULL)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 {
1913
41e402cd7b3a do not generate RC files for non-Windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1902
diff changeset
333 // The user asks how many blocks are present in this pixel data
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 unsigned int blocks = GetPixelDataBlockCount(pixelData, transferSyntax);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 Json::Value result(Json::arrayValue);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 for (unsigned int i = 0; i < blocks; i++)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 result.append(boost::lexical_cast<std::string>(i));
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 output.AnswerJson(result);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 return true;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 unsigned int block = boost::lexical_cast<unsigned int>(*blockUri);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 if (block < GetPixelDataBlockCount(pixelData, transferSyntax))
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 DcmPixelSequence* pixelSequence = NULL;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 if (pixelData.getEncapsulatedRepresentation
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 (transferSyntax, NULL, pixelSequence).good() && pixelSequence)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 // This is the case for JPEG transfer syntaxes
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 if (block < pixelSequence->card())
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 DcmPixelItem* pixelItem = NULL;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 if (pixelSequence->getItem(pixelItem, block).good() && pixelItem)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 if (pixelItem->getLength() == 0)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 {
5406
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
363 output.AnswerBuffer(NULL, 0, MimeType_Binary, ContentCompression_AlreadyCompressed);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 return true;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 Uint8* buffer = NULL;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 if (pixelItem->getUint8Array(buffer).good() && buffer)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 {
5406
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
370 output.AnswerBuffer(buffer, pixelItem->getLength(), MimeType_Binary, ContentCompression_AlreadyCompressed);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 return true;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 else
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 // This is the case for raw, uncompressed image buffers
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 assert(*blockUri == "0");
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
380 DicomFieldStream stream(*element, transferSyntax);
5406
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
381 output.AnswerStream(stream, ContentCompression_NotCompressed);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 catch (boost::bad_lexical_cast&)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 // The URI entered by the user is not a number
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 catch (std::bad_cast&)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 // This should never happen
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 return false;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 static void SendPathValueForLeaf(RestApiOutput& output,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 const std::string& tag,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 DcmItem& dicom,
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 E_TransferSyntax transferSyntax)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 DcmTagKey k;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 ParseTagAndGroup(k, tag);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 DcmSequenceOfItems* sequence = NULL;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 if (dicom.findAndGetSequence(k, sequence).good() &&
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 sequence != NULL &&
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 sequence->getVR() == EVR_SQ)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 SendSequence(output, *sequence);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 return;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 DcmElement* element = NULL;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 if (dicom.findAndGetElement(k, element).good() &&
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 element != NULL &&
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 //element->getVR() != EVR_UNKNOWN && // This would forbid private tags
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 element->getVR() != EVR_SQ)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 {
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
421 DicomFieldStream stream(*element, transferSyntax);
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
422 output.AnswerStream(stream);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 }
2394
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
425 #endif
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426
2394
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
427
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
428 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 void ParsedDicomFile::SendPathValue(RestApiOutput& output,
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
430 const UriComponents& uri) const
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
432 DcmItem* dicom = GetDcmtkObjectConst().getDataset();
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
433 E_TransferSyntax transferSyntax = GetDcmtkObjectConst().getDataset()->getCurrentXfer();
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 // Special case: Accessing the pixel data
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 if (uri.size() == 1 ||
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 uri.size() == 2)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 DcmTagKey tag;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 ParseTagAndGroup(tag, uri[0]);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 if (tag.getGroup() == DICOM_TAG_PIXEL_DATA.GetGroup() &&
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 tag.getElement() == DICOM_TAG_PIXEL_DATA.GetElement())
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 AnswerPixelData(output, *dicom, transferSyntax, uri.size() == 1 ? NULL : &uri[1]);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 return;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 // Go down in the tag hierarchy according to the URI
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 for (size_t pos = 0; pos < uri.size() / 2; pos++)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 size_t index;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 try
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 index = boost::lexical_cast<size_t>(uri[2 * pos + 1]);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 catch (boost::bad_lexical_cast&)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 return;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 DcmTagKey k;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 DcmItem *child = NULL;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 ParseTagAndGroup(k, uri[2 * pos]);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 if (!dicom->findAndGetSequenceItem(k, child, index).good() ||
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 child == NULL)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 return;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 dicom = child;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 // We have reached the end of the URI
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 if (uri.size() % 2 == 0)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 SendPathValueForDictionary(output, *dicom);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 else
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 SendPathValueForLeaf(output, uri.back(), *dicom, transferSyntax);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 }
2394
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
485 #endif
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
486
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 void ParsedDicomFile::Remove(const DicomTag& tag)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 {
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
490 RemovePath(DicomPath(tag));
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2281
diff changeset
494 void ParsedDicomFile::Clear(const DicomTag& tag,
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2281
diff changeset
495 bool onlyIfExists)
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2281
diff changeset
496 {
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
497 ClearPath(DicomPath(tag), onlyIfExists);
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2281
diff changeset
498 }
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2281
diff changeset
499
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
501 void ParsedDicomFile::RemovePrivateTagsInternal(const std::set<DicomTag>* toKeep)
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 {
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
503 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
504
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
505 DcmDataset& dataset = *GetDcmtkObject().getDataset();
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
506
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
507 // Loop over the dataset to detect its private tags
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 typedef std::list<DcmElement*> Tags;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 Tags privateTags;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 for (unsigned long i = 0; i < dataset.card(); i++)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 DcmElement* element = dataset.getElement(i);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 DcmTag tag(element->getTag());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
515
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
516 // Is this a private tag?
1694
06d579e82bb8 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
517 if (tag.isPrivate())
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 {
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
519 bool remove = true;
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 // 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
522 if (toKeep != NULL)
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 DicomTag tmp = FromDcmtkBridge::Convert(tag);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
525 if (toKeep->find(tmp) != toKeep->end())
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 remove = false; // Keep it
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
528 }
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
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
531 if (remove)
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
532 {
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
533 privateTags.push_back(element);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
534 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
538 // Loop over the detected private tags to remove them
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 for (Tags::iterator it = privateTags.begin();
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 it != privateTags.end(); ++it)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 DcmElement* tmp = dataset.remove(*it);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 if (tmp != NULL)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 delete tmp;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
551 static void InsertInternal(DcmDataset& dicom,
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
552 DcmElement* element)
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 {
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
554 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
555 if (!cond.good())
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 // This field already exists
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
558 delete element;
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 throw OrthancException(ErrorCode_InternalError);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
564 void ParsedDicomFile::Insert(const DicomTag& tag,
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
565 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
566 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
567 const std::string& privateCreator)
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 {
2797
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
569 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
570 {
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
571 // 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
572 // 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
573 return;
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
574 }
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
575
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
576 if (GetDcmtkObject().getDataset()->tagExists(ToDcmtkBridge::Convert(tag)))
1980
ebce5f456b8e new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1979
diff changeset
577 {
ebce5f456b8e new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1979
diff changeset
578 throw OrthancException(ErrorCode_AlreadyExistingTag);
ebce5f456b8e new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1979
diff changeset
579 }
ebce5f456b8e new error code: ErrorCode_AlreadyExistingTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1979
diff changeset
580
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
581 if (decodeDataUriScheme &&
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
582 value.type() == Json::stringValue &&
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
583 (tag == DICOM_TAG_ENCAPSULATED_DOCUMENT ||
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
584 tag == DICOM_TAG_PIXEL_DATA))
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
585 {
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
586 if (EmbedContentInternal(value.asString()))
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 return;
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
589 }
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
590 }
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
591
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
592 InvalidateCache();
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
593
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
594 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
595 Encoding encoding = DetectEncoding(hasCodeExtensions);
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
596 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
597 InsertInternal(*GetDcmtkObject().getDataset(), element.release());
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
598 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
599
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600
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
601 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
602 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
603 {
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 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
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 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
607 "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
608 }
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 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
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 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
612 "" /* 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
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 }
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
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 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
618 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
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 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
621 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
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 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
624 }
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
625 }
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
626
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
627 void ParsedDicomFile::RemovePrivateTags()
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 RemovePrivateTagsInternal(NULL);
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
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
632 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
633 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
634 RemovePrivateTagsInternal(&toKeep);
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
635 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
636
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
637
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
638 static bool CanReplaceProceed(DcmDataset& dicom,
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
639 const DcmTagKey& tag,
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
640 DicomReplaceMode mode)
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
641 {
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
642 if (dicom.findAndDeleteElement(tag).good())
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 {
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
644 // This tag was existing, it has been deleted
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
645 return true;
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
646 }
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
647 else
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
648 {
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
649 // This tag was absent, act wrt. the specified "mode"
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 switch (mode)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 case DicomReplaceMode_InsertIfAbsent:
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
653 return true;
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 case DicomReplaceMode_ThrowIfAbsent:
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
656 throw OrthancException(ErrorCode_InexistentItem, "Cannot replace inexistent tag: " +
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
657 FromDcmtkBridge::GetTagName(DicomTag(tag.getGroup(), tag.getElement()), ""));
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 case DicomReplaceMode_IgnoreIfAbsent:
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
660 return false;
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
661
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
662 default:
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
663 throw OrthancException(ErrorCode_ParameterOutOfRange);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 }
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
666 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
667
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
668
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
669 void ParsedDicomFile::UpdateStorageUid(const DicomTag& tag,
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
670 const std::string& utf8Value,
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
671 bool decodeDataUriScheme)
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
672 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
673 if (tag != DICOM_TAG_SOP_CLASS_UID &&
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
674 tag != DICOM_TAG_SOP_INSTANCE_UID)
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675 {
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
676 return;
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
679 std::string binary;
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
680 const std::string* decoded = &utf8Value;
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
681
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
682 if (decodeDataUriScheme &&
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
683 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
684 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
685 std::string mime;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
686 if (!Toolbox::DecodeDataUriScheme(mime, binary, utf8Value))
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
687 {
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
688 throw OrthancException(ErrorCode_BadFileFormat);
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
689 }
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
690
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
691 decoded = &binary;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
692 }
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
693 else
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
694 {
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
695 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
696 Encoding encoding = DetectEncoding(hasCodeExtensions);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
697 if (encoding != Encoding_Utf8)
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
698 {
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
699 binary = Toolbox::ConvertFromUtf8(utf8Value, encoding);
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
700 decoded = &binary;
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
701 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
702 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704 /**
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 * dcmodify will automatically correct 'Media Storage SOP Class
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706 * UID' and 'Media Storage SOP Instance UID' in the metaheader, if
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 * you make changes to the related tags in the dataset ('SOP Class
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708 * UID' and 'SOP Instance UID') via insert or modify mode
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 * options. You can disable this behaviour by using the -nmu
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 * option.
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 **/
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 if (tag == DICOM_TAG_SOP_CLASS_UID)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714 {
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
715 ReplacePlainString(DICOM_TAG_MEDIA_STORAGE_SOP_CLASS_UID, *decoded);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 if (tag == DICOM_TAG_SOP_INSTANCE_UID)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 {
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
720 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
721 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
722 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
723
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
724
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
725 void ParsedDicomFile::Replace(const DicomTag& tag,
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1694
diff changeset
726 const std::string& utf8Value,
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
727 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
728 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
729 const std::string& privateCreator)
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
730 {
2797
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
731 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
732 {
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
733 // 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
734 // 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
735 return;
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
736 }
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
737 else
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
738 {
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
739 InvalidateCache();
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 DcmDataset& dicom = *GetDcmtkObject().getDataset();
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
742 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode))
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 // 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
745 // the replace mode was set to "InsertIfAbsent"
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
746
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
747 if (decodeDataUriScheme &&
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
748 (tag == DICOM_TAG_ENCAPSULATED_DOCUMENT ||
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
749 tag == DICOM_TAG_PIXEL_DATA))
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
750 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
751 if (EmbedContentInternal(utf8Value))
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 return;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
754 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
755 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
756
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
757 std::unique_ptr<DcmElement> element(FromDcmtkBridge::CreateElementForTag(tag, privateCreator));
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
758
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
759 if (!utf8Value.empty())
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
760 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
761 bool hasCodeExtensions;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
762 Encoding encoding = DetectEncoding(hasCodeExtensions);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
763 FromDcmtkBridge::FillElementWithString(*element, utf8Value, decodeDataUriScheme, encoding);
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
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
766 InsertInternal(dicom, element.release());
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
767
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
768 if (tag == DICOM_TAG_SOP_CLASS_UID ||
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
769 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
770 {
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
771 if (decodeDataUriScheme &&
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
772 boost::starts_with(utf8Value, URI_SCHEME_PREFIX_BINARY))
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 std::string mime, decoded;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
775 if (!Toolbox::DecodeDataUriScheme(mime, decoded, utf8Value))
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
776 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
777 throw OrthancException(ErrorCode_BadFileFormat);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
778 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
779 else
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 UpdateStorageUid(tag, decoded, false);
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 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
784 else
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
785 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
786 UpdateStorageUid(tag, utf8Value, false);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
787 }
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
788 }
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
789 }
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
790 }
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
791 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
792
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
793
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
794 void ParsedDicomFile::Replace(const DicomTag& tag,
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
795 const Json::Value& value,
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
796 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
797 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
798 const std::string& privateCreator)
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
799 {
2797
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
800 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
801 {
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
802 // 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
803 // 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
804 return;
9a0c6a046cc2 Fix handling of incoming C-FIND queries containing Generic Group Length (*, 0x0000)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
805 }
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
806 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
807 {
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
808 Replace(tag, value.asString(), decodeDataUriScheme, mode, privateCreator);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
809 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
810 else
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
811 {
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
812 if (tag == DICOM_TAG_SOP_CLASS_UID ||
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
813 tag == DICOM_TAG_SOP_INSTANCE_UID)
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1689
diff changeset
814 {
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
815 // Must be a string
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
816 throw OrthancException(ErrorCode_BadParameterType);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
817 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
818
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
819 InvalidateCache();
1979
9e0f408db796 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1956
diff changeset
820
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
821 DcmDataset& dicom = *GetDcmtkObject().getDataset();
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
822 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode))
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 // 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
825 // the replace mode was set to "InsertIfAbsent"
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
826
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
827 bool hasCodeExtensions;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
828 Encoding encoding = DetectEncoding(hasCodeExtensions);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
829 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
830 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834
2394
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
835 #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
836 void ParsedDicomFile::Answer(RestApiOutput& output) const
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838 std::string serialized;
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
839 if (FromDcmtkBridge::SaveToMemoryBuffer(serialized, *GetDcmtkObjectConst().getDataset()))
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 {
5406
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
841 ContentCompression contentCompression = ContentCompression_Unknown;
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
842 DicomTransferSyntax transferSyntax;
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
843
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
844 if (LookupTransferSyntax(transferSyntax))
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
845 {
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
846 contentCompression = (IsCompressedTransferSyntax(transferSyntax) ? ContentCompression_AlreadyCompressed : ContentCompression_NotCompressed);
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
847 }
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
848
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
849 output.AnswerBuffer(serialized,
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
850 MimeType_Dicom,
aaf7c49a9ddc tentative to implement smart HTTP compression with detection of transfer syntax
Alain Mazy <am@osimis.io>
parents: 5396
diff changeset
851 contentCompression);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 }
2394
75c779ca948c fix compilation without Web server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
854 #endif
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 bool ParsedDicomFile::GetTagValue(std::string& value,
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
858 const DicomTag& tag) const
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860 DcmTagKey k(tag.GetGroup(), tag.GetElement());
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
861 DcmDataset& dataset = *GetDcmtkObjectConst().getDataset();
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
862
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
863 if (tag.IsPrivate() ||
1655
e40fd0d925c5 /tools/create-dicom can create tags with unknown VR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1641
diff changeset
864 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
865 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
866 tag == DICOM_TAG_ENCAPSULATED_DOCUMENT)
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 {
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
868 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
869 long unsigned int count = 0;
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
871 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
872 {
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
873 if (count > 0)
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
874 {
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
875 assert(data != NULL);
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
876 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
877 }
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
878 else
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
879 {
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
880 value.clear();
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
881 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
882
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
883 return true;
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 else
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
886 {
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
887 return false;
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
888 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
889 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 else
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 {
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
892 DcmElement* element = NULL;
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
893 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
894 element == NULL)
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
895 {
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
896 return false;
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
897 }
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
898
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
899 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
900 Encoding encoding = DetectEncoding(hasCodeExtensions);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
901
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
902 std::set<DicomTag> tmp;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
903 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
904 (*element, DicomToJsonFlags_Default,
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
905 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
906
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
907 if (v.get() == NULL ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
908 v->IsNull())
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
909 {
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
910 value = "";
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
911 }
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
912 else
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
913 {
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
914 // TODO v->IsBinary()
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
915 value = v->GetContent();
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
916 }
1556
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
917
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
918 return true;
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
923 DicomInstanceHasher ParsedDicomFile::GetHasher() const
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925 std::string patientId, studyUid, seriesUid, instanceUid;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926
3446
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
927 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
928 {
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
929 /**
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
930 * 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
931 * 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
932 * 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
933 * https://groups.google.com/d/msg/orthanc-users/aphG_h1AHVg/rfOTtTPTAgAJ
3853
ba53d51ffa9a leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
934 * 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
935 **/
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
936 patientId.clear();
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
937 }
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
938
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
939 if (!GetTagValue(studyUid, DICOM_TAG_STUDY_INSTANCE_UID) ||
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 !GetTagValue(seriesUid, DICOM_TAG_SERIES_INSTANCE_UID) ||
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 !GetTagValue(instanceUid, DICOM_TAG_SOP_INSTANCE_UID))
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 {
3446
52da6e9335dd Allow anonymizing/modifying instances without the PatientID tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
943 throw OrthancException(ErrorCode_BadFileFormat, "missing StudyInstanceUID, SeriesInstanceUID or SOPInstanceUID");
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 return DicomInstanceHasher(patientId, studyUid, seriesUid, instanceUid);
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 void ParsedDicomFile::SaveToMemoryBuffer(std::string& buffer)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
952 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
953 {
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
954 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
955 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958
2512
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2499
diff changeset
959 #if ORTHANC_SANDBOXED == 0
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960 void ParsedDicomFile::SaveToFile(const std::string& path)
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 {
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962 // TODO Avoid using a temporary memory buffer, write directly on disk
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 std::string content;
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 SaveToMemoryBuffer(content);
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
965 SystemToolbox::WriteFile(content, path);
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
966 }
2512
4dcafa8d6633 SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2499
diff changeset
967 #endif
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
968
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
970 ParsedDicomFile::ParsedDicomFile(bool createIdentifiers) : pimpl_(new PImpl)
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971 {
794
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
972 pimpl_->file_.reset(new DcmFileFormat);
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
973
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
974 if (createIdentifiers)
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
975 {
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
976 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
977 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
978 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
979 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
980 }
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
981 }
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982
791
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
983
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
984 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
985 Encoding defaultEncoding,
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3948
diff changeset
986 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
987 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
988 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
989 {
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
990 pimpl_->file_.reset(new DcmFileFormat);
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3948
diff changeset
991 InvalidateCache();
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
992
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
993 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
994
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
995 if (tmp == NULL)
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
996 {
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
997 SetEncoding(defaultEncoding);
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
998 }
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
999 else if (tmp->IsBinary())
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1000 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1001 throw OrthancException(ErrorCode_ParameterOutOfRange,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1002 "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
1003 }
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1004 else if (tmp->IsNull() ||
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1005 tmp->GetContent().empty())
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1006 {
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1007 SetEncoding(defaultEncoding);
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1008 }
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1009 else
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1010 {
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1011 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
1012
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1013 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
1014 {
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1015 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
1016 }
5396
c5f1865aaa3b Support multiple values in SpecificCharacterSet in C-Find answers
Alain Mazy <am@osimis.io>
parents: 5348
diff changeset
1017 else if (permissive)
c5f1865aaa3b Support multiple values in SpecificCharacterSet in C-Find answers
Alain Mazy <am@osimis.io>
parents: 5348
diff changeset
1018 {
c5f1865aaa3b Support multiple values in SpecificCharacterSet in C-Find answers
Alain Mazy <am@osimis.io>
parents: 5348
diff changeset
1019 SetEncoding(defaultEncoding);
c5f1865aaa3b Support multiple values in SpecificCharacterSet in C-Find answers
Alain Mazy <am@osimis.io>
parents: 5348
diff changeset
1020 }
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1021 else
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1022 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1023 throw OrthancException(ErrorCode_ParameterOutOfRange,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1024 "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
1025 tmp->GetContent() + "\"");
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1026 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1027 }
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1028
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1029 for (DicomMap::Content::const_iterator
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1030 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
1031 {
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1032 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
1033 !it->second->IsNull())
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1034 {
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
1035 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
1036 {
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3948
diff changeset
1037 // 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
1038 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
1039
4039
fa35465175b8 fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4035
diff changeset
1040 std::map<uint16_t, std::string>::const_iterator found = privateCreators.find(it->first.GetGroup());
fa35465175b8 fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4035
diff changeset
1041
fa35465175b8 fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4035
diff changeset
1042 if (it->first.IsPrivate() &&
fa35465175b8 fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4035
diff changeset
1043 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
1044 {
4039
fa35465175b8 fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4035
diff changeset
1045 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
1046 }
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 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
1048 {
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 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
1050 }
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
1051 }
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
1052 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
1053 {
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
1054 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
1055 {
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
1056 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
1057 }
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
1058 }
2846
d386abc18133 simplification in SplitStudyJob, fix possible memory leak
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2797
diff changeset
1059 }
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1060 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1061 }
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 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
1064 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
1065 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
1066 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
1067 {
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
1068 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
1069 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
1070 }
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
1071
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
1072
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1073 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
1074 Encoding defaultEncoding,
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3948
diff changeset
1075 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
1076 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
1077 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
1078 pimpl_(new PImpl)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1079 {
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
1080 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
1081 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1082
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1083
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1788
diff changeset
1084 ParsedDicomFile::ParsedDicomFile(const void* content,
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1788
diff changeset
1085 size_t size) : pimpl_(new PImpl)
791
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1086 {
1935
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1087 pimpl_->file_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(content, size));
791
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1088 }
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1089
794
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
1090 ParsedDicomFile::ParsedDicomFile(const std::string& content) : pimpl_(new PImpl)
791
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1091 {
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1092 if (content.size() == 0)
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1093 {
1935
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1094 pimpl_->file_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(NULL, 0));
791
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1095 }
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1096 else
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1097 {
1935
e251606c1433 FromDcmtkBridge::LoadFromMemoryBuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1934
diff changeset
1098 pimpl_->file_.reset(FromDcmtkBridge::LoadFromMemoryBuffer(&content[0], content.size()));
791
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1099 }
381f90e2b69d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
1100 }
792
111a1738e11e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 791
diff changeset
1101
111a1738e11e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 791
diff changeset
1102
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4140
diff changeset
1103 ParsedDicomFile::ParsedDicomFile(const ParsedDicomFile& other,
2521
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2512
diff changeset
1104 bool keepSopInstanceUid) :
794
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 793
diff changeset
1105 pimpl_(new PImpl)
792
111a1738e11e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 791
diff changeset
1106 {
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1107 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
1108
2521
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2512
diff changeset
1109 if (!keepSopInstanceUid)
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2512
diff changeset
1110 {
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2512
diff changeset
1111 // Create a new instance-level identifier
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2512
diff changeset
1112 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
1113 }
792
111a1738e11e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 791
diff changeset
1114 }
111a1738e11e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 791
diff changeset
1115
111a1738e11e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 791
diff changeset
1116
1788
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1117 ParsedDicomFile::ParsedDicomFile(DcmDataset& dicom) : pimpl_(new PImpl)
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1118 {
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1119 pimpl_->file_.reset(new DcmFileFormat(&dicom));
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1120 }
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1121
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1122
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1123 ParsedDicomFile::ParsedDicomFile(DcmFileFormat& dicom) : pimpl_(new PImpl)
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1124 {
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1125 pimpl_->file_.reset(new DcmFileFormat(dicom));
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1126 }
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1127
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1128
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3901
diff changeset
1129 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
1130 {
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3901
diff changeset
1131 pimpl_->file_.reset(dicom); // No cloning
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3901
diff changeset
1132 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3901
diff changeset
1133
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3901
diff changeset
1134
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1135 DcmFileFormat& ParsedDicomFile::GetDcmtkObjectConst() const
793
145604a97914 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
1136 {
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1137 if (pimpl_->file_.get() == NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1138 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1139 throw OrthancException(ErrorCode_BadSequenceOfCalls,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1140 "ReleaseDcmtkObject() was called");
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 else
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 return *pimpl_->file_;
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 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1147
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4296
diff changeset
1148 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
1149 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1150 return new ParsedDicomFile(dicom);
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1151 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1152
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1153 DcmFileFormat &ParsedDicomFile::GetDcmtkObject()
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1154 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1155 return GetDcmtkObjectConst();
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1156 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4278
diff changeset
1157
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1158
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1159 DcmFileFormat* ParsedDicomFile::ReleaseDcmtkObject()
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1160 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1161 if (pimpl_->file_.get() == NULL)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1162 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1163 throw OrthancException(ErrorCode_BadSequenceOfCalls,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1164 "ReleaseDcmtkObject() was called");
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1165 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1166 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1167 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1168 pimpl_->frameIndex_.reset(NULL);
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1169 return pimpl_->file_.release();
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1170 }
793
145604a97914 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
1171 }
145604a97914 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
1172
145604a97914 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
1173
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1174 ParsedDicomFile* ParsedDicomFile::Clone(bool keepSopInstanceUid) const
793
145604a97914 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
1175 {
2521
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2512
diff changeset
1176 return new ParsedDicomFile(*this, keepSopInstanceUid);
793
145604a97914 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
1177 }
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1178
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1179
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1180 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
1181 {
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1182 std::string mimeString, content;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1183 if (!Toolbox::DecodeDataUriScheme(mimeString, content, dataUriScheme))
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
1184 {
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1185 return false;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
1186 }
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1980
diff changeset
1187
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1188 Toolbox::ToLowerCase(mimeString);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1189 MimeType mime = StringToMimeType(mimeString);
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1190
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1191 switch (mime)
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1192 {
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1193 case MimeType_Png:
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
1194 #if ORTHANC_ENABLE_PNG == 1
2908
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;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
1197 #else
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1198 throw OrthancException(ErrorCode_NotImplemented,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1199 "Orthanc was compiled without support of PNG");
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1200 #endif
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1201
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1202 case MimeType_Jpeg:
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1203 #if ORTHANC_ENABLE_JPEG == 1
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1204 EmbedImage(mime, content);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1205 break;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1206 #else
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1207 throw OrthancException(ErrorCode_NotImplemented,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1208 "Orthanc was compiled without support of JPEG");
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2310
diff changeset
1209 #endif
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1210
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1211 case MimeType_Pam:
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1212 EmbedImage(mime, content);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1213 break;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1214
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1215 case MimeType_Binary:
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1216 EmbedImage(mime, content);
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1217 break;
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1218
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1219 case MimeType_Pdf:
5348
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1220 {
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1221 if (content.size() < 5 || // (*)
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1222 strncmp("%PDF-", content.c_str(), 5) != 0)
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1223 {
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1224 throw OrthancException(ErrorCode_BadFileFormat, "Not a PDF file");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1225 }
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1226
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1227 EncapsulateDocument(MimeType_Pdf, content);
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1228
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1229 // In Orthanc <= 1.9.7, the "Modality" would have always be overwritten as "OT"
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1230 // https://groups.google.com/g/orthanc-users/c/eNSddNrQDtM/m/wc1HahimAAAJ
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1231
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1232 SetIfAbsent(DICOM_TAG_SOP_CLASS_UID, UID_EncapsulatedPDFStorage);
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1233 SetIfAbsent(DICOM_TAG_MODALITY, "OT");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1234 SetIfAbsent(FromDcmtkBridge::Convert(DCM_ConversionType), "WSD");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1235 //SetIfAbsent(FromDcmtkBridge::Convert(DCM_SeriesNumber), "1");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1236
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1237 break;
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1238 }
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1239
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1240 case MimeType_Mtl:
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1241 EncapsulateDocument(mime, content);
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1242 SetIfAbsent(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.104.5");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1243 SetIfAbsent(DICOM_TAG_MODALITY, "M3D");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1244 break;
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1245
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1246 case MimeType_Obj:
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1247 EncapsulateDocument(mime, content);
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1248 SetIfAbsent(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.104.4");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1249 SetIfAbsent(DICOM_TAG_MODALITY, "M3D");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1250 break;
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1251
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1252 case MimeType_Stl:
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1253 EncapsulateDocument(mime, content);
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1254 SetIfAbsent(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.104.3");
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1255 SetIfAbsent(DICOM_TAG_MODALITY, "M3D");
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1256 break;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1257
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1258 default:
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
1259 throw OrthancException(ErrorCode_NotImplemented,
2989
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2954
diff changeset
1260 "Unsupported MIME type for the content of a new DICOM file: " +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2954
diff changeset
1261 std::string(EnumerationToString(mime)));
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1558
diff changeset
1262 }
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1263
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1264 return true;
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1265 }
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1266
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1267
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1268 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
1269 {
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1270 if (!EmbedContentInternal(dataUriScheme))
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1271 {
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1272 throw OrthancException(ErrorCode_BadFileFormat);
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1273 }
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1274 }
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1275
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1276
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1277 void ParsedDicomFile::EmbedImage(MimeType mime,
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1278 const std::string& content)
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1279 {
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1280 switch (mime)
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
1281 {
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1282
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1283 #if ORTHANC_ENABLE_JPEG == 1
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1284 case MimeType_Jpeg:
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1285 {
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1286 JpegReader reader;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1287 reader.ReadFromMemory(content);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1288 EmbedImage(reader);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1289 break;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1290 }
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
1291 #endif
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
1292
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
1293 #if ORTHANC_ENABLE_PNG == 1
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1294 case MimeType_Png:
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1295 {
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1296 PngReader reader;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1297 reader.ReadFromMemory(content);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1298 EmbedImage(reader);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1299 break;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1300 }
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
1301 #endif
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
1302
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1303 case MimeType_Pam:
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1304 {
4211
afad57ac30ef enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1305 // "true" means "enforce memory alignment": This is slower,
afad57ac30ef enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
1306 // 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
1307 PamReader reader(true);
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1308 reader.ReadFromMemory(content);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1309 EmbedImage(reader);
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1310 break;
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1311 }
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1312
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1313 case MimeType_Binary:
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1314 EmbedRawPixelData(content);
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1315 break;
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1316
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1317 default:
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1318 throw OrthancException(ErrorCode_NotImplemented);
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1319 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1320 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1321
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1322
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1323 void ParsedDicomFile::EmbedImage(const ImageAccessor& accessor)
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1324 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1325 if (accessor.GetFormat() != PixelFormat_Grayscale8 &&
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1326 accessor.GetFormat() != PixelFormat_Grayscale16 &&
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1327 accessor.GetFormat() != PixelFormat_SignedGrayscale16 &&
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1328 accessor.GetFormat() != PixelFormat_RGB24 &&
5054
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1329 accessor.GetFormat() != PixelFormat_RGBA32 &&
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1330 accessor.GetFormat() != PixelFormat_RGBA64)
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1331 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1332 throw OrthancException(ErrorCode_NotImplemented);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1333 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1334
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1335 InvalidateCache();
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1336
5054
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1337 if (accessor.GetFormat() == PixelFormat_RGBA32 ||
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1338 accessor.GetFormat() == PixelFormat_RGBA64)
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1339 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1340 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
1341 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1342
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1343 // 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
1344
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1345 Remove(DICOM_TAG_PIXEL_DATA);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1346 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
1347 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
1348 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
1349
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1350 // 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
1351 //ReplacePlainString(DICOM_TAG_NUMBER_OF_FRAMES, "1");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1352
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1353 if (accessor.GetFormat() == PixelFormat_SignedGrayscale16)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1354 {
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1355 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "1");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1356 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1357 else
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1358 {
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1359 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "0"); // Unsigned pixels
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1360 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1361
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1362 unsigned int bytesPerPixel = 0;
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1363
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1364 switch (accessor.GetFormat())
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1365 {
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1366 case PixelFormat_Grayscale8:
2910
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1367 // By default, grayscale images are MONOCHROME2
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1368 SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1369
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1370 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8");
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1371 ReplacePlainString(DICOM_TAG_BITS_STORED, "8");
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1372 ReplacePlainString(DICOM_TAG_HIGH_BIT, "7");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1373 bytesPerPixel = 1;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1374 break;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1375
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1376 case PixelFormat_RGB24:
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1377 case PixelFormat_RGBA32:
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1378 ReplacePlainString(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "RGB");
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1379 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
1380 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8");
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1381 ReplacePlainString(DICOM_TAG_BITS_STORED, "8");
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1382 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
1383 bytesPerPixel = 3;
2910
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1384
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1385 // "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
1386 // Pixel" is greater than 1
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1387 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
1388
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1389 break;
5054
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1390
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1391 case PixelFormat_RGBA64:
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1392 ReplacePlainString(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "RGB");
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1393 ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "3");
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1394 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "16");
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1395 ReplacePlainString(DICOM_TAG_BITS_STORED, "16");
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1396 ReplacePlainString(DICOM_TAG_HIGH_BIT, "15");
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1397 bytesPerPixel = 6;
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1398
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1399 // "Planar configuration" must only present if "Samples per
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1400 // Pixel" is greater than 1
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1401 ReplacePlainString(DICOM_TAG_PLANAR_CONFIGURATION, "0"); // Color channels are interleaved
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1402
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1403 break;
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1404
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1405 case PixelFormat_Grayscale16:
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1406 case PixelFormat_SignedGrayscale16:
2910
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1407 // By default, grayscale images are MONOCHROME2
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1408 SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
83133583183d minor fixes if embedding images within DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1409
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1410 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "16");
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1411 ReplacePlainString(DICOM_TAG_BITS_STORED, "16");
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1412 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
1413 bytesPerPixel = 2;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1414 break;
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 default:
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1417 throw OrthancException(ErrorCode_NotImplemented);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1418 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1419
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1420 assert(bytesPerPixel != 0);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1935
diff changeset
1421
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1422 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
1423 DICOM_TAG_PIXEL_DATA.GetElement());
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1424
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1425 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
1426
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1427 unsigned int pitch = accessor.GetWidth() * bytesPerPixel;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1428 Uint8* target = NULL;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1429 pixels->createUint8Array(accessor.GetHeight() * pitch, target);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1430
4278
9279de56a405 avoid multiple calls to GetWidth() and GetHeight() on pixel loops
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1431 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
1432 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
1433
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1434 {
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1435 Uint8* q = target;
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1436 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
1437 {
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1438 switch (accessor.GetFormat())
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1439 {
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1440 case PixelFormat_RGB24:
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1441 case PixelFormat_Grayscale8:
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1442 case PixelFormat_Grayscale16:
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1443 case PixelFormat_SignedGrayscale16:
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1444 {
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1445 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
1446 q += pitch;
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1447 break;
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1448 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1449
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1450 case PixelFormat_RGBA32:
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1451 {
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1452 // 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
1453 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
1454 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
1455 {
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1456 q[0] = source[0];
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1457 q[1] = source[1];
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1458 q[2] = source[2];
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1459 }
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1460
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1461 break;
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1462 }
5054
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1463
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1464 case PixelFormat_RGBA64:
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1465 {
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1466 // The alpha channel is not supported by the DICOM standard
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1467 const Uint8* source = reinterpret_cast<const Uint8*>(accessor.GetConstRow(y));
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1468 for (unsigned int x = 0; x < width; x++, q += 6, source += 8)
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1469 {
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1470 q[0] = source[0];
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1471 q[1] = source[1];
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1472 q[2] = source[2];
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1473 q[3] = source[3];
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1474 q[4] = source[4];
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1475 q[5] = source[5];
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1476 }
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1477
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1478 break;
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4956
diff changeset
1479 }
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1480
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1481 default:
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1482 throw OrthancException(ErrorCode_NotImplemented);
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1483 }
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1484 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1485 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1486
4532
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1487 static const Endianness ENDIANNESS = Toolbox::DetectEndianness();
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1488 if (ENDIANNESS == Endianness_Big &&
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1489 (accessor.GetFormat() == PixelFormat_Grayscale16 ||
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1490 accessor.GetFormat() == PixelFormat_SignedGrayscale16))
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1491 {
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1492 // New in Orthanc 1.9.1
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1493 assert(pitch % 2 == 0);
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1494 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
1495 }
11bfea08341a fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1496
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1497 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
1498 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1499 throw OrthancException(ErrorCode_InternalError);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1500 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 799
diff changeset
1501 }
874
87791ebc1f50 download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
1502
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1503 void ParsedDicomFile::EmbedRawPixelData(const std::string& content)
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1504 {
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1505 DcmTag key(DICOM_TAG_PIXEL_DATA.GetGroup(),
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1506 DICOM_TAG_PIXEL_DATA.GetElement());
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1507
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1508 std::unique_ptr<DcmPixelData> pixels(new DcmPixelData(key));
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1509
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1510 Uint8* target = NULL;
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1511 pixels->createUint8Array(content.size(), target);
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1512 memcpy(target, content.c_str(), content.size());
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1513
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1514 if (!GetDcmtkObject().getDataset()->insert(pixels.release(), false, false).good())
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1515 {
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1516 throw OrthancException(ErrorCode_InternalError);
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1517 }
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1518 }
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1519
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
1520
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1521 Encoding ParsedDicomFile::DetectEncoding(bool& hasCodeExtensions) const
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
1522 {
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1523 return FromDcmtkBridge::DetectEncoding(hasCodeExtensions,
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1524 *GetDcmtkObjectConst().getDataset(),
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1525 GetDefaultDicomEncoding());
956
2fd5a163776d primitives for proper encoding handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 874
diff changeset
1526 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1527
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1528
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1529 void ParsedDicomFile::SetEncoding(Encoding encoding)
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1530 {
1558
124de28b32ed fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1556
diff changeset
1531 if (encoding == Encoding_Windows1251)
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1532 {
1558
124de28b32ed fix encodings of newly created dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1556
diff changeset
1533 // 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
1534 // 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
1535 return;
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1536 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1537
1565
4b23310eb7e8 add tags per instances in a series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
1538 std::string s = GetDicomSpecificCharacterSet(encoding);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1539 ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, s);
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1540 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1018
diff changeset
1541
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
1542 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
1543 DicomToJsonFormat format,
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
1544 DicomToJsonFlags flags,
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1545 unsigned int maxStringLength) const
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1113
diff changeset
1546 {
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1547 std::set<DicomTag> ignoreTagLength;
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1548 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
1549 format, flags, maxStringLength, ignoreTagLength);
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1550 }
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1551
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1552
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1553 void ParsedDicomFile::DatasetToJson(Json::Value& target,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1554 DicomToJsonFormat format,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1555 DicomToJsonFlags flags,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2394
diff changeset
1556 unsigned int maxStringLength,
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1557 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
1558 {
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1559 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
1560 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
1561 }
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
1562
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
1563
1831
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1827
diff changeset
1564 void ParsedDicomFile::HeaderToJson(Json::Value& target,
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1565 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
1566 {
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1567 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
1568 }
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1827
diff changeset
1569
3ae2ff249675 "/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1827
diff changeset
1570
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1571 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
1572 {
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1573 DcmTag key(tag.GetGroup(), tag.GetElement());
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1574 return GetDcmtkObjectConst().getDataset()->tagExists(key);
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1575 }
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1576
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1577
5348
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1578 void ParsedDicomFile::EncapsulateDocument(MimeType mime,
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1579 const std::string& document)
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1580 {
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1581 InvalidateCache();
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1582
5348
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1583 ReplacePlainString(FromDcmtkBridge::Convert(DCM_MIMETypeOfEncapsulatedDocument), EnumerationToString(mime));
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1584
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1585 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
1586
5348
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1587 size_t s = document.size();
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1588 if (s & 1)
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1589 {
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1590 // 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
1591 s += 1;
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1592 }
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1593
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1594 Uint8* bytes = NULL;
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1595 OFCondition result = element->createUint8Array(s, bytes);
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1596 if (!result.good() || bytes == NULL)
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1597 {
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1598 throw OrthancException(ErrorCode_NotEnoughMemory);
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1599 }
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1600
5348
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1601 if (s > 0)
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1602 {
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1603 bytes[s - 1] = 0;
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1604 }
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1605
5348
303e930fff0f "/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5323
diff changeset
1606 memcpy(bytes, document.c_str(), document.size());
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1607
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1608 DcmPolymorphOBOW* obj = element.release();
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3912
diff changeset
1609 result = GetDcmtkObject().getDataset()->insert(obj);
1555
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1610
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1611 if (!result.good())
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1612 {
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1613 delete obj;
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1614 throw OrthancException(ErrorCode_NotEnoughMemory);
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1615 }
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1616 }
d6a93e12b1c1 Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1523
diff changeset
1617
1556
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1618
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1619 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
1620 {
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1621 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
1622
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1623 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
1624 !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
1625 sop != UID_EncapsulatedPDFStorage ||
2905
ae20fccdd867 refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2889
diff changeset
1626 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
1627 {
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1628 return false;
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1629 }
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1630
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1631 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
1632 {
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1633 return false;
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1634 }
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1635
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1636 // 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
1637 // 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
1638 // 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
1639 // 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
1640 // 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
1641 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
1642 {
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1643 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
1644
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1645 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
1646 {
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1647 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
1648 }
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1649 }
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1650
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1651 return true;
b8dc2f855a83 Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1555
diff changeset
1652 }
1662
09be34b2f30e ParsedDicomFile::Convert()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
1653
09be34b2f30e ParsedDicomFile::Convert()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1655
diff changeset
1654
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1655 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
1656 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
1657 const std::string& privateCreator)
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1658 {
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
1659 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
1660 const bool decodeDataUriScheme = (flags & DicomFromJsonFlags_DecodeDataUriScheme) ? true : false;
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1661
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1662 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
1663 result->SetEncoding(FromDcmtkBridge::ExtractEncoding(json, GetDefaultDicomEncoding()));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1664
1934
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
1665 const Json::Value::Members tags = json.getMemberNames();
72a2fd7fed8b FromDcmtkBridge::FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
1666
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1667 for (size_t i = 0; i < tags.size(); i++)
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1668 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1669 DicomTag tag = FromDcmtkBridge::ParseTag(tags[i]);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1670 const Json::Value& value = json[tags[i]];
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1671
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1672 if (tag == DICOM_TAG_PIXEL_DATA ||
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1673 tag == DICOM_TAG_ENCAPSULATED_DOCUMENT)
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1674 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1675 if (value.type() != Json::stringValue)
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1676 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1677 throw OrthancException(ErrorCode_BadRequest);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1678 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1679 else
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1680 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1681 result->EmbedContent(value.asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1682 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1683 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1684 else if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET)
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1685 {
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
1686 result->Replace(tag, value, decodeDataUriScheme, DicomReplaceMode_InsertIfAbsent, privateCreator);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1687 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1688 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1689
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1690 return result.release();
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
1691 }
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
1692
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1693
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1694 void ParsedDicomFile::GetRawFrame(std::string& target,
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1695 MimeType& mime,
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1696 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
1697 {
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1698 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
1699 {
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
1700 assert(pimpl_->file_ != NULL &&
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1701 GetDcmtkObjectConst().getDataset() != NULL);
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1702 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
1703 }
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1704
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1705 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
1706
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1707 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
1708 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
1709 {
1946
40b7a0176305 fix compilation against DCMTK 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1945
diff changeset
1710 case EXS_JPEGProcess1:
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1711 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
1712 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
1713
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1714 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
1715 case EXS_JPEG2000:
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1716 mime = MimeType_Jpeg2000;
2016
0ae26237569a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1717 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
1718
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1719 default:
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1720 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
1721 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
1722 }
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1723 }
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1724
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1725
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1726 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
1727 {
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1913
diff changeset
1728 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
1729 }
1950
533ff46e944b return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1946
diff changeset
1730
533ff46e944b return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1946
diff changeset
1731
533ff46e944b return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1946
diff changeset
1732 unsigned int ParsedDicomFile::GetFramesCount() const
533ff46e944b return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1946
diff changeset
1733 {
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
1734 assert(pimpl_->file_ != NULL &&
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1735 GetDcmtkObjectConst().getDataset() != NULL);
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1736 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
1737 }
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1738
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1739
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1740 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
1741 {
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1742 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1743 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
1744
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1745 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
1746 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1747 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
1748 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
1749 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1750 }
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
1751
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1752
4139
a4f28efdfccf "maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
1753 void ParsedDicomFile::ExtractDicomSummary(DicomMap& target,
a4f28efdfccf "maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
1754 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
1755 {
4137
6774605d4341 keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4136
diff changeset
1756 std::set<DicomTag> ignoreTagLength;
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1757 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
1758 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
1759 }
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1760
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
1761
3577
33cfcc74d1b1 argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3446
diff changeset
1762 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
1763 unsigned int maxTagLength,
3577
33cfcc74d1b1 argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3446
diff changeset
1764 const std::set<DicomTag>& ignoreTagLength) const
33cfcc74d1b1 argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3446
diff changeset
1765 {
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1766 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
1767 maxTagLength, ignoreTagLength);
3577
33cfcc74d1b1 argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3446
diff changeset
1768 }
33cfcc74d1b1 argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3446
diff changeset
1769
33cfcc74d1b1 argument "ignoreTagLength" to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3446
diff changeset
1770
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1771 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
1772 {
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1773 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
1774 }
2281
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1775
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1776
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1777 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
1778 {
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1779 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
1780 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
1781
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1782 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
1783
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1784 const char *c = NULL;
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1785 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
1786 c != NULL)
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1787 {
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1788 result = StringToPhotometricInterpretation(c);
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1789 return true;
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1790 }
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1791 else
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1792 {
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1793 return false;
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1794 }
e002430baa41 Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1795 }
2499
83b8b6743531 ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1796
83b8b6743531 ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1797
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1798 void ParsedDicomFile::Apply(ITagVisitor& visitor) const
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1799 {
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1800 FromDcmtkBridge::Apply(*GetDcmtkObjectConst().getDataset(), visitor, GetDefaultDicomEncoding());
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1801 }
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1802
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1803
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1804 ImageAccessor* ParsedDicomFile::DecodeFrame(unsigned int frame) const
2499
83b8b6743531 ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1805 {
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1806 if (GetDcmtkObjectConst().getDataset() == NULL)
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1807 {
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1808 throw OrthancException(ErrorCode_InternalError);
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1809 }
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1810 else
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1811 {
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1812 return DicomImageDecoder::Decode(*GetDcmtkObjectConst().getDataset(), frame);
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
1813 }
2499
83b8b6743531 ITagVisitor - for anonymization relationships
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1814 }
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
1815
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
1816
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1817 static bool HasGenericGroupLength(const DicomPath& path)
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1818 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1819 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
1820 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1821 if (path.GetPrefixTag(i).GetElement() == 0x0000)
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1822 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1823 return true;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1824 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1825 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1826
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1827 return (path.GetFinalTag().GetElement() == 0x0000);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1828 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1829
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1830
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1831 void ParsedDicomFile::ReplacePath(const DicomPath& path,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1832 const Json::Value& value,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1833 bool decodeDataUriScheme,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1834 DicomReplaceMode mode,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1835 const std::string& privateCreator)
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1836 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1837 if (HasGenericGroupLength(path))
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1838 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1839 // 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
1840 // handled by DCMTK serialization
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1841 return;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1842 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1843 else if (path.GetPrefixLength() == 0)
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1844 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1845 Replace(path.GetFinalTag(), value, decodeDataUriScheme, mode, privateCreator);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1846 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1847 else
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1848 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1849 InvalidateCache();
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1850
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1851 bool hasCodeExtensions;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1852 Encoding encoding = DetectEncoding(hasCodeExtensions);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1853 std::unique_ptr<DcmElement> element(
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1854 FromDcmtkBridge::FromJson(path.GetFinalTag(), value, decodeDataUriScheme, encoding, privateCreator));
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1855
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1856 FromDcmtkBridge::ReplacePath(*GetDcmtkObject().getDataset(), path, *element, mode);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1857 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1858 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1859
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1860
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1861 void ParsedDicomFile::RemovePath(const DicomPath& path)
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1862 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1863 InvalidateCache();
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1864 FromDcmtkBridge::RemovePath(*GetDcmtkObject().getDataset(), path);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1865 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1866
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1867
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1868 void ParsedDicomFile::ClearPath(const DicomPath& path,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1869 bool onlyIfExists)
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1870 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1871 if (HasGenericGroupLength(path))
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1872 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1873 // 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
1874 // handled by DCMTK serialization
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1875 return;
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1876 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1877 else
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1878 {
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1879 InvalidateCache();
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1880 FromDcmtkBridge::ClearPath(*GetDcmtkObject().getDataset(), path, onlyIfExists);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1881 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1882 }
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1883
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4588
diff changeset
1884
4777
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1885 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
1886 const DicomPath& path,
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1887 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
1888 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1889 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
1890 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
1891 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1892
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1893
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1894 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
1895 double& windowWidth,
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1896 unsigned int frame) const
4771
9f207131c7f4 added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
1897 {
9f207131c7f4 added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
1898 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
1899
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1900 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
1901 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
1902 DcmItem *item1 = NULL;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1903 DcmItem *item2 = NULL;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1904
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1905 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
1906 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
1907 wc != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1908 ww != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1909 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
1910 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
1911 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1912 return; // OK
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 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
1915 item1 != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1916 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
1917 item2 != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1918 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
1919 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
1920 wc != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1921 ww != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1922 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
1923 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
1924 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1925 // 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
1926 // (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
1927 return; // OK
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1928 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1929 else
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1930 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1931 Uint16 bitsStored = 0;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1932 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
1933 bitsStored == 0)
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1934 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1935 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
1936 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1937
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1938 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
1939 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
1940 }
4771
9f207131c7f4 added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
1941 }
4777
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1942
4771
9f207131c7f4 added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
1943
4777
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1944 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
1945 double& rescaleSlope,
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1946 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
1947 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1948 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
1949
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1950 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
1951 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
1952 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
1953 DcmItem *item1 = NULL;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1954 DcmItem *item2 = NULL;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1955
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1956 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
1957 sopClassUid != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1958 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
1959 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1960 // 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
1961 rescaleIntercept = 0;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1962 rescaleSlope = 1;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1963 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1964 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
1965 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
1966 intercept != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1967 slope != NULL &&
4781
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4777
diff changeset
1968 SerializationToolbox::ParseDouble(rescaleIntercept, intercept) &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4777
diff changeset
1969 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
1970 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1971 return; // OK
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1972 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1973 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
1974 item1 != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1975 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
1976 item2 != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1977 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
1978 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
1979 intercept != NULL &&
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1980 slope != NULL &&
4781
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4777
diff changeset
1981 SerializationToolbox::ParseDouble(rescaleIntercept, intercept) &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4777
diff changeset
1982 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
1983 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1984 // 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
1985 // (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
1986 return; // OK
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1987 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1988 else
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1989 {
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1990 rescaleIntercept = 0;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1991 rescaleSlope = 1;
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1992 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1993 }
3b78ba359db3 Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4771
diff changeset
1994
4771
9f207131c7f4 added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
1995
4947
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
1996 void ParsedDicomFile::ListOverlays(std::set<uint16_t>& groups) const
4945
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
1997 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
1998 DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset();
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
1999
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2000 // "Repeating Groups shall only be allowed in the even Groups (6000-601E,eeee)"
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2001 // https://dicom.nema.org/medical/dicom/2021e/output/chtml/part05/sect_7.6.html
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2002
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2003 for (uint16_t group = 0x6000; group <= 0x601e; group += 2)
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2004 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2005 if (dataset.tagExists(DcmTagKey(group, 0x0010)))
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2006 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2007 groups.insert(group);
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2008 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2009 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2010 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2011
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2012
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2013 static unsigned int Ceiling(unsigned int a,
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2014 unsigned int b)
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2015 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2016 if (a % b == 0)
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2017 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2018 return a / b;
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2019 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2020 else
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2021 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2022 return a / b + 1;
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2023 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2024 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2025
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2026
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2027 ImageAccessor* ParsedDicomFile::DecodeOverlay(int& originX,
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2028 int& originY,
4947
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2029 uint16_t group) const
4945
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2030 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2031 // https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.9.2.html
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2032
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2033 DcmDataset& dataset = *const_cast<ParsedDicomFile&>(*this).GetDcmtkObject().getDataset();
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2034
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2035 Uint16 rows, columns, bitsAllocated, bitPosition;
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2036 const Sint16* origin = NULL;
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2037 unsigned long originSize = 0;
4956
964bbf5cb365 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4955
diff changeset
2038 DcmElement* overlayElement = NULL;
4955
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2039 Uint8* overlayData = NULL;
4945
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2040
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2041 if (dataset.findAndGetUint16(DcmTagKey(group, 0x0010), rows).good() &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2042 dataset.findAndGetUint16(DcmTagKey(group, 0x0011), columns).good() &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2043 dataset.findAndGetSint16Array(DcmTagKey(group, 0x0050), origin, &originSize).good() &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2044 origin != NULL &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2045 originSize == 2 &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2046 dataset.findAndGetUint16(DcmTagKey(group, 0x0100), bitsAllocated).good() &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2047 bitsAllocated == 1 &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2048 dataset.findAndGetUint16(DcmTagKey(group, 0x0102), bitPosition).good() &&
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2049 bitPosition == 0 &&
4956
964bbf5cb365 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4955
diff changeset
2050 dataset.findAndGetElement(DcmTagKey(group, 0x3000), overlayElement).good() &&
964bbf5cb365 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4955
diff changeset
2051 overlayElement != NULL &&
964bbf5cb365 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4955
diff changeset
2052 overlayElement->getUint8Array(overlayData).good() &&
4945
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2053 overlayData != NULL)
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2054 {
4955
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2055 /**
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2056 * WARNING - It might seem easier to use
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2057 * "dataset.findAndGetUint8Array()" that directly gives the size
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2058 * of the overlay data (using the "count" parameter), instead of
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2059 * "dataset.findAndGetElement()". Unfortunately, this does *not*
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2060 * work with Emscripten/WebAssembly, that reports a "count" that
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2061 * is half the number of bytes, presumably because of
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2062 * discrepancies in the way sizeof are computed inside DCMTK.
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2063 * The method "getLengthField()" reports the correct number of
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2064 * bytes, even if targeting WebAssembly.
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2065 **/
1610e56cadfb fix ParsedDicomFile::DecodeOverlay() for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4947
diff changeset
2066
4945
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2067 unsigned int expectedSize = Ceiling(rows * columns, 8);
4956
964bbf5cb365 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4955
diff changeset
2068 if (overlayElement->getLengthField() < expectedSize)
4945
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2069 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2070 throw OrthancException(ErrorCode_CorruptedFile, "Overlay doesn't have a valid number of bits");
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2071 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2072
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2073 originX = origin[1];
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2074 originY = origin[0];
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2075
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2076 std::unique_ptr<ImageAccessor> overlay(new Image(Orthanc::PixelFormat_Grayscale8, columns, rows, false));
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2077
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2078 unsigned int posBit = 0;
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2079 for (int y = 0; y < rows; y++)
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2080 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2081 uint8_t* target = reinterpret_cast<uint8_t*>(overlay->GetRow(y));
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2082
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2083 for (int x = 0; x < columns; x++)
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2084 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2085 uint8_t source = overlayData[posBit / 8];
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2086 uint8_t mask = 1 << (posBit % 8);
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2087
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2088 *target = ((source & mask) ? 255 : 0);
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2089
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2090 target++;
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2091 posBit++;
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2092 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2093 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2094
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2095 return overlay.release();
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2096 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2097 else
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2098 {
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2099 throw OrthancException(ErrorCode_CorruptedFile, "Invalid overlay");
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2100 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2101 }
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2102
6a59dc426f93 added ParsedDicomFile::DecodeOverlay()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4912
diff changeset
2103
4947
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2104 ImageAccessor* ParsedDicomFile::DecodeAllOverlays(int& originX,
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2105 int& originY) const
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2106 {
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2107 std::set<uint16_t> groups;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2108 ListOverlays(groups);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2109
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2110 if (groups.empty())
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2111 {
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2112 originX = 0;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2113 originY = 0;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2114 return new Image(PixelFormat_Grayscale8, 0, 0, false);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2115 }
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2116 else
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2117 {
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2118 std::set<uint16_t>::const_iterator it = groups.begin();
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2119 assert(it != groups.end());
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2120
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2121 std::unique_ptr<ImageAccessor> result(DecodeOverlay(originX, originY, *it));
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2122 assert(result.get() != NULL);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2123 ++it;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2124
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2125 int right = originX + static_cast<int>(result->GetWidth());
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2126 int bottom = originY + static_cast<int>(result->GetHeight());
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2127
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2128 while (it != groups.end())
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2129 {
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2130 int ox, oy;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2131 std::unique_ptr<ImageAccessor> overlay(DecodeOverlay(ox, oy, *it));
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2132 assert(overlay.get() != NULL);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2133
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2134 int mergedX = std::min(originX, ox);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2135 int mergedY = std::min(originY, oy);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2136 right = std::max(right, ox + static_cast<int>(overlay->GetWidth()));
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2137 bottom = std::max(bottom, oy + static_cast<int>(overlay->GetHeight()));
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2138
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2139 assert(right >= mergedX && bottom >= mergedY);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2140 unsigned int width = static_cast<unsigned int>(right - mergedX);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2141 unsigned int height = static_cast<unsigned int>(bottom - mergedY);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2142
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2143 std::unique_ptr<ImageAccessor> merged(new Image(PixelFormat_Grayscale8, width, height, false));
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2144 ImageProcessing::Set(*merged, 0);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2145
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2146 ImageAccessor a;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2147 merged->GetRegion(a, originX - mergedX, originY - mergedY, result->GetWidth(), result->GetHeight());
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2148 ImageProcessing::Maximum(a, *result);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2149
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2150 merged->GetRegion(a, ox - mergedX, oy - mergedY, overlay->GetWidth(), overlay->GetHeight());
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2151 ImageProcessing::Maximum(a, *overlay);
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2152
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2153 originX = mergedX;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2154 originY = mergedY;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2155 result.reset(merged.release());
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2156
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2157 ++it;
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2158 }
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2159
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2160 return result.release();
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2161 }
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2162 }
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2163
5318
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2164
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2165 void ParsedDicomFile::InjectEmptyPixelData(ValueRepresentation vr)
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2166 {
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2167 DcmItem& dataset = *GetDcmtkObject().getDataset();
5318
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2168
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2169 DcmElement *element = NULL;
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2170 if (!dataset.findAndGetElement(DCM_PixelData, element).good() ||
5318
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2171 element == NULL)
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2172 {
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2173 // The pixel data is indeed nonexistent, insert it now
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2174 switch (vr)
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2175 {
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2176 case ValueRepresentation_OtherByte:
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2177 if (!dataset.putAndInsertUint8Array(DCM_PixelData, NULL, 0).good())
5318
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2178 {
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2179 throw OrthancException(ErrorCode_InternalError);
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2180 }
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2181 break;
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2182
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2183 case ValueRepresentation_OtherWord:
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2184 if (!dataset.putAndInsertUint16Array(DCM_PixelData, NULL, 0).good())
5318
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2185 {
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2186 throw OrthancException(ErrorCode_InternalError);
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2187 }
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2188 break;
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2189
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2190 default:
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2191 throw OrthancException(ErrorCode_ParameterOutOfRange);
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2192 }
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2193 }
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2194 }
68e15471b408 added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
2195
4947
dfbe764995cf added ParsedDicomFile::DecodeAllOverlays()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4945
diff changeset
2196
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2197 void ParsedDicomFile::RemoveFromPixelData()
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2198 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2199 DcmItem& dataset = *GetDcmtkObject().getDataset();
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2200
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2201 // We need to go backward, otherwise "dataset.card()" is invalidated
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2202 for (unsigned long i = dataset.card(); i > 0; i--)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2203 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2204 DcmElement* element = dataset.getElement(i - 1);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2205 if (element == NULL)
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2206 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2207 throw OrthancException(ErrorCode_InternalError);
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2208 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2209
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2210 if (element->getTag().getGroup() > DCM_PixelData.getGroup() ||
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2211 (element->getTag().getGroup() == DCM_PixelData.getGroup() &&
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2212 element->getTag().getElement() >= DCM_PixelData.getElement()))
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2213 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2214 std::unique_ptr<DcmElement> removal(dataset.remove(i - 1));
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2215 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2216 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2217 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2218
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2219
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2220 ValueRepresentation ParsedDicomFile::GuessPixelDataValueRepresentation() const
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2221 {
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2222 DicomTransferSyntax ts;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2223 if (LookupTransferSyntax(ts))
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2224 {
5323
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
2225 DcmItem& dataset = *GetDcmtkObjectConst().getDataset();
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
2226
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
2227 uint16_t bitsAllocated;
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
2228 if (!dataset.findAndGetUint16(DCM_BitsAllocated, bitsAllocated).good())
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2229 {
5323
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
2230 bitsAllocated = 8;
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2231 }
5323
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
2232
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5322
diff changeset
2233 return DicomImageInformation::GuessPixelDataValueRepresentation(ts, bitsAllocated);
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2234 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2235 else
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2236 {
5322
a904a4caf5b7 unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5319
diff changeset
2237 // Assume "OB" if the transfer syntax is unknown
5319
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2238 return ValueRepresentation_OtherByte;
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2239 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2240 }
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2241
f2e1ad71e49c added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5318
diff changeset
2242
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
2243 #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
2244 // 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
2245 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
2246 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
2247 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
2248 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
2249 {
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
2250 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
2251 }
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
2252
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
2253 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
2254 {
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
2255 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
2256 }
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
2257
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
2258 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
2259 {
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
2260 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
2261 }
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
2262
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
2263 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
2264 {
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
2265 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
2266 }
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
2267
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
2268 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
2269 {
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
2270 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
2271 }
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2272
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2273 bool ParsedDicomFile::LookupTransferSyntax(std::string& result) const
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2274 {
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2275 DicomTransferSyntax s;
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2276 if (LookupTransferSyntax(s))
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2277 {
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2278 result = GetTransferSyntaxUid(s);
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2279 return true;
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2280 }
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2281 else
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2282 {
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2283 return false;
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2284 }
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
2285 }
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
2286
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
2287 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
2288 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
2289 {
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
2290 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
2291 }
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
2292 #endif
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2293 }