Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/DicomMapTests.cpp @ 4874:bee6da5155dc
fix polygon filling
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 18 Jan 2022 13:04:47 +0100 |
parents | 43e613a7756b |
children | b7ce2bb6b881 |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4845
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4845
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
7 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
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:
4063
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:
4063
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:
4063
diff
changeset
|
11 * the License, or (at your option) any later version. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
12 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
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:
4063
diff
changeset
|
16 * Lesser General Public License for more details. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
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:
4063
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:
4063
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:
4063
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
21 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
22 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
23 |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
24 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
25 // Must be the first to be sure to use the Orthanc framework shared library |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
26 # include <OrthancFramework.h> |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
27 #endif |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
28 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
29 #if !defined(DCMTK_VERSION_NUMBER) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
30 # error DCMTK_VERSION_NUMBER is not defined |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
31 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
32 |
4062 | 33 #include <gtest/gtest.h> |
711 | 34 |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
35 #include "../Sources/Compatibility.h" |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
36 #include "../Sources/OrthancException.h" |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
37 #include "../Sources/DicomFormat/DicomMap.h" |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
38 #include "../Sources/DicomFormat/DicomStreamReader.h" |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
39 #include "../Sources/DicomParsing/FromDcmtkBridge.h" |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
40 #include "../Sources/DicomParsing/ToDcmtkBridge.h" |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
41 #include "../Sources/DicomParsing/ParsedDicomFile.h" |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
42 #include "../Sources/DicomParsing/DicomWebJsonVisitor.h" |
711 | 43 |
4304 | 44 #include <boost/lexical_cast.hpp> |
711 | 45 |
46 using namespace Orthanc; | |
47 | |
48 TEST(DicomMap, MainTags) | |
49 { | |
50 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID)); | |
51 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient)); | |
52 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study)); | |
53 | |
54 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_STUDY_INSTANCE_UID)); | |
55 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_ACCESSION_NUMBER)); | |
56 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SERIES_INSTANCE_UID)); | |
57 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SOP_INSTANCE_UID)); | |
58 | |
59 std::set<DicomTag> s; | |
60 DicomMap::GetMainDicomTags(s); | |
61 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID)); | |
62 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
63 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER)); | |
64 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID)); | |
65 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID)); | |
66 | |
67 DicomMap::GetMainDicomTags(s, ResourceType_Patient); | |
68 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID)); | |
69 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
70 | |
71 DicomMap::GetMainDicomTags(s, ResourceType_Study); | |
72 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
73 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER)); | |
74 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
75 | |
76 DicomMap::GetMainDicomTags(s, ResourceType_Series); | |
77 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID)); | |
78 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
79 | |
80 DicomMap::GetMainDicomTags(s, ResourceType_Instance); | |
81 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID)); | |
82 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
83 } | |
84 | |
85 | |
86 TEST(DicomMap, Tags) | |
87 { | |
1360 | 88 std::set<DicomTag> s; |
89 | |
711 | 90 DicomMap m; |
1360 | 91 m.GetTags(s); |
1492 | 92 ASSERT_EQ(0u, s.size()); |
1360 | 93 |
711 | 94 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_NAME)); |
95 ASSERT_FALSE(m.HasTag(0x0010, 0x0010)); | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
96 m.SetValue(0x0010, 0x0010, "PatientName", false); |
711 | 97 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_NAME)); |
98 ASSERT_TRUE(m.HasTag(0x0010, 0x0010)); | |
99 | |
1360 | 100 m.GetTags(s); |
1492 | 101 ASSERT_EQ(1u, s.size()); |
1360 | 102 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin()); |
103 | |
711 | 104 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_ID)); |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
105 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID", false); |
711 | 106 ASSERT_TRUE(m.HasTag(0x0010, 0x0020)); |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
107 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID2", false); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
108 ASSERT_EQ("PatientID2", m.GetValue(0x0010, 0x0020).GetContent()); |
711 | 109 |
1360 | 110 m.GetTags(s); |
1492 | 111 ASSERT_EQ(2u, s.size()); |
1360 | 112 |
711 | 113 m.Remove(DICOM_TAG_PATIENT_ID); |
114 ASSERT_THROW(m.GetValue(0x0010, 0x0020), OrthancException); | |
115 | |
1360 | 116 m.GetTags(s); |
1492 | 117 ASSERT_EQ(1u, s.size()); |
1360 | 118 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin()); |
119 | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3694
diff
changeset
|
120 std::unique_ptr<DicomMap> mm(m.Clone()); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
121 ASSERT_EQ("PatientName", mm->GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
711 | 122 |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
123 m.SetValue(DICOM_TAG_PATIENT_ID, "Hello", false); |
711 | 124 ASSERT_THROW(mm->GetValue(DICOM_TAG_PATIENT_ID), OrthancException); |
125 mm->CopyTagIfExists(m, DICOM_TAG_PATIENT_ID); | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
126 ASSERT_EQ("Hello", mm->GetValue(DICOM_TAG_PATIENT_ID).GetContent()); |
711 | 127 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
128 DicomValue v; |
711 | 129 ASSERT_TRUE(v.IsNull()); |
130 } | |
131 | |
132 | |
133 TEST(DicomMap, FindTemplates) | |
134 { | |
135 DicomMap m; | |
136 | |
137 DicomMap::SetupFindPatientTemplate(m); | |
138 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID)); | |
139 | |
140 DicomMap::SetupFindStudyTemplate(m); | |
141 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)); | |
142 ASSERT_TRUE(m.HasTag(DICOM_TAG_ACCESSION_NUMBER)); | |
143 | |
144 DicomMap::SetupFindSeriesTemplate(m); | |
145 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)); | |
146 | |
147 DicomMap::SetupFindInstanceTemplate(m); | |
148 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID)); | |
149 } | |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
150 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
151 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
152 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
153 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
154 static void TestModule(ResourceType level, |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
155 DicomModule module) |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
156 { |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
157 // REFERENCE: DICOM PS3.3 2015c - Information Object Definitions |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
158 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
159 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
160 std::set<DicomTag> moduleTags, main; |
1368 | 161 DicomTag::AddTagsForModule(moduleTags, module); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
162 DicomMap::GetMainDicomTags(main, level); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
163 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
164 // The main dicom tags are a subset of the module |
1304 | 165 for (std::set<DicomTag>::const_iterator it = main.begin(); it != main.end(); ++it) |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
166 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
167 bool ok = moduleTags.find(*it) != moduleTags.end(); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
168 |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
169 // Exceptions for the Study level |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
170 if (level == ResourceType_Study && |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
171 (*it == DicomTag(0x0008, 0x0080) || /* InstitutionName, from Visit identification module, related to Visit */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
172 *it == DicomTag(0x0032, 0x1032) || /* RequestingPhysician, from Imaging Service Request module, related to Study */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
173 *it == DicomTag(0x0032, 0x1060))) /* RequestedProcedureDescription, from Requested Procedure module, related to Study */ |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
174 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
175 ok = true; |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
176 } |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
177 |
1849
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
178 // Exceptions for the Series level |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
179 if (level == ResourceType_Series && |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
180 (*it == DicomTag(0x0008, 0x0070) || /* Manufacturer, from General Equipment Module */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
181 *it == DicomTag(0x0008, 0x1010) || /* StationName, from General Equipment Module */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
182 *it == DicomTag(0x0018, 0x0024) || /* SequenceName, from MR Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
183 *it == DicomTag(0x0018, 0x1090) || /* CardiacNumberOfImages, from MR Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
184 *it == DicomTag(0x0020, 0x0037) || /* ImageOrientationPatient, from Image Plane Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
185 *it == DicomTag(0x0020, 0x0105) || /* NumberOfTemporalPositions, from MR Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
186 *it == DicomTag(0x0020, 0x1002) || /* ImagesInAcquisition, from General Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
187 *it == DicomTag(0x0054, 0x0081) || /* NumberOfSlices, from PET Series module */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
188 *it == DicomTag(0x0054, 0x0101) || /* NumberOfTimeSlices, from PET Series module */ |
1850
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1849
diff
changeset
|
189 *it == DicomTag(0x0054, 0x1000) || /* SeriesType, from PET Series module */ |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1849
diff
changeset
|
190 *it == DicomTag(0x0018, 0x1400) || /* AcquisitionDeviceProcessingDescription, from CR/X-Ray/DX/WholeSlideMicro Image (SIMPLIFICATION => Series) */ |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1849
diff
changeset
|
191 *it == DicomTag(0x0018, 0x0010))) /* ContrastBolusAgent, from Contrast/Bolus module (SIMPLIFICATION => Series) */ |
1849
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
192 { |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
193 ok = true; |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
194 } |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
195 |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
196 // Exceptions for the Instance level |
1704 | 197 if (level == ResourceType_Instance && |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
198 (*it == DicomTag(0x0020, 0x0012) || /* AccessionNumber, from General Image module */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
199 *it == DicomTag(0x0054, 0x1330) || /* ImageIndex, from PET Image module */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
200 *it == DicomTag(0x0020, 0x0100) || /* TemporalPositionIdentifier, from MR Image module */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
201 *it == DicomTag(0x0028, 0x0008) || /* NumberOfFrames, from Multi-frame module attributes, related to Image */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
202 *it == DicomTag(0x0020, 0x0032) || /* ImagePositionPatient, from Image Plan module, related to Image */ |
2804
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
203 *it == DicomTag(0x0020, 0x0037) || /* ImageOrientationPatient, from Image Plane Module (Orthanc 1.4.2) */ |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
204 *it == DicomTag(0x0020, 0x4000))) /* ImageComments, from General Image module */ |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
205 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
206 ok = true; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
207 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
208 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
209 if (!ok) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
210 { |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
211 std::cout << it->Format() << ": " << FromDcmtkBridge::GetTagName(*it, "") |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
212 << " not expected at level " << EnumerationToString(level) << std::endl; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
213 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
214 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
215 EXPECT_TRUE(ok); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
216 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
217 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
218 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
219 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
220 TEST(DicomMap, Modules) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
221 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
222 TestModule(ResourceType_Patient, DicomModule_Patient); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
223 TestModule(ResourceType_Study, DicomModule_Study); |
1849
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
224 TestModule(ResourceType_Series, DicomModule_Series); // TODO |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
225 TestModule(ResourceType_Instance, DicomModule_Instance); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
226 } |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
227 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
228 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
229 TEST(DicomMap, Parse) |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
230 { |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
231 DicomMap m; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
232 float f; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
233 double d; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
234 int32_t i; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
235 int64_t j; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
236 uint32_t k; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
237 uint64_t l; |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
238 unsigned int ui; |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
239 std::string s; |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
240 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
241 m.SetValue(DICOM_TAG_PATIENT_NAME, " ", false); // Empty value |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
242 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
243 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
244 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
245 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
246 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
247 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
248 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
249 m.SetValue(DICOM_TAG_PATIENT_NAME, "0", true); // Binary value |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
250 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
251 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
252 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
253 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
254 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
255 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
256 |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
257 ASSERT_FALSE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); |
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
258 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, true)); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
259 ASSERT_EQ("0", s); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
260 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
261 |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
262 // 2**31-1 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
263 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483647", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
264 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
265 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
266 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
267 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
268 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
269 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
270 ASSERT_FLOAT_EQ(2147483647.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
271 ASSERT_DOUBLE_EQ(2147483647.0, d); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
272 ASSERT_EQ(2147483647, i); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
273 ASSERT_EQ(2147483647ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
274 ASSERT_EQ(2147483647u, k); |
2418 | 275 ASSERT_EQ(2147483647ull, l); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
276 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
277 // Test shortcuts |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
278 m.SetValue(DICOM_TAG_PATIENT_NAME, "42", false); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
279 ASSERT_TRUE(m.ParseFloat(f, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
280 ASSERT_TRUE(m.ParseDouble(d, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
281 ASSERT_TRUE(m.ParseInteger32(i, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
282 ASSERT_TRUE(m.ParseInteger64(j, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
283 ASSERT_TRUE(m.ParseUnsignedInteger32(k, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
284 ASSERT_TRUE(m.ParseUnsignedInteger64(l, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
285 ASSERT_FLOAT_EQ(42.0f, f); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
286 ASSERT_DOUBLE_EQ(42.0, d); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
287 ASSERT_EQ(42, i); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
288 ASSERT_EQ(42ll, j); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
289 ASSERT_EQ(42u, k); |
2418 | 290 ASSERT_EQ(42ull, l); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
291 |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
292 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
293 ASSERT_EQ("42", s); |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
294 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, true)); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
295 ASSERT_EQ("42", s); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
296 |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
297 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
298 // 2**31 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
299 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483648", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
300 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
301 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
302 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
303 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
304 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
305 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
306 ASSERT_FLOAT_EQ(2147483648.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
307 ASSERT_DOUBLE_EQ(2147483648.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
308 ASSERT_EQ(2147483648ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
309 ASSERT_EQ(2147483648u, k); |
2418 | 310 ASSERT_EQ(2147483648ull, l); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
311 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
312 // 2**32-1 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
313 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967295", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
314 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
315 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
316 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
317 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
318 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
319 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
320 ASSERT_FLOAT_EQ(4294967295.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
321 ASSERT_DOUBLE_EQ(4294967295.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
322 ASSERT_EQ(4294967295ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
323 ASSERT_EQ(4294967295u, k); |
2418 | 324 ASSERT_EQ(4294967295ull, l); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
325 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
326 // 2**32 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
327 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967296", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
328 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
329 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
330 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
331 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
332 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
333 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
334 ASSERT_FLOAT_EQ(4294967296.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
335 ASSERT_DOUBLE_EQ(4294967296.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
336 ASSERT_EQ(4294967296ll, j); |
2418 | 337 ASSERT_EQ(4294967296ull, l); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
338 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
339 m.SetValue(DICOM_TAG_PATIENT_NAME, "-1", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
340 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
341 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
342 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
343 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
344 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
345 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
346 ASSERT_FLOAT_EQ(-1.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
347 ASSERT_DOUBLE_EQ(-1.0, d); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
348 ASSERT_EQ(-1, i); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
349 ASSERT_EQ(-1ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
350 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
351 // -2**31 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
352 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483648", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
353 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
354 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
355 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
356 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
357 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
358 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
359 ASSERT_FLOAT_EQ(-2147483648.0f, f); |
2829 | 360 ASSERT_DOUBLE_EQ(-2147483648.0, d); |
361 ASSERT_EQ(static_cast<int32_t>(-2147483648ll), i); | |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
362 ASSERT_EQ(-2147483648ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
363 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
364 // -2**31 - 1 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
365 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483649", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
366 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
367 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
368 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
369 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
370 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
371 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
372 ASSERT_FLOAT_EQ(-2147483649.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
373 ASSERT_DOUBLE_EQ(-2147483649.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
374 ASSERT_EQ(-2147483649ll, j); |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
375 |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
376 |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
377 // "800\0" in US COLMUNS tag |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
378 m.SetValue(DICOM_TAG_COLUMNS, "800\0", false); |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
379 ASSERT_TRUE(m.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(ui)); |
3541 | 380 ASSERT_EQ(800u, ui); |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
381 m.SetValue(DICOM_TAG_COLUMNS, "800", false); |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3497
diff
changeset
|
382 ASSERT_TRUE(m.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(ui)); |
3541 | 383 ASSERT_EQ(800u, ui); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
384 } |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
385 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
386 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
387 TEST(DicomMap, Serialize) |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
388 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
389 Json::Value s; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
390 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
391 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
392 DicomMap m; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
393 m.SetValue(DICOM_TAG_PATIENT_NAME, "Hello", false); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
394 m.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "Binary", true); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
395 m.SetNullValue(DICOM_TAG_SERIES_DESCRIPTION); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
396 m.Serialize(s); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
397 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
398 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
399 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
400 DicomMap m; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
401 m.Unserialize(s); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
402 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
403 const DicomValue* v = m.TestAndGetValue(DICOM_TAG_ACCESSION_NUMBER); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
404 ASSERT_TRUE(v == NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
405 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
406 v = m.TestAndGetValue(DICOM_TAG_PATIENT_NAME); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
407 ASSERT_TRUE(v != NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
408 ASSERT_FALSE(v->IsNull()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
409 ASSERT_FALSE(v->IsBinary()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
410 ASSERT_EQ("Hello", v->GetContent()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
411 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
412 v = m.TestAndGetValue(DICOM_TAG_STUDY_DESCRIPTION); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
413 ASSERT_TRUE(v != NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
414 ASSERT_FALSE(v->IsNull()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
415 ASSERT_TRUE(v->IsBinary()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
416 ASSERT_EQ("Binary", v->GetContent()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
417 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
418 v = m.TestAndGetValue(DICOM_TAG_SERIES_DESCRIPTION); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
419 ASSERT_TRUE(v != NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
420 ASSERT_TRUE(v->IsNull()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
421 ASSERT_FALSE(v->IsBinary()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
422 ASSERT_THROW(v->GetContent(), OrthancException); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
423 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
424 } |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
425 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
426 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
427 |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
428 TEST(DicomMap, ExtractMainDicomTags) |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
429 { |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
430 DicomMap b; |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
431 b.SetValue(DICOM_TAG_PATIENT_NAME, "E", false); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
432 ASSERT_TRUE(b.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
433 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
434 { |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
435 DicomMap a; |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
436 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
437 a.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "B", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
438 a.SetValue(DICOM_TAG_SERIES_DESCRIPTION, "C", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
439 a.SetValue(DICOM_TAG_NUMBER_OF_FRAMES, "D", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
440 a.SetValue(DICOM_TAG_SLICE_THICKNESS, "F", false); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
441 ASSERT_FALSE(a.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
442 b.ExtractMainDicomTags(a); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
443 } |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
444 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
445 ASSERT_EQ(4u, b.GetSize()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
446 ASSERT_EQ("A", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
447 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
448 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
449 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
450 ASSERT_FALSE(b.HasTag(DICOM_TAG_SLICE_THICKNESS)); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
451 ASSERT_TRUE(b.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
452 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
453 b.SetValue(DICOM_TAG_PATIENT_NAME, "G", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
454 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
455 { |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
456 DicomMap a; |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
457 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
458 a.SetValue(DICOM_TAG_SLICE_THICKNESS, "F", false); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
459 ASSERT_FALSE(a.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
460 b.Merge(a); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
461 } |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
462 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
463 ASSERT_EQ(5u, b.GetSize()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
464 ASSERT_EQ("G", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
465 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
466 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
467 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
468 ASSERT_EQ("F", b.GetValue(DICOM_TAG_SLICE_THICKNESS).GetContent()); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
469 ASSERT_FALSE(b.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
470 } |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
471 |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
472 |
3551
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
473 TEST(DicomMap, RemoveBinary) |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
474 { |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
475 DicomMap b; |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
476 b.SetValue(DICOM_TAG_PATIENT_NAME, "A", false); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
477 b.SetValue(DICOM_TAG_PATIENT_ID, "B", true); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
478 b.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, DicomValue()); // NULL |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
479 b.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, DicomValue("C", false)); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
480 b.SetValue(DICOM_TAG_SOP_INSTANCE_UID, DicomValue("D", true)); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
481 |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
482 b.RemoveBinaryTags(); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
483 |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
484 std::string s; |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
485 ASSERT_EQ(2u, b.GetSize()); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
486 ASSERT_TRUE(b.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); ASSERT_EQ("A", s); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
487 ASSERT_TRUE(b.LookupStringValue(s, DICOM_TAG_SERIES_INSTANCE_UID, false)); ASSERT_EQ("C", s); |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
488 } |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
489 |
173c7f363d8f
DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3541
diff
changeset
|
490 |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
491 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
492 TEST(DicomWebJson, Multiplicity) |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
493 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
494 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.4.html |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
495 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
496 ParsedDicomFile dicom(false); |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
497 dicom.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "SB1^SB2^SB3^SB4^SB5"); |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
498 dicom.ReplacePlainString(DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "1\\2.3\\4"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
499 dicom.ReplacePlainString(DICOM_TAG_IMAGE_POSITION_PATIENT, ""); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
500 |
3581
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
501 DicomWebJsonVisitor visitor; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
502 dicom.Apply(visitor); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
503 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
504 { |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
505 const Json::Value& tag = visitor.GetResult() ["00200037"]; // ImageOrientationPatient |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
506 const Json::Value& value = tag["Value"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
507 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
508 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
509 ASSERT_EQ(2u, tag.getMemberNames().size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
510 ASSERT_EQ(3u, value.size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
511 ASSERT_EQ(Json::realValue, value[1].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
512 ASSERT_FLOAT_EQ(1.0f, value[0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
513 ASSERT_FLOAT_EQ(2.3f, value[1].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
514 ASSERT_FLOAT_EQ(4.0f, value[2].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
515 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
516 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
517 { |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
518 const Json::Value& tag = visitor.GetResult() ["00200032"]; // ImagePositionPatient |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
519 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
520 ASSERT_EQ(1u, tag.getMemberNames().size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
521 } |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
522 |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3202
diff
changeset
|
523 std::string xml; |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
524 visitor.FormatXml(xml); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
525 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
526 { |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
527 DicomMap m; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
528 m.FromDicomWeb(visitor.GetResult()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
529 ASSERT_EQ(3u, m.GetSize()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
530 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
531 std::string s; |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
532 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
533 ASSERT_EQ("SB1^SB2^SB3^SB4^SB5", s); |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
534 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_POSITION_PATIENT, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
535 ASSERT_TRUE(s.empty()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
536 |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
537 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
538 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
539 std::vector<std::string> v; |
3581
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
540 Toolbox::TokenizeString(v, s, '\\'); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
541 ASSERT_FLOAT_EQ(1.0f, boost::lexical_cast<float>(v[0])); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
542 ASSERT_FLOAT_EQ(2.3f, boost::lexical_cast<float>(v[1])); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
543 ASSERT_FLOAT_EQ(4.0f, boost::lexical_cast<float>(v[2])); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
544 } |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
545 } |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
546 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
547 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
548 TEST(DicomWebJson, NullValue) |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
549 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
550 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.5.html |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
551 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
552 ParsedDicomFile dicom(false); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
553 dicom.ReplacePlainString(DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "1.5\\\\\\2.5"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
554 |
3581
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
555 DicomWebJsonVisitor visitor; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
556 dicom.Apply(visitor); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
557 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
558 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
559 const Json::Value& tag = visitor.GetResult() ["00200037"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
560 const Json::Value& value = tag["Value"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
561 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
562 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
563 ASSERT_EQ(2u, tag.getMemberNames().size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
564 ASSERT_EQ(4u, value.size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
565 ASSERT_EQ(Json::realValue, value[0].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
566 ASSERT_EQ(Json::nullValue, value[1].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
567 ASSERT_EQ(Json::nullValue, value[2].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
568 ASSERT_EQ(Json::realValue, value[3].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
569 ASSERT_FLOAT_EQ(1.5f, value[0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
570 ASSERT_FLOAT_EQ(2.5f, value[3].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
571 } |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
572 |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3202
diff
changeset
|
573 std::string xml; |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
574 visitor.FormatXml(xml); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
575 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
576 { |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
577 DicomMap m; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
578 m.FromDicomWeb(visitor.GetResult()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
579 ASSERT_EQ(1u, m.GetSize()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
580 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
581 std::string s; |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3497
diff
changeset
|
582 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
583 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
584 std::vector<std::string> v; |
3581
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
585 Toolbox::TokenizeString(v, s, '\\'); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
586 ASSERT_FLOAT_EQ(1.5f, boost::lexical_cast<float>(v[0])); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
587 ASSERT_TRUE(v[1].empty()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
588 ASSERT_TRUE(v[2].empty()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
589 ASSERT_FLOAT_EQ(2.5f, boost::lexical_cast<float>(v[3])); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3217
diff
changeset
|
590 } |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
591 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
592 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
593 |
3581
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
594 TEST(DicomWebJson, PixelSpacing) |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
595 { |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
596 // Test related to locales: Make sure that decimal separator is |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
597 // correctly handled (dot "." vs comma ",") |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
598 ParsedDicomFile source(false); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
599 source.ReplacePlainString(DICOM_TAG_PIXEL_SPACING, "1.5\\1.3"); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
600 |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
601 DicomWebJsonVisitor visitor; |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
602 source.Apply(visitor); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
603 |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
604 DicomMap target; |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
605 target.FromDicomWeb(visitor.GetResult()); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
606 |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
607 ASSERT_EQ("DS", visitor.GetResult() ["00280030"]["vr"].asString()); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
608 ASSERT_FLOAT_EQ(1.5f, visitor.GetResult() ["00280030"]["Value"][0].asFloat()); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
609 ASSERT_FLOAT_EQ(1.3f, visitor.GetResult() ["00280030"]["Value"][1].asFloat()); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
610 |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
611 std::string s; |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
612 ASSERT_TRUE(target.LookupStringValue(s, DICOM_TAG_PIXEL_SPACING, false)); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
613 ASSERT_EQ(s, "1.5\\1.3"); |
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3551
diff
changeset
|
614 } |
3651
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
615 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
616 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
617 TEST(DicomMap, MainTagNames) |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
618 { |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
619 ASSERT_EQ(3, ResourceType_Instance - ResourceType_Patient); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
620 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
621 for (int i = ResourceType_Patient; i <= ResourceType_Instance; i++) |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
622 { |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
623 ResourceType level = static_cast<ResourceType>(i); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
624 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
625 std::set<DicomTag> tags; |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
626 DicomMap::GetMainDicomTags(tags, level); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
627 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
628 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it) |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
629 { |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
630 DicomMap a; |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
631 a.SetValue(*it, "TEST", false); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
632 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
633 Json::Value json; |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
634 a.DumpMainDicomTags(json, level); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
635 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
636 ASSERT_EQ(Json::objectValue, json.type()); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
637 ASSERT_EQ(1u, json.getMemberNames().size()); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
638 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
639 std::string name = json.getMemberNames() [0]; |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
640 EXPECT_EQ(name, FromDcmtkBridge::GetTagName(*it, "")); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
641 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
642 DicomMap b; |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
643 b.ParseMainDicomTags(json, level); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
644 |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
645 ASSERT_EQ(1u, b.GetSize()); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
646 ASSERT_EQ("TEST", b.GetStringValue(*it, "", false)); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
647 |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4494
diff
changeset
|
648 std::string main = FromDcmtkBridge::GetTagName(*it, ""); |
3651
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
649 if (!main.empty()) |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
650 { |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
651 ASSERT_EQ(main, name); |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
652 } |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
653 } |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
654 } |
46cb00e4adbb
DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
655 } |
4213
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
656 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
657 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
658 |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
659 TEST(DicomTag, Comparisons) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
660 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
661 DicomTag a(0x0000, 0x0000); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
662 DicomTag b(0x0010, 0x0010); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
663 DicomTag c(0x0010, 0x0020); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
664 DicomTag d(0x0020, 0x0000); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
665 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
666 // operator==() |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
667 ASSERT_TRUE(a == a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
668 ASSERT_FALSE(a == b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
669 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
670 // operator!=() |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
671 ASSERT_FALSE(a != a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
672 ASSERT_TRUE(a != b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
673 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
674 // operator<=() |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
675 ASSERT_TRUE(a <= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
676 ASSERT_TRUE(a <= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
677 ASSERT_TRUE(a <= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
678 ASSERT_TRUE(a <= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
679 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
680 ASSERT_FALSE(b <= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
681 ASSERT_TRUE(b <= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
682 ASSERT_TRUE(b <= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
683 ASSERT_TRUE(b <= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
684 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
685 ASSERT_FALSE(c <= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
686 ASSERT_FALSE(c <= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
687 ASSERT_TRUE(c <= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
688 ASSERT_TRUE(c <= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
689 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
690 ASSERT_FALSE(d <= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
691 ASSERT_FALSE(d <= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
692 ASSERT_FALSE(d <= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
693 ASSERT_TRUE(d <= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
694 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
695 // operator<() |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
696 ASSERT_FALSE(a < a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
697 ASSERT_TRUE(a < b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
698 ASSERT_TRUE(a < c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
699 ASSERT_TRUE(a < d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
700 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
701 ASSERT_FALSE(b < a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
702 ASSERT_FALSE(b < b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
703 ASSERT_TRUE(b < c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
704 ASSERT_TRUE(b < d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
705 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
706 ASSERT_FALSE(c < a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
707 ASSERT_FALSE(c < b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
708 ASSERT_FALSE(c < c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
709 ASSERT_TRUE(c < d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
710 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
711 ASSERT_FALSE(d < a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
712 ASSERT_FALSE(d < b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
713 ASSERT_FALSE(d < c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
714 ASSERT_FALSE(d < d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
715 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
716 // operator>=() |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
717 ASSERT_TRUE(a >= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
718 ASSERT_FALSE(a >= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
719 ASSERT_FALSE(a >= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
720 ASSERT_FALSE(a >= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
721 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
722 ASSERT_TRUE(b >= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
723 ASSERT_TRUE(b >= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
724 ASSERT_FALSE(b >= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
725 ASSERT_FALSE(b >= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
726 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
727 ASSERT_TRUE(c >= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
728 ASSERT_TRUE(c >= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
729 ASSERT_TRUE(c >= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
730 ASSERT_FALSE(c >= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
731 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
732 ASSERT_TRUE(d >= a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
733 ASSERT_TRUE(d >= b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
734 ASSERT_TRUE(d >= c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
735 ASSERT_TRUE(d >= d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
736 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
737 // operator>() |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
738 ASSERT_FALSE(a > a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
739 ASSERT_FALSE(a > b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
740 ASSERT_FALSE(a > c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
741 ASSERT_FALSE(a > d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
742 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
743 ASSERT_TRUE(b > a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
744 ASSERT_FALSE(b > b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
745 ASSERT_FALSE(b > c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
746 ASSERT_FALSE(b > d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
747 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
748 ASSERT_TRUE(c > a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
749 ASSERT_TRUE(c > b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
750 ASSERT_FALSE(c > c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
751 ASSERT_FALSE(c > d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
752 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
753 ASSERT_TRUE(d > a); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
754 ASSERT_TRUE(d > b); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
755 ASSERT_TRUE(d > c); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
756 ASSERT_FALSE(d > d); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
757 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
758 |
4845
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
759 TEST(ParsedDicomFile, canIncludeXsVrTags) |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
760 { |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
761 Json::Value tags; |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
762 tags["0028,0034"] = "1\\1"; // PixelAspectRatio |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
763 tags["0028,1101"] = "256\\0\\16"; // RedPaletteColorLookupTableDescriptor which is declared as xs VR in dicom.dic |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
764 |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
765 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(tags, DicomFromJsonFlags_DecodeDataUriScheme, "")); |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
766 // simply make sure it does not throw ! |
02d77189d8ba
added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents:
4831
diff
changeset
|
767 } |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
768 |
4213
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
769 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
770 #if ORTHANC_SANDBOXED != 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
771 |
4213
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
772 #include "../Sources/SystemToolbox.h" |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
773 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
774 TEST(DicomMap, DISABLED_ParseDicomMetaInformation) |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
775 { |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
776 static const std::string PATH = "/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/"; |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
777 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
778 std::map<std::string, DicomTransferSyntax> f; |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
779 f.insert(std::make_pair(PATH + "../ColorTestMalaterre.dcm", DicomTransferSyntax_LittleEndianImplicit)); // 1.2.840.10008.1.2 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
780 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.1.dcm", DicomTransferSyntax_LittleEndianExplicit)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
781 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.2.dcm", DicomTransferSyntax_BigEndianExplicit)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
782 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.50.dcm", DicomTransferSyntax_JPEGProcess1)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
783 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.51.dcm", DicomTransferSyntax_JPEGProcess2_4)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
784 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.57.dcm", DicomTransferSyntax_JPEGProcess14)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
785 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.70.dcm", DicomTransferSyntax_JPEGProcess14SV1)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
786 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.80.dcm", DicomTransferSyntax_JPEGLSLossless)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
787 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.81.dcm", DicomTransferSyntax_JPEGLSLossy)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
788 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.90.dcm", DicomTransferSyntax_JPEG2000LosslessOnly)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
789 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.4.91.dcm", DicomTransferSyntax_JPEG2000)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
790 f.insert(std::make_pair(PATH + "1.2.840.10008.1.2.5.dcm", DicomTransferSyntax_RLELossless)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
791 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
792 for (std::map<std::string, DicomTransferSyntax>::const_iterator it = f.begin(); it != f.end(); ++it) |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
793 { |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
794 printf("\n== %s ==\n\n", it->first.c_str()); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
795 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
796 std::string dicom; |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
797 SystemToolbox::ReadFile(dicom, it->first, false); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
798 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
799 DicomMap d; |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
800 ASSERT_TRUE(DicomMap::ParseDicomMetaInformation(d, dicom.c_str(), dicom.size())); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
801 d.Print(stdout); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
802 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
803 std::string s; |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
804 ASSERT_TRUE(d.LookupStringValue(s, DICOM_TAG_TRANSFER_SYNTAX_UID, false)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
805 |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
806 DicomTransferSyntax ts; |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
807 ASSERT_TRUE(LookupTransferSyntax(ts, s)); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
808 ASSERT_EQ(ts, it->second); |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
809 } |
be2eca8b02e1
testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
810 } |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
811 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
812 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
813 namespace |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
814 { |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
815 class V : public DicomStreamReader::IVisitor |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
816 { |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
817 private: |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
818 DicomMap map_; |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
819 uint64_t pixelDataOffset_; |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
820 |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
821 public: |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
822 V() : |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
823 pixelDataOffset_(0) |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
824 { |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
825 } |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
826 |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
827 const DicomMap& GetDicomMap() const |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
828 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
829 return map_; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
830 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
831 |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
832 virtual void VisitMetaHeaderTag(const DicomTag& tag, |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
833 const ValueRepresentation& vr, |
4215
28e9457dc7ab
working on sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4214
diff
changeset
|
834 const std::string& value) ORTHANC_OVERRIDE |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
835 { |
4215
28e9457dc7ab
working on sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4214
diff
changeset
|
836 std::cout << "Header: " << tag.Format() << " [" << Toolbox::ConvertToAscii(value).c_str() << "] (" << value.size() << ")" << std::endl; |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
837 } |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
838 |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
839 virtual void VisitTransferSyntax(DicomTransferSyntax transferSyntax) ORTHANC_OVERRIDE |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
840 { |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
841 printf("TRANSFER SYNTAX: %s\n", GetTransferSyntaxUid(transferSyntax)); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
842 } |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
843 |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
844 virtual bool VisitDatasetTag(const DicomTag& tag, |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
845 const ValueRepresentation& vr, |
4215
28e9457dc7ab
working on sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4214
diff
changeset
|
846 const std::string& value, |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
847 bool isLittleEndian, |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
848 uint64_t fileOffset) ORTHANC_OVERRIDE |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
849 { |
4215
28e9457dc7ab
working on sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4214
diff
changeset
|
850 if (!isLittleEndian) |
28e9457dc7ab
working on sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4214
diff
changeset
|
851 printf("** "); |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
852 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
853 if (tag == DICOM_TAG_PIXEL_DATA) |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
854 { |
4216 | 855 std::cout << "Dataset: " << tag.Format() << " " << EnumerationToString(vr) |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
856 << " [PIXEL] (" << value.size() << "), offset: " << std::hex << fileOffset << std::dec << std::endl; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
857 pixelDataOffset_ = fileOffset; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
858 return false; |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
859 } |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
860 else |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
861 { |
4216 | 862 std::cout << "Dataset: " << tag.Format() << " " << EnumerationToString(vr) |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
863 << " [" << Toolbox::ConvertToAscii(value).c_str() << "] (" << value.size() |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
864 << "), offset: " << std::hex << fileOffset << std::dec << std::endl; |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
865 } |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
866 |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
867 map_.SetValue(tag, value, Toolbox::IsAsciiString(value)); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
868 |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
869 return true; |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
870 } |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
871 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
872 uint64_t GetPixelDataOffset() const |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
873 { |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
874 return pixelDataOffset_; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
875 } |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
876 }; |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
877 } |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
878 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
879 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
880 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
881 TEST(DicomStreamReader, DISABLED_Tutu) |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
882 { |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
883 static const std::string PATH = "/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/"; |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
884 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
885 typedef std::list< std::pair<std::string, uint64_t> > Sources; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
886 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
887 Sources sources; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
888 sources.push_back(std::make_pair(PATH + "../ColorTestMalaterre.dcm", 0x03a0u)); |
4494
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
889 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.1.dcm", 0x037cu)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
890 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.2.dcm", 0x03e8u)); // Big Endian |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
891 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.50.dcm", 0x04acu)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
892 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.51.dcm", 0x072cu)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
893 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.57.dcm", 0x0620u)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
894 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.70.dcm", 0x065au)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
895 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.80.dcm", 0x0b46u)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
896 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.81.dcm", 0x073eu)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
897 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.90.dcm", 0x0b66u)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
898 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.4.91.dcm", 0x19b8u)); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
899 sources.push_back(std::make_pair(PATH + "1.2.840.10008.1.2.5.dcm", 0x0b0au)); |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
900 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
901 { |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
902 std::string dicom; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
903 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
904 uint64_t offset; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
905 // Not a DICOM image |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
906 SystemToolbox::ReadFile(dicom, PATH + "1.2.840.10008.1.2.4.50.png", false); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
907 ASSERT_FALSE(DicomStreamReader::LookupPixelDataOffset(offset, dicom)); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
908 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
909 // Image without valid DICOM preamble |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
910 SystemToolbox::ReadFile(dicom, PATH + "1.2.840.10008.1.2.dcm", false); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
911 ASSERT_FALSE(DicomStreamReader::LookupPixelDataOffset(offset, dicom)); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
912 } |
4216 | 913 |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
914 for (Sources::const_iterator it = sources.begin(); it != sources.end(); ++it) |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
915 { |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
916 std::string dicom; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
917 SystemToolbox::ReadFile(dicom, it->first, false); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
918 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
919 { |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
920 uint64_t offset; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
921 ASSERT_TRUE(DicomStreamReader::LookupPixelDataOffset(offset, dicom)); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
922 ASSERT_EQ(it->second, offset); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
923 } |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
924 |
4494
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
925 { |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
926 uint64_t offset; |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
927 ASSERT_TRUE(DicomStreamReader::LookupPixelDataOffset(offset, dicom.c_str(), dicom.size())); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
928 ASSERT_EQ(it->second, offset); |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
929 } |
39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4493
diff
changeset
|
930 |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
931 ParsedDicomFile a(dicom); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
932 Json::Value aa; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
933 a.DatasetToJson(aa, DicomToJsonFormat_Short, DicomToJsonFlags_Default, 0); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
934 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
935 std::stringstream stream; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
936 size_t pos = 0; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
937 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
938 DicomStreamReader r(stream); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
939 V visitor; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
940 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
941 // Test reading byte per byte |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
942 while (pos < dicom.size() && |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
943 !r.IsDone()) |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
944 { |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
945 r.Consume(visitor); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
946 stream.clear(); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
947 stream.put(dicom[pos++]); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
948 } |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
949 |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
950 r.Consume(visitor); |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
951 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
952 ASSERT_EQ(it->second, visitor.GetPixelDataOffset()); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
953 |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
954 // Truncate the original DICOM up to pixel data |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
955 dicom.resize(visitor.GetPixelDataOffset()); |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
956 |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
957 ParsedDicomFile b(dicom); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
958 Json::Value bb; |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
959 b.DatasetToJson(bb, DicomToJsonFormat_Short, DicomToJsonFlags_Default, 0); |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
960 |
4493
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
961 aa.removeMember("7fe0,0010"); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
962 aa.removeMember("fffc,fffc"); // For "1.2.840.10008.1.2.5.dcm" |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
963 ASSERT_EQ(aa.toStyledString(), bb.toStyledString()); |
b57ca702a430
DicomStreamReader::LookupPixelDataOffset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
964 } |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
965 } |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
966 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
967 TEST(DicomStreamReader, DISABLED_Tutu2) |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
968 { |
4223 | 969 //static const std::string PATH = "/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/"; |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
970 |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
971 //const std::string path = PATH + "1.2.840.10008.1.2.4.50.dcm"; |
4217 | 972 //const std::string path = PATH + "1.2.840.10008.1.2.2.dcm"; |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
973 const std::string path = "/home/jodogne/Subversion/orthanc-tests/Database/HierarchicalAnonymization/RTH/RT.dcm"; |
4217 | 974 |
975 std::ifstream stream(path.c_str()); | |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
976 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
977 DicomStreamReader r(stream); |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
978 V visitor; |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
979 |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
980 r.Consume(visitor); |
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
981 |
4223 | 982 printf(">> %d\n", static_cast<int>(r.GetProcessedBytes())); |
4214
7b011cfda135
working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4213
diff
changeset
|
983 } |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
984 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
985 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
986 #include <boost/filesystem.hpp> |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
987 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
988 TEST(DicomStreamReader, DISABLED_Tutu3) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
989 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
990 static const std::string PATH = "/home/jodogne/Subversion/orthanc-tests/Database/"; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
991 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
992 std::set<std::string> errors; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
993 unsigned int success = 0; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
994 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
995 for (boost::filesystem::recursive_directory_iterator current(PATH), end; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
996 current != end ; ++current) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
997 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
998 if (SystemToolbox::IsRegularFile(current->path().string())) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
999 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1000 try |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1001 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1002 if (current->path().extension() == ".dcm") |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1003 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1004 const std::string path = current->path().string(); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1005 printf("[%s]\n", path.c_str()); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1006 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1007 DicomMap m1; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1008 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1009 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1010 std::ifstream stream(path.c_str()); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1011 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1012 DicomStreamReader r(stream); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1013 V visitor; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1014 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1015 try |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1016 { |
4220
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
1017 r.Consume(visitor, DICOM_TAG_PIXEL_DATA); |
92a21efa5c96
reorganization of DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4219
diff
changeset
|
1018 //r.Consume(visitor); |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1019 success++; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1020 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1021 catch (OrthancException& e) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1022 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1023 errors.insert(path); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1024 continue; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1025 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1026 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1027 m1.Assign(visitor.GetDicomMap()); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1028 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1029 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1030 m1.SetValue(DICOM_TAG_PIXEL_DATA, "", true); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1031 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1032 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1033 DicomMap m2; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1034 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1035 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1036 std::string dicom; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1037 SystemToolbox::ReadFile(dicom, path); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1038 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1039 ParsedDicomFile f(dicom); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1040 f.ExtractDicomSummary(m2, 256); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1041 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1042 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1043 std::set<DicomTag> tags; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1044 m2.GetTags(tags); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1045 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1046 bool first = true; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1047 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1048 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1049 if (!m1.HasTag(*it)) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1050 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1051 if (first) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1052 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1053 fprintf(stderr, "[%s]\n", path.c_str()); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1054 first = false; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1055 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1056 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1057 std::cerr << "ERROR: " << it->Format() << std::endl; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1058 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1059 else if (!m2.GetValue(*it).IsNull() && |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1060 !m2.GetValue(*it).IsBinary() && |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1061 Toolbox::IsAsciiString(m1.GetValue(*it).GetContent())) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1062 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1063 const std::string& v1 = m1.GetValue(*it).GetContent(); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1064 const std::string& v2 = m2.GetValue(*it).GetContent(); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1065 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1066 if (v1 != v2 && |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1067 (v1.size() != v2.size() + 1 || |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1068 v1.substr(0, v2.size()) != v2)) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1069 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1070 std::cerr << "ERROR: [" << v1 << "] [" << v2 << "]" << std::endl; |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1071 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1072 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1073 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1074 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1075 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1076 catch (boost::filesystem::filesystem_error&) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1077 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1078 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1079 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1080 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1081 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1082 |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1083 printf("\n== ERRORS ==\n"); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1084 for (std::set<std::string>::const_iterator |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1085 it = errors.begin(); it != errors.end(); ++it) |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1086 { |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1087 printf("[%s]\n", it->c_str()); |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1088 } |
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1089 |
4223 | 1090 printf("\n== SUCCESSES: %u ==\n\n", success); |
4218
8e069a7e1c11
validation against orthanc-tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4217
diff
changeset
|
1091 } |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1092 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1093 #endif |