Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomFormat/DicomStreamReader.cpp @ 4328:ce9284aebd40
new macro ORTHANC_DEPRECATED
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Nov 2020 13:34:58 +0100 |
parents | 50b0c69b653a |
children | d9473bd5ed43 |
rev | line source |
---|---|
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * License along with this program. If not, see |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "../PrecompiledHeaders.h" |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "DicomStreamReader.h" |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "../OrthancException.h" |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
4304 | 28 #include <cassert> |
29 | |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 namespace Orthanc |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
4221
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
32 static bool IsNormalizationNeeded(const std::string& source, |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
33 ValueRepresentation vr) |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
34 { |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
35 return (!source.empty() && |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
36 (source[source.size() - 1] == ' ' || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
37 source[source.size() - 1] == '\0') && |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
38 // Normalization only applies to string-based VR |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
39 (vr == ValueRepresentation_ApplicationEntity || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
40 vr == ValueRepresentation_AgeString || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
41 vr == ValueRepresentation_CodeString || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
42 vr == ValueRepresentation_DecimalString || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
43 vr == ValueRepresentation_IntegerString || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
44 vr == ValueRepresentation_LongString || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
45 vr == ValueRepresentation_LongText || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
46 vr == ValueRepresentation_PersonName || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
47 vr == ValueRepresentation_ShortString || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
48 vr == ValueRepresentation_ShortText || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
49 vr == ValueRepresentation_UniqueIdentifier || |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
50 vr == ValueRepresentation_UnlimitedText)); |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
51 } |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
52 |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
53 |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
54 static void NormalizeValue(std::string& inplace, |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
55 ValueRepresentation vr) |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
56 { |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
57 if (IsNormalizationNeeded(inplace, vr)) |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
58 { |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
59 assert(!inplace.empty()); |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
60 inplace.resize(inplace.size() - 1); |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
61 } |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
62 } |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
63 |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
64 |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 static uint16_t ReadUnsignedInteger16(const char* dicom, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 bool littleEndian) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 if (littleEndian) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 return (static_cast<uint16_t>(p[0]) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 (static_cast<uint16_t>(p[1]) << 8)); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 return (static_cast<uint16_t>(p[1]) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 (static_cast<uint16_t>(p[0]) << 8)); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 static uint32_t ReadUnsignedInteger32(const char* dicom, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 bool littleEndian) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 if (littleEndian) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 return (static_cast<uint32_t>(p[0]) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 (static_cast<uint32_t>(p[1]) << 8) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 (static_cast<uint32_t>(p[2]) << 16) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 (static_cast<uint32_t>(p[3]) << 24)); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 return (static_cast<uint32_t>(p[3]) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 (static_cast<uint32_t>(p[2]) << 8) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 (static_cast<uint32_t>(p[1]) << 16) | |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 (static_cast<uint32_t>(p[0]) << 24)); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 static DicomTag ReadTag(const char* dicom, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 bool littleEndian) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 return DicomTag(ReadUnsignedInteger16(dicom, littleEndian), |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 ReadUnsignedInteger16(dicom + 2, littleEndian)); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 static bool IsShortExplicitTag(ValueRepresentation vr) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 /** |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 * Are we in the case of Table 7.1-2? "Data Element with |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 * Explicit VR of AE, AS, AT, CS, DA, DS, DT, FL, FD, IS, LO, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 * LT, PN, SH, SL, SS, ST, TM, UI, UL and US" |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_7.html#sect_7.1.2 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 **/ |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 return (vr == ValueRepresentation_ApplicationEntity /* AE */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 vr == ValueRepresentation_AgeString /* AS */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 vr == ValueRepresentation_AttributeTag /* AT */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 vr == ValueRepresentation_CodeString /* CS */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 vr == ValueRepresentation_Date /* DA */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 vr == ValueRepresentation_DecimalString /* DS */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 vr == ValueRepresentation_DateTime /* DT */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 vr == ValueRepresentation_FloatingPointSingle /* FL */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 vr == ValueRepresentation_FloatingPointDouble /* FD */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 vr == ValueRepresentation_IntegerString /* IS */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 vr == ValueRepresentation_LongString /* LO */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 vr == ValueRepresentation_LongText /* LT */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 vr == ValueRepresentation_PersonName /* PN */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 vr == ValueRepresentation_ShortString /* SH */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 vr == ValueRepresentation_SignedLong /* SL */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 vr == ValueRepresentation_SignedShort /* SS */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 vr == ValueRepresentation_ShortText /* ST */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 vr == ValueRepresentation_Time /* TM */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 vr == ValueRepresentation_UniqueIdentifier /* UI */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 vr == ValueRepresentation_UnsignedLong /* UL */ || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 vr == ValueRepresentation_UnsignedShort /* US */); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 bool DicomStreamReader::IsLittleEndian() const |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 return (transferSyntax_ != DicomTransferSyntax_BigEndianExplicit); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 void DicomStreamReader::HandlePreamble(IVisitor& visitor, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 const std::string& block) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 assert(block.size() == 144u); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 assert(reader_.GetProcessedBytes() == 144u); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 /** |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 * The "DICOM file meta information" is always encoded using |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 * "Explicit VR Little Endian Transfer Syntax" |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 * http://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 **/ |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 if (block[128] != 'D' || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 block[129] != 'I' || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 block[130] != 'C' || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 block[131] != 'M' || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 ReadTag(block.c_str() + 132, true) != DicomTag(0x0002, 0x0000) || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 block[136] != 'U' || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 block[137] != 'L' || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 ReadUnsignedInteger16(block.c_str() + 138, true) != 4) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 throw OrthancException(ErrorCode_BadFileFormat); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 uint32_t length = ReadUnsignedInteger32(block.c_str() + 140, true); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 reader_.Schedule(length); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 state_ = State_MetaHeader; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 |
4221
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
180 |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 void DicomStreamReader::HandleMetaHeader(IVisitor& visitor, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 const std::string& block) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 size_t pos = 0; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 const char* p = block.c_str(); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 bool hasTransferSyntax = false; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 while (pos + 8 <= block.size()) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 DicomTag tag = ReadTag(p + pos, true); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 ValueRepresentation vr = StringToValueRepresentation(std::string(p + pos + 4, 2), true); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 if (IsShortExplicitTag(vr)) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 uint16_t length = ReadUnsignedInteger16(p + pos + 6, true); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 std::string value; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 value.assign(p + pos + 8, length); |
4221
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
201 NormalizeValue(value, vr); |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 if (tag.GetGroup() == 0x0002) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 visitor.VisitMetaHeaderTag(tag, vr, value); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 if (tag == DICOM_TAG_TRANSFER_SYNTAX_UID) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 if (LookupTransferSyntax(transferSyntax_, value)) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 hasTransferSyntax = true; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 throw OrthancException(ErrorCode_NotImplemented, "Unsupported transfer syntax: " + value); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 pos += length + 8; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 else if (pos + 12 <= block.size()) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 uint16_t reserved = ReadUnsignedInteger16(p + pos + 6, true); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 if (reserved != 0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 uint32_t length = ReadUnsignedInteger32(p + pos + 8, true); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 if (tag.GetGroup() == 0x0002) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 { |
4221
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
234 std::string value; |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
235 value.assign(p + pos + 12, length); |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
236 NormalizeValue(value, vr); |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 visitor.VisitMetaHeaderTag(tag, vr, value); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 pos += length + 12; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 if (pos != block.size()) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 throw OrthancException(ErrorCode_BadFileFormat); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 if (!hasTransferSyntax) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 throw OrthancException(ErrorCode_BadFileFormat, "DICOM file meta-header without transfer syntax UID"); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 visitor.VisitTransferSyntax(transferSyntax_); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 reader_.Schedule(8); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 state_ = State_DatasetTag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 void DicomStreamReader::HandleDatasetTag(const std::string& block, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 const DicomTag& untilTag) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 static const DicomTag DICOM_TAG_SEQUENCE_ITEM(0xfffe, 0xe000); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 static const DicomTag DICOM_TAG_SEQUENCE_DELIMITATION_ITEM(0xfffe, 0xe00d); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 static const DicomTag DICOM_TAG_SEQUENCE_DELIMITATION_SEQUENCE(0xfffe, 0xe0dd); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 assert(block.size() == 8u); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 const bool littleEndian = IsLittleEndian(); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 DicomTag tag = ReadTag(block.c_str(), littleEndian); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 if (sequenceDepth_ == 0 && |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 tag >= untilTag) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 state_ = State_Done; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 return; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 if (tag == DICOM_TAG_SEQUENCE_ITEM || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 tag == DICOM_TAG_SEQUENCE_DELIMITATION_ITEM || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 tag == DICOM_TAG_SEQUENCE_DELIMITATION_SEQUENCE) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 // The special sequence items are encoded like "Implicit VR" |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 uint32_t length = ReadUnsignedInteger32(block.c_str() + 4, littleEndian); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 if (tag == DICOM_TAG_SEQUENCE_ITEM) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 if (length == 0xffffffffu) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 // Undefined length: Need to loop over the tags of the nested dataset |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 reader_.Schedule(8); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 state_ = State_DatasetTag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 // Explicit length: Can skip the full sequence at once |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 reader_.Schedule(length); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 state_ = State_DatasetValue; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 else if (tag == DICOM_TAG_SEQUENCE_DELIMITATION_ITEM || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 tag == DICOM_TAG_SEQUENCE_DELIMITATION_SEQUENCE) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 if (length != 0 || |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 sequenceDepth_ == 0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 throw OrthancException(ErrorCode_BadFileFormat); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 if (tag == DICOM_TAG_SEQUENCE_DELIMITATION_SEQUENCE) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 sequenceDepth_ --; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 reader_.Schedule(8); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 state_ = State_DatasetTag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 throw OrthancException(ErrorCode_InternalError); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 ValueRepresentation vr = ValueRepresentation_Unknown; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 if (transferSyntax_ == DicomTransferSyntax_LittleEndianImplicit) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 if (sequenceDepth_ == 0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 danglingTag_ = tag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 danglingVR_ = vr; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 uint32_t length = ReadUnsignedInteger32(block.c_str() + 4, true /* little endian */); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 HandleDatasetExplicitLength(length); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 // This in an explicit transfer syntax |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 vr = StringToValueRepresentation( |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 std::string(block.c_str() + 4, 2), false /* ignore unknown VR */); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 if (vr == ValueRepresentation_Sequence) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 sequenceDepth_ ++; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 reader_.Schedule(4); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 state_ = State_SequenceExplicitLength; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 else if (IsShortExplicitTag(vr)) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 uint16_t length = ReadUnsignedInteger16(block.c_str() + 6, littleEndian); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 reader_.Schedule(length); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 state_ = State_DatasetValue; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 uint16_t reserved = ReadUnsignedInteger16(block.c_str() + 6, littleEndian); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 if (reserved != 0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 throw OrthancException(ErrorCode_BadFileFormat); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 reader_.Schedule(4); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 state_ = State_DatasetExplicitLength; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 if (sequenceDepth_ == 0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 danglingTag_ = tag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 danglingVR_ = vr; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 void DicomStreamReader::HandleDatasetExplicitLength(uint32_t length) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 if (length == 0xffffffffu) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 /** |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 * This is the case of pixel data with compressed transfer |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 * syntaxes. Schedule the reading of the first tag of the |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 * nested dataset. |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_7.5.html |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 **/ |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 state_ = State_DatasetTag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 reader_.Schedule(8); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 sequenceDepth_ ++; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 reader_.Schedule(length); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 state_ = State_DatasetValue; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 void DicomStreamReader::HandleDatasetExplicitLength(const std::string& block) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 assert(block.size() == 4); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 uint32_t length = ReadUnsignedInteger32(block.c_str(), IsLittleEndian()); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 HandleDatasetExplicitLength(length); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 void DicomStreamReader::HandleSequenceExplicitLength(const std::string& block) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 assert(block.size() == 4); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 uint32_t length = ReadUnsignedInteger32(block.c_str(), IsLittleEndian()); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 if (length == 0xffffffffu) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 state_ = State_DatasetTag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 reader_.Schedule(8); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 reader_.Schedule(length); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 state_ = State_SequenceExplicitValue; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 void DicomStreamReader::HandleSequenceExplicitValue() |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 if (sequenceDepth_ == 0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 throw OrthancException(ErrorCode_InternalError); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 sequenceDepth_ --; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 state_ = State_DatasetTag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 reader_.Schedule(8); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 void DicomStreamReader::HandleDatasetValue(IVisitor& visitor, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 const std::string& block) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 if (sequenceDepth_ == 0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 bool c; |
4221
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
450 |
e4c0218b6b23
better normalization in stream reader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4220
diff
changeset
|
451 if (IsNormalizationNeeded(block, danglingVR_)) |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 std::string s(block.begin(), block.end() - 1); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 c = visitor.VisitDatasetTag(danglingTag_, danglingVR_, s, IsLittleEndian()); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 c = visitor.VisitDatasetTag(danglingTag_, danglingVR_, block, IsLittleEndian()); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 if (!c) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 state_ = State_Done; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 return; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 reader_.Schedule(8); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 state_ = State_DatasetTag; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 DicomStreamReader::DicomStreamReader(std::istream& stream) : |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 reader_(stream), |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 state_(State_Preamble), |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 transferSyntax_(DicomTransferSyntax_LittleEndianImplicit), // Dummy |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 danglingTag_(0x0000, 0x0000), // Dummy |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 danglingVR_(ValueRepresentation_Unknown), // Dummy |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 sequenceDepth_(0) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 reader_.Schedule(128 /* empty header */ + |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 4 /* "DICM" magic value */ + |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 4 /* (0x0002, 0x0000) tag */ + |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 2 /* value representation of (0x0002, 0x0000) == "UL" */ + |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 2 /* length of "UL" value == 4 */ + |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 4 /* actual length of the meta-header */); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 void DicomStreamReader::Consume(IVisitor& visitor, |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 const DicomTag& untilTag) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 while (state_ != State_Done) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 std::string block; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 if (reader_.Read(block)) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 switch (state_) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 case State_Preamble: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 HandlePreamble(visitor, block); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 case State_MetaHeader: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 HandleMetaHeader(visitor, block); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 case State_DatasetTag: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 HandleDatasetTag(block, untilTag); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 case State_DatasetExplicitLength: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 HandleDatasetExplicitLength(block); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 case State_SequenceExplicitLength: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 HandleSequenceExplicitLength(block); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 case State_SequenceExplicitValue: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 HandleSequenceExplicitValue(); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 case State_DatasetValue: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 HandleDatasetValue(visitor, block); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 break; |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 default: |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 throw OrthancException(ErrorCode_InternalError); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 else |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 return; // No more data in the stream |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 void DicomStreamReader::Consume(IVisitor& visitor) |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 DicomTag untilTag(0xffff, 0xffff); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 Consume(visitor, untilTag); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 } |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
545 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
546 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
547 bool DicomStreamReader::IsDone() const |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
548 { |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
549 return (state_ == State_Done); |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
550 } |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
551 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
552 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
553 uint64_t DicomStreamReader::GetProcessedBytes() const |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
554 { |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
555 return reader_.GetProcessedBytes(); |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4222
diff
changeset
|
556 } |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 } |