Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp @ 5517:0d433132b249 pg-transactions
refactoring IDatabaseWrapper::Capabilities
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 Jan 2024 19:19:52 +0100 |
parents | 48b8dae6dc77 |
children | f7adfb22e20e |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
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:
1091
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5442
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5442
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
7 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
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:
4107
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:
4107
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:
4107
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:
809
diff
changeset
|
12 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
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:
809
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:
809
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:
4107
diff
changeset
|
16 * Lesser General Public License for more details. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
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:
4107
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:
4107
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:
4107
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
21 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
22 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
23 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp 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 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
26 # include <OrthancFramework.h> |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
27 #endif |
9214e3a7b0a2
moving FromDcmtkTests.cpp 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(ORTHANC_ENABLE_DCMTK_TRANSCODING) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
30 # error ORTHANC_ENABLE_DCMTK_TRANSCODING 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 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
33 #if !defined(ORTHANC_ENABLE_PUGIXML) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
34 # error ORTHANC_ENABLE_PUGIXML is not defined |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
35 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
36 |
4062 | 37 #include <gtest/gtest.h> |
782 | 38 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
39 #include "../Sources/Compatibility.h" |
5323
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
40 #include "../Sources/DicomFormat/DicomImageInformation.h" |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
41 #include "../Sources/DicomFormat/DicomPath.h" |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
42 #include "../Sources/DicomNetworking/DicomFindAnswers.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
43 #include "../Sources/DicomParsing/DicomModification.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
44 #include "../Sources/DicomParsing/DicomWebJsonVisitor.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
45 #include "../Sources/DicomParsing/FromDcmtkBridge.h" |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
46 #include "../Sources/DicomParsing/ParsedDicomCache.h" |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
47 #include "../Sources/DicomParsing/ToDcmtkBridge.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
48 #include "../Sources/Endianness.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
49 #include "../Sources/Images/Image.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
50 #include "../Sources/Images/ImageBuffer.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
51 #include "../Sources/Images/ImageProcessing.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
52 #include "../Sources/Images/PngReader.h" |
4304 | 53 #include "../Sources/Logging.h" |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
54 #include "../Sources/OrthancException.h" |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
55 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
56 #include "../Resources/CodeGeneration/EncodingTests.h" |
782 | 57 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
58 #if ORTHANC_SANDBOXED != 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
59 # include "../Sources/SystemToolbox.h" |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
60 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
61 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
62 #include <dcmtk/dcmdata/dcdeftag.h> |
1690 | 63 #include <dcmtk/dcmdata/dcelem.h> |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
64 #include <dcmtk/dcmdata/dcvrat.h> |
4736
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
65 #include <dcmtk/dcmdata/dcpxitem.h> |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
66 #include <dcmtk/dcmdata/dcvrss.h> |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
67 #include <dcmtk/dcmdata/dcvrfl.h> |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
68 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
69 #include <boost/algorithm/string/predicate.hpp> |
4304 | 70 #include <boost/lexical_cast.hpp> |
1690 | 71 |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
72 #if ORTHANC_ENABLE_PUGIXML == 1 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
73 # include <pugixml.hpp> |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
74 # if !defined(PUGIXML_VERSION) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
75 # error PUGIXML_VERSION is not available |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
76 # endif |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
77 #endif |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
78 |
782 | 79 using namespace Orthanc; |
80 | |
81 TEST(DicomFormat, Tag) | |
82 { | |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2107
diff
changeset
|
83 ASSERT_EQ("PatientName", FromDcmtkBridge::GetTagName(DicomTag(0x0010, 0x0010), "")); |
782 | 84 |
85 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription"); | |
86 ASSERT_EQ(0x0008, t.GetGroup()); | |
87 ASSERT_EQ(0x103E, t.GetElement()); | |
88 | |
89 t = FromDcmtkBridge::ParseTag("0020-e040"); | |
90 ASSERT_EQ(0x0020, t.GetGroup()); | |
91 ASSERT_EQ(0xe040, t.GetElement()); | |
92 | |
93 // Test ==() and !=() operators | |
94 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020)); | |
95 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020)); | |
96 } | |
97 | |
98 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
99 #if ORTHANC_SANDBOXED != 1 |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
100 TEST(DicomModification, Basic) |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
101 { |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
102 DicomModification m; |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
103 m.SetupAnonymization(DicomVersion_2008); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
104 //m.SetLevel(DicomRootLevel_Study); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
105 //m.ReplacePlainString(DICOM_TAG_PATIENT_ID, "coucou"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
106 //m.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "coucou"); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
107 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
108 ParsedDicomFile o(true); |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
109 o.SaveToFile("UnitTestsResults/anon.dcm"); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
110 |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
111 for (int i = 0; i < 10; i++) |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
112 { |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
113 char b[1024]; |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
114 sprintf(b, "UnitTestsResults/anon%06d.dcm", i); |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
115 std::unique_ptr<ParsedDicomFile> f(o.Clone(false)); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
116 if (i > 4) |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
117 o.ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, "coucou"); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
118 m.Apply(*f); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
119 f->SaveToFile(b); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
120 } |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
121 } |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
122 #endif |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
123 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
124 |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
125 TEST(DicomModification, Anonymization) |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
126 { |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
127 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, FromDcmtkBridge::ParseTag("PatientName")); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
128 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
129 const DicomTag privateTag(0x0045, 0x1010); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
130 const DicomTag privateTag2(FromDcmtkBridge::ParseTag("0031-1020")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
131 ASSERT_TRUE(privateTag.IsPrivate()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
132 ASSERT_TRUE(privateTag2.IsPrivate()); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
133 ASSERT_EQ(0x0031, privateTag2.GetGroup()); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
134 ASSERT_EQ(0x1020, privateTag2.GetElement()); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
135 |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
136 std::string s; |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
137 ParsedDicomFile o(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
138 o.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "coucou"); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
139 ASSERT_FALSE(o.GetTagValue(s, privateTag)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
140 o.Insert(privateTag, "private tag", false, "OrthancCreator"); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
141 ASSERT_TRUE(o.GetTagValue(s, privateTag)); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
142 ASSERT_STREQ("private tag", s.c_str()); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
143 |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
144 ASSERT_FALSE(o.GetTagValue(s, privateTag2)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
145 ASSERT_THROW(o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_ThrowIfAbsent, "OrthancCreator"), OrthancException); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
146 ASSERT_FALSE(o.GetTagValue(s, privateTag2)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
147 o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_IgnoreIfAbsent, "OrthancCreator"); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
148 ASSERT_FALSE(o.GetTagValue(s, privateTag2)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
149 o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_InsertIfAbsent, "OrthancCreator"); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
150 ASSERT_TRUE(o.GetTagValue(s, privateTag2)); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
151 ASSERT_STREQ("hello", s.c_str()); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
152 o.Replace(privateTag2, std::string("hello world"), false, DicomReplaceMode_InsertIfAbsent, "OrthancCreator"); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
153 ASSERT_TRUE(o.GetTagValue(s, privateTag2)); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
154 ASSERT_STREQ("hello world", s.c_str()); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
155 |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
156 ASSERT_TRUE(o.GetTagValue(s, DICOM_TAG_PATIENT_NAME)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
157 ASSERT_FALSE(Toolbox::IsUuid(s)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
158 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
159 DicomModification m; |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
160 m.SetupAnonymization(DicomVersion_2008); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
161 m.Keep(privateTag); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
162 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
163 m.Apply(o); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
164 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
165 ASSERT_TRUE(o.GetTagValue(s, DICOM_TAG_PATIENT_NAME)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
166 ASSERT_TRUE(Toolbox::IsUuid(s)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
167 ASSERT_TRUE(o.GetTagValue(s, privateTag)); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
168 ASSERT_STREQ("private tag", s.c_str()); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
169 |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
170 m.SetupAnonymization(DicomVersion_2008); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
171 m.Apply(o); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
172 ASSERT_FALSE(o.GetTagValue(s, privateTag)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
173 } |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
174 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
175 |
802 | 176 #include <dcmtk/dcmdata/dcuid.h> |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
177 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
178 TEST(DicomModification, Png) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
179 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
180 // Red dot in http://en.wikipedia.org/wiki/Data_URI_scheme (RGBA image) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
181 std::string s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
182 |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
183 std::string m, cc; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
184 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(m, cc, s)); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
185 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
186 ASSERT_EQ("image/png", m); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
187 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
188 PngReader reader; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
189 reader.ReadFromMemory(cc); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
190 |
1492 | 191 ASSERT_EQ(5u, reader.GetHeight()); |
192 ASSERT_EQ(5u, reader.GetWidth()); | |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
193 ASSERT_EQ(PixelFormat_RGBA32, reader.GetFormat()); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
194 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
195 ParsedDicomFile o(true); |
1562 | 196 o.EmbedContent(s); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
197 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
198 #if ORTHANC_SANDBOXED != 1 |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
199 o.SaveToFile("UnitTestsResults/png1.dcm"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
200 #endif |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
201 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
202 // Red dot, without alpha channel |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
203 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDTcIn2+8BgAAACJJREFUCNdj/P//PwMjIwME/P/P+J8BBTAxEOL/R9Lx/z8AynoKAXOeiV8AAAAASUVORK5CYII="; |
1562 | 204 o.EmbedContent(s); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
205 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
206 #if ORTHANC_SANDBOXED != 1 |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
207 o.SaveToFile("UnitTestsResults/png2.dcm"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
208 #endif |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
209 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
210 // Check box in Graylevel8 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
211 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="; |
1562 | 212 o.EmbedContent(s); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
213 //o.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, UID_DigitalXRayImageStorageForProcessing); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
214 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
215 #if ORTHANC_SANDBOXED != 1 |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
216 o.SaveToFile("UnitTestsResults/png3.dcm"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
217 #endif |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
218 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
219 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
220 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
221 // Gradient in Graylevel16 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
222 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
223 ImageBuffer img; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
224 img.SetWidth(256); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
225 img.SetHeight(256); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
226 img.SetFormat(PixelFormat_Grayscale16); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
227 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
228 ImageAccessor accessor; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
229 img.GetWriteableAccessor(accessor); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
230 |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1641
diff
changeset
|
231 uint16_t v = 0; |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
232 for (unsigned int y = 0; y < img.GetHeight(); y++) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
233 { |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
234 uint16_t *p = reinterpret_cast<uint16_t*>(accessor.GetRow(y)); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
235 for (unsigned int x = 0; x < img.GetWidth(); x++, p++, v++) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
236 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
237 *p = v; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
238 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
239 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
240 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
241 o.EmbedImage(accessor); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
242 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
243 #if ORTHANC_SANDBOXED != 1 |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
244 o.SaveToFile("UnitTestsResults/png4.dcm"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
245 #endif |
5054
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
246 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
247 // From http://www.schaik.com/pngsuite/pngsuite_bas_png.html |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
248 // 16Bit RGBA PNG |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
249 // License http://www.schaik.com/pngsuite/PngSuite.LICENSE |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
250 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgEAYAAAAj6qa3AAAABGdBTUEAAYagMeiWXwAADSJJREFUeJzdmV9sHNd1xn/zj7NLck0u5VqOSwSgrIcEkQDKtNvYxlKJAstNEIgWIFkuUtQyWsCQW8mKlAJecf1iLLUGWsmKDCgwUMByigC25UKh0SaIXNMpiSiJHZoERAN+kEQ0lR1LkLhLL8nd4fzrwzl3qVVVNI9BHhbfzp07d+537r3nfOeMlaZpCtB8FwCaE+3YmLh9+x/LfStNG/8hfzPfgN6x5iZ98P/B5ubfr98fWn/TD5rvZrbVRt01W/AsQGYuMwf5clqWxnRMMDH4N4LxccFI28O/F3T12tHnnW8JWj9U1PvsUjTv2aL41zr+TxT1fvT0Le97RPGQYPBrRb3fHFU013/ZIr4pc6FaguZIZhxuMkCqNhLq2VK2BL3ldFiJTynerxM7rBPSdm9SJ6SjuM8I2nrf1vvWvYpP6du0PTXj36P4RPv4kRm/T3FECU+1YzOr+KhgY8oQb5Szo7USNDdl5gCCCX8buGunJDmmU1GbCfXO4c5hyJfTfu31VTWArmD0r4rzOrFP1AC2oPNFNcBDSvwLOp8HFHUnpfp8ohj/VsdNdNw/FVz9MyX8J4rPKuHLSlOfX5k3xFcmOwvVEjTHMqMAzdHMGEDwqv9U2w5IdO1am11tJ9S7NnRtgN5yuqh3/0snWteJXtGJfqQTm1FD/LsaYlYNoe2WYqrtiV7HipHBh5W4XgerSvi6Eo6V5oLgcov48uWugVoJGlPZAqwZINjgXwZYnejY1maAeJ9ORU+52exmzYV695buLZAvpz/Vu6d1ohU1gK5EcF7Q03ZH0VaXy48Uv6Pj6P34Ax1Hr1cVAzV88w0lrO3LvxNcmjXEl2a6B6slWFno7ANoTmaGAYLf+PcDBL/2/xwg/IG3r90ApxR1U5pTbja7WXOhnjuSOwK95eTv1AA6wXDrLRP+J0FXr+29gtb7OpoeheRVHUfPcHj4lnH+Qonr9fK/CNY/N8TrR3PFWgmW7+76DKARZx2AYMovAATH/MMA4WbvAkD4Je/jNh8QbVfUI9ByP3rKzWY3ay7Ue3p6eiBfTvSsRpHgqtmqDUHPE3QcNYClBkh1dN3KYajEA8GGPr+8rDR1Fost4ouLPXdUS7Bc6SoCrOztPA3QzGXqNxsgHPHGAcJN3hxAeM7b3rYDIvUBJqAZv27cmznlZrObNRfq+Xw+D73l5EkdRb10U3FF0VW0dqoBduhoxqvr8w29XlJcVKyOGOLVar63VoJ6PZcDWKl0FgGab2T2AAT9/hWA1cmOYYBwzBsFiH7ufg0gmnDbfYBjApiJtMYg6teNezOn3Gx2s+ZCfd3b696GfDk6p4ReVAPoynlK0Nb7iXr18DUl/leC9ecEa9rvRov4jR3rxqslWDzRcxBgebmrC6BZyRQBgkW/B2B1taMDIAw8HyCaczcBRE+7rwDEE067AWxdCyNhTCQ3Ac34dePezOk0m92suVBfv339dugth3NqAPXStf/Ut9zicZpNJa5xfuFTwavvGOJXz61/pFaC2kjvOMBStTsP0GhkswDBUf8IwOpDHecBoofdXwBEl9x7AaJT7j6AuMf5HCD5Z/tv23yArafYaDcjYUwkNwHN+HXj3swpN5vdrLlQ7z/Ufwjy5aYepKoqPrdXzVUTNF78+lnBKy8Z4leO93+3WoKFT/vuAag/l3sRoDGTHQQIAt8HCCteESB8wXseIJp3BwDi3wqD5An7dYD4J8IwmbBv2QH7BY1oNdrNSBgTyU1AM37duDdzys1mN2su1De+vPFl6C0vTkvrfz+m5lLC1+4QvHjAEL+4f+PJWgmun71zJ0C9L7cA0Phl9kGA4Fn/BEAYygyiilsEiD9wHgCIv+x8DJCctx8ESMbsUYB0s3UBIHnZ3t9mAEvPvFHrLdGq2s1IGBPJTUAzft24N3PKzWY3ay7Uh4aGhiBfvnxJ71YFpz80xKenh+6rluDagbtOAiwVuicBmlszkwDha/KGqOrmAeJYZpB83z4IkKyzbwAkX7V/BZBOWcMA6SVhlG6y5gDSCat9B/BNRY37Rq0b0Wq0m5EwJpKbgGb8unFv5pSbzW7WXKjvfnz349BbfnyPIX7mzd27aiWoVvN5gODH/k6AqCYjxIGTAUhG7HGA9Kz1GECaygzSilUE4Dsyw3TeGgBgigJA+qoyeksZ/pRvtvkAVNu18jM9Ai21brSWajcjYUwkNwHN+PVWvqin3Gx2s+Zr1GWE3bvOvAmQz0sP/0BwUgwoIzin4mcA7HJSArAeS88CWJY8bx1NjwAwyyCAVUnFIJMMA1hPpSK2dvEWAP/AP94+GzSJqckFTJqiO8CIVqPdjIQxkdwENOPXjXszp1w2+5k3YfeuWmn3Lvl/5q0zb+1+HGDovulpgLveu7YNoHtwaQYgM9ncCuA9KW9wq1EewHFkBnYlKQLYM8kWAHs+GQCwptICgDWWjgJYYeoBWBNp+xFIjDTRjLyVmJr8zKQrqtZbotVoNyNhTCTXgGb8uri36WkYuq9aqlYhn5dftQpD98m96Q+nPxwaAth48uJ+gDt3ygi5BRkxW2/kAPwTkgl6nszArURFAOcBmaEzHw8A2JNJAcB+XVJs64fC0H4lebrdAForMaUIk5G3ElM1gElTWmrdiFbdAUbCmEguAe3ifth4sla6dgDuOgnBj8HfCf4BCE7CXe/BtW2w8aT0vXjg4oGNLwM05zMDAH33yIi5F+UN2cHGDIDvywy8Y+H3ALznwxcA3MvRBgAnit2bDeBsji8A2Elit9cDDiphU4MxuYBR+SYxvSU/M2rdiFaj3UTCXDkO/d+tlq6fhTt3wlIBuifFM7i98otq0D0ISzPS5/pZCZ6ZAbjy0pWX+g8BhI945wCCEX8coHt2aRAgm5UZ+JWgCNAxu7oFwJ2PBgBcWxi4+6JTAM6meA7APpEcbM8G1Qe0ik+mBmNKEUYJ3pKfmTTFqHURrVfPwfpHaqWFT6HvHjkQuQVoboXMJMQBOBmJFfEz0tbcKn3qffLMwqdS+vLOwdV3rr6zfjtANO7uAAjf874Oa5I3c7R5BMDvkRl2fLT6FQDvE2HgjkUlAPcVYehMxO0+IPq2oskF9Ay3ajAmvzMZuRrC5GeSptzYAevGq6XaCPSOy4HIvQiNX0L2QXGR3pOQjIA9DnYZkpK0ha9Btg6NnDxTfw6CEfDHIRoHdwfcGLkxsu5tgKTXrgJEkevCTUpwj/cGgH8l6AfoeF8YeOMi1t2vRT8HcP8t+nabAUI9u61yo5G2WnwyNZhWKUIzcklMq1XI99ZKiyeg5yAsVaE7D40ZyA5K6co/AVEV3DykZ8F6TH7pWXCrEOWlT/CsPNOYge5ZWBqE8D3wvg5JL9hVqNaqNdELSWLbsKYEo9PuXoCo7uYAokl3+GYDeL8LvwDgHQqPt/mA8EuKps5qyo1adTPFJ1ODkVLE4iL03FEt1euQy8mB6OoSz5DNiov0fYkVnidB03Ek9luW/NJU2uJY+oShPBMEMkajISlXR4fknq4rSbhtw+Lni5/39AAkFbsIkHxm3w0QO04MEE25BQD/cHAMIDruHoLbpMPhbiVsCsymzqrpr9H2EtfrRyFXrJWWK9BVlH3RWYRmBTJFCI6Cf0RihleUKoJbhOT7YB+EtAJWEayjkB4BuwJJEdwKREXwjkH4PfArEBQhcxSatxuvAnYR6pV6JXcEIB0UzZr02QsA8ZRTAIjLTgnA3xxcAIj3OT9oM8CqOsFWZV3jvKmzSrlxaQa6B6ul5buh6zNY2Qudp8UzZPaIi/R7YPUh6DgP4QvgPS/qwXkAknVg30D05I+AWWBQMo1ki/SJP5BnwhegYxZWt8iYwSKEe8B7A6LT4O6F5DOw74Z0UMT60uzSbPcWgHTAugyQTNrDAMnP7EcBkk32HNymHhBoXG99UtDKuhSYly9D10CttLIAnX1yILIONHOQqUPQD/6Vm7bqw+D+QupJ7gDEXwbnYymx2r8SfWkNgFWBtAj2PCQD4MxDPADuZYg2gDsP0QB0fASrX5F3BP0Q1cHNQeyAE0PSB/YCpANgXYbl+eX5rg0A6ZRVaDOAZoXJMftwmw8ItOhpvqXIJ4WVSegsVEuNKcgWoDkJmWE5IH5hDVcnoWMYwgA8H6JL4N4rMsr5IiTnwX5QBLY1DEwBBWASGAZrCtKCJOFJAZwIYlfKMVEC3icSkDvel7gUTYI7LGrFLUA8BU4Bkkmwh/U9BViZWpnqlGxwzJJ0WLPB/1UPMAUN+YjUKEN2tFZqjkFmVMySGYXgN+DfD8Ex8A9LrPDGIRwDbxSiOXA3QXQK3H2iJ+3X5WuDPQrpJUm001cl37Se0v9jkI5q3yfW0N2nY41BVNJ3jayhf1jmEpfBKUHyM7AfXcN0DKxRaIw1xrIlgPSCJP7puDUCVppmtinxCfNxNHNBPiZm5/5vbG7+/fr9ofVvbgb5NJbZ1ny3NmqZZLb5LmS2iRluxsYEZG/T/kdx/xvwP2XY7MOt27XzAAAAAElFTkSuQmCC"; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
251 o.EmbedContent(s); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
252 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
253 #if ORTHANC_SANDBOXED != 1 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
254 o.SaveToFile("UnitTestsResults/png5.dcm"); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
255 #endif |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
256 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
257 } |
1088
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
258 |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
259 |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
260 TEST(FromDcmtkBridge, Encodings1) |
1088
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
261 { |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
262 for (unsigned int i = 0; i < testEncodingsCount; i++) |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
263 { |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
264 std::string source(testEncodingsEncoded[i]); |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
265 std::string expected(testEncodingsExpected[i]); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
266 std::string s = Toolbox::ConvertToUtf8(source, testEncodings[i], false); |
1695 | 267 //std::cout << EnumerationToString(testEncodings[i]) << std::endl; |
1089 | 268 EXPECT_EQ(expected, s); |
1088
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
269 } |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
270 } |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
271 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
272 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
273 TEST(FromDcmtkBridge, Enumerations) |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
274 { |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
275 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.12.1.1.2 |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
276 Encoding e; |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
277 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
278 ASSERT_FALSE(GetDicomEncoding(e, "")); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
279 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 6")); ASSERT_EQ(Encoding_Ascii, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
280 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
281 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-2 |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
282 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 100")); ASSERT_EQ(Encoding_Latin1, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
283 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 101")); ASSERT_EQ(Encoding_Latin2, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
284 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 109")); ASSERT_EQ(Encoding_Latin3, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
285 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 110")); ASSERT_EQ(Encoding_Latin4, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
286 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 144")); ASSERT_EQ(Encoding_Cyrillic, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
287 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 127")); ASSERT_EQ(Encoding_Arabic, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
288 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 126")); ASSERT_EQ(Encoding_Greek, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
289 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 138")); ASSERT_EQ(Encoding_Hebrew, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
290 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 148")); ASSERT_EQ(Encoding_Latin5, e); |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
291 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 13")); ASSERT_EQ(Encoding_Japanese, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
292 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 166")); ASSERT_EQ(Encoding_Thai, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
293 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
294 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-3 |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
295 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 6")); ASSERT_EQ(Encoding_Ascii, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
296 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 100")); ASSERT_EQ(Encoding_Latin1, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
297 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 101")); ASSERT_EQ(Encoding_Latin2, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
298 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 109")); ASSERT_EQ(Encoding_Latin3, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
299 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 110")); ASSERT_EQ(Encoding_Latin4, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
300 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 144")); ASSERT_EQ(Encoding_Cyrillic, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
301 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 127")); ASSERT_EQ(Encoding_Arabic, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
302 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 126")); ASSERT_EQ(Encoding_Greek, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
303 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 138")); ASSERT_EQ(Encoding_Hebrew, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
304 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 148")); ASSERT_EQ(Encoding_Latin5, e); |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
305 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 13")); ASSERT_EQ(Encoding_Japanese, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
306 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 166")); ASSERT_EQ(Encoding_Thai, e); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
307 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
308 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-4 |
3219 | 309 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 87")); ASSERT_EQ(Encoding_JapaneseKanji, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
310 ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 159")); //ASSERT_EQ(Encoding_JapaneseKanjiSupplementary, e); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
311 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 149")); ASSERT_EQ(Encoding_Korean, e); |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
312 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 58")); ASSERT_EQ(Encoding_SimplifiedChinese, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
313 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
314 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-5 |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
315 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 192")); ASSERT_EQ(Encoding_Utf8, e); |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
316 ASSERT_TRUE(GetDicomEncoding(e, "GB18030")); ASSERT_EQ(Encoding_Chinese, e); |
2401
a051aba0037c
Use "GBK" (frequently used in China) as an alias for "GB18030"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
317 ASSERT_TRUE(GetDicomEncoding(e, "GBK")); ASSERT_EQ(Encoding_Chinese, e); |
5291
800261398381
Made Orthanc more resilient to common spelling errors in SpecificCharacterSet
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
318 |
800261398381
Made Orthanc more resilient to common spelling errors in SpecificCharacterSet
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
319 // common spelling mistakes |
800261398381
Made Orthanc more resilient to common spelling errors in SpecificCharacterSet
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
320 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR_100")); ASSERT_EQ(Encoding_Latin1, e); |
800261398381
Made Orthanc more resilient to common spelling errors in SpecificCharacterSet
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
321 ASSERT_TRUE(GetDicomEncoding(e, "ISO_2022_IR_6")); ASSERT_EQ(Encoding_Ascii, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
322 } |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
323 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
324 |
1091 | 325 TEST(FromDcmtkBridge, Encodings3) |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
326 { |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
327 for (unsigned int i = 0; i < testEncodingsCount; i++) |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
328 { |
1695 | 329 //std::cout << EnumerationToString(testEncodings[i]) << std::endl; |
1091 | 330 std::string dicom; |
331 | |
332 { | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
333 ParsedDicomFile f(true); |
1091 | 334 f.SetEncoding(testEncodings[i]); |
1695 | 335 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
336 std::string s = Toolbox::ConvertToUtf8(testEncodingsEncoded[i], testEncodings[i], false); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
337 f.Insert(DICOM_TAG_PATIENT_NAME, s, false, ""); |
1091 | 338 f.SaveToMemoryBuffer(dicom); |
339 } | |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
340 |
1347 | 341 if (testEncodings[i] != Encoding_Windows1251) |
1091 | 342 { |
343 ParsedDicomFile g(dicom); | |
344 | |
345 if (testEncodings[i] != Encoding_Ascii) | |
346 { | |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
347 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
348 ASSERT_EQ(testEncodings[i], g.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
349 ASSERT_FALSE(hasCodeExtensions); |
1091 | 350 } |
351 | |
352 std::string tag; | |
353 ASSERT_TRUE(g.GetTagValue(tag, DICOM_TAG_PATIENT_NAME)); | |
354 ASSERT_EQ(std::string(testEncodingsExpected[i]), tag); | |
355 } | |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
356 } |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
357 } |
1360 | 358 |
359 | |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
360 TEST(FromDcmtkBridge, ValueRepresentation) |
1360 | 361 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
362 ASSERT_EQ(ValueRepresentation_PersonName, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
363 FromDcmtkBridge::LookupValueRepresentation(DICOM_TAG_PATIENT_NAME)); |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
364 ASSERT_EQ(ValueRepresentation_Date, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
365 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0020) /* StudyDate */)); |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
366 ASSERT_EQ(ValueRepresentation_Time, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
367 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0030) /* StudyTime */)); |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
368 ASSERT_EQ(ValueRepresentation_DateTime, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
369 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x002a) /* AcquisitionDateTime */)); |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
370 ASSERT_EQ(ValueRepresentation_NotSupported, |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
371 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0001, 0x0001) /* some private tag */)); |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
372 } |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
373 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
374 |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
375 TEST(FromDcmtkBridge, ParseListOfTags) |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
376 { |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
377 {// nominal test |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
378 std::string source = "0010,0010;PatientBirthDate;0020,0020"; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
379 std::set<DicomTag> result; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
380 FromDcmtkBridge::ParseListOfTags(result, source); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
381 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
382 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_NAME) != result.end()); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
383 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_BIRTH_DATE) != result.end()); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
384 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ORIENTATION) != result.end()); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
385 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ID) == result.end()); |
4941 | 386 |
387 // serialize to string | |
388 std::string serialized; | |
389 FromDcmtkBridge::FormatListOfTags(serialized, result); | |
390 ASSERT_EQ("0010,0010;0010,0030;0020,0020", serialized); | |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
391 } |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
392 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
393 {// no tag |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
394 std::string source = ""; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
395 std::set<DicomTag> result; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
396 FromDcmtkBridge::ParseListOfTags(result, source); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
397 |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4954
diff
changeset
|
398 ASSERT_EQ(0u, result.size()); |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
399 } |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
400 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
401 {// invalid tag |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
402 std::string source = "0010,0010;Patient-BirthDate;0020,0020"; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
403 std::set<DicomTag> result; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
404 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
405 ASSERT_THROW(FromDcmtkBridge::ParseListOfTags(result, source), OrthancException); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
406 } |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
407 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
408 {// duplicate tag only once |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
409 std::string source = "0010,0010;PatientName"; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
410 std::set<DicomTag> result; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
411 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
412 FromDcmtkBridge::ParseListOfTags(result, source); |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
413 |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4954
diff
changeset
|
414 ASSERT_EQ(1u, result.size()); |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
415 } |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
416 |
4941 | 417 {// Json |
418 Json::Value source = Json::arrayValue; | |
419 source.append("0010,0010"); | |
420 source.append("PatientBirthDate"); | |
421 source.append("0020,0020"); | |
422 std::set<DicomTag> result; | |
423 FromDcmtkBridge::ParseListOfTags(result, source); | |
424 | |
425 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_NAME) != result.end()); | |
426 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_BIRTH_DATE) != result.end()); | |
427 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ORIENTATION) != result.end()); | |
428 ASSERT_TRUE(result.find(DICOM_TAG_PATIENT_ID) == result.end()); | |
429 } | |
430 | |
431 | |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
432 } |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
433 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
434 static const DicomTag REFERENCED_STUDY_SEQUENCE(0x0008, 0x1110); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
435 static const DicomTag REFERENCED_PATIENT_SEQUENCE(0x0008, 0x1120); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
436 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
437 static void CreateSampleJson(Json::Value& a) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
438 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
439 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
440 Json::Value b = Json::objectValue; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
441 b["PatientName"] = "Hello"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
442 b["PatientID"] = "World"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
443 b["StudyDescription"] = "Toto"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
444 a.append(b); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
445 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
446 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
447 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
448 Json::Value b = Json::objectValue; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
449 b["PatientName"] = "data:application/octet-stream;base64,SGVsbG8y"; // echo -n "Hello2" | base64 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
450 b["PatientID"] = "World2"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
451 a.append(b); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
452 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
453 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
454 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
455 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
456 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
457 TEST(ParsedDicomFile, InsertReplaceStrings) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
458 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
459 ParsedDicomFile f(true); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
460 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
461 f.Insert(DICOM_TAG_PATIENT_NAME, "World", false, ""); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
462 ASSERT_THROW(f.Insert(DICOM_TAG_PATIENT_ID, "Hello", false, ""), OrthancException); // Already existing tag |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
463 f.ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, "Toto"); // (*) |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
464 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "Tata"); // (**) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
465 |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4465
diff
changeset
|
466 DicomTransferSyntax syntax; |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4465
diff
changeset
|
467 ASSERT_TRUE(f.LookupTransferSyntax(syntax)); |
3974
bd0af2e11325
fix for big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
468 // The default transfer syntax depends on the OS endianness |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4465
diff
changeset
|
469 ASSERT_TRUE(syntax == DicomTransferSyntax_LittleEndianExplicit || |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4465
diff
changeset
|
470 syntax == DicomTransferSyntax_BigEndianExplicit); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
471 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
472 ASSERT_THROW(f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession"), |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
473 false, DicomReplaceMode_ThrowIfAbsent, ""), OrthancException); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
474 f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession"), false, DicomReplaceMode_IgnoreIfAbsent, ""); |
4507
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4465
diff
changeset
|
475 |
b4c58795f3a8
widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4465
diff
changeset
|
476 std::string s; |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
477 ASSERT_FALSE(f.GetTagValue(s, DICOM_TAG_ACCESSION_NUMBER)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
478 f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession"), false, DicomReplaceMode_InsertIfAbsent, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
479 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_ACCESSION_NUMBER)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
480 ASSERT_EQ(s, "Accession"); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
481 f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession2"), false, DicomReplaceMode_IgnoreIfAbsent, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
482 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_ACCESSION_NUMBER)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
483 ASSERT_EQ(s, "Accession2"); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
484 f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession3"), false, DicomReplaceMode_ThrowIfAbsent, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
485 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_ACCESSION_NUMBER)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
486 ASSERT_EQ(s, "Accession3"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
487 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
488 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_PATIENT_NAME)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
489 ASSERT_EQ(s, "World"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
490 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_SOP_INSTANCE_UID)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
491 ASSERT_EQ(s, "Toto"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
492 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID)); // Implicitly modified by (*) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
493 ASSERT_EQ(s, "Toto"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
494 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_SOP_CLASS_UID)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
495 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
496 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_MEDIA_STORAGE_SOP_CLASS_UID)); // Implicitly modified by (**) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
497 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
498 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
499 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
500 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
501 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
502 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
503 TEST(ParsedDicomFile, InsertReplaceJson) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
504 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
505 ParsedDicomFile f(true); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
506 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
507 Json::Value a; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
508 CreateSampleJson(a); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
509 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
510 ASSERT_FALSE(f.HasTag(REFERENCED_STUDY_SEQUENCE)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
511 f.Remove(REFERENCED_STUDY_SEQUENCE); // No effect |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
512 f.Insert(REFERENCED_STUDY_SEQUENCE, a, true, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
513 ASSERT_TRUE(f.HasTag(REFERENCED_STUDY_SEQUENCE)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
514 ASSERT_THROW(f.Insert(REFERENCED_STUDY_SEQUENCE, a, true, ""), OrthancException); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
515 f.Remove(REFERENCED_STUDY_SEQUENCE); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
516 ASSERT_FALSE(f.HasTag(REFERENCED_STUDY_SEQUENCE)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
517 f.Insert(REFERENCED_STUDY_SEQUENCE, a, true, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
518 ASSERT_TRUE(f.HasTag(REFERENCED_STUDY_SEQUENCE)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
519 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
520 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
521 ASSERT_THROW(f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_ThrowIfAbsent, ""), OrthancException); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
522 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
523 f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_IgnoreIfAbsent, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
524 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE)); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
525 f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_InsertIfAbsent, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
526 ASSERT_TRUE(f.HasTag(REFERENCED_PATIENT_SEQUENCE)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
527 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
528 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
529 Json::Value b; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
530 f.DatasetToJson(b, DicomToJsonFormat_Full, DicomToJsonFlags_Default, 0); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
531 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
532 Json::Value c; |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
533 Toolbox::SimplifyDicomAsJson(c, b, DicomToJsonFormat_Human); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
534 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
535 ASSERT_EQ(0, c["ReferencedPatientSequence"].compare(a)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
536 ASSERT_NE(0, c["ReferencedStudySequence"].compare(a)); // Because Data URI Scheme decoding was enabled |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
537 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
538 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
539 a = "data:application/octet-stream;base64,VGF0YQ=="; // echo -n "Tata" | base64 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
540 f.Replace(DICOM_TAG_SOP_INSTANCE_UID, a, false, DicomReplaceMode_InsertIfAbsent, ""); // (*) |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
541 f.Replace(DICOM_TAG_SOP_CLASS_UID, a, true, DicomReplaceMode_InsertIfAbsent, ""); // (**) |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
542 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
543 std::string s; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
544 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_SOP_INSTANCE_UID)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
545 ASSERT_EQ(s, a.asString()); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
546 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID)); // Implicitly modified by (*) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
547 ASSERT_EQ(s, a.asString()); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
548 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_SOP_CLASS_UID)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
549 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
550 ASSERT_TRUE(f.GetTagValue(s, DICOM_TAG_MEDIA_STORAGE_SOP_CLASS_UID)); // Implicitly modified by (**) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
551 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
552 } |
1695 | 553 |
554 | |
555 TEST(ParsedDicomFile, JsonEncoding) | |
556 { | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
557 ParsedDicomFile f(true); |
1695 | 558 |
559 for (unsigned int i = 0; i < testEncodingsCount; i++) | |
560 { | |
561 if (testEncodings[i] != Encoding_Windows1251) | |
562 { | |
563 //std::cout << EnumerationToString(testEncodings[i]) << std::endl; | |
564 f.SetEncoding(testEncodings[i]); | |
565 | |
566 if (testEncodings[i] != Encoding_Ascii) | |
567 { | |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
568 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
569 ASSERT_EQ(testEncodings[i], f.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
570 ASSERT_FALSE(hasCodeExtensions); |
1695 | 571 } |
572 | |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
573 Json::Value s = Toolbox::ConvertToUtf8(testEncodingsEncoded[i], testEncodings[i], false); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
574 f.Replace(DICOM_TAG_PATIENT_NAME, s, false, DicomReplaceMode_InsertIfAbsent, ""); |
1695 | 575 |
576 Json::Value v; | |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
577 f.DatasetToJson(v, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0); |
1695 | 578 ASSERT_EQ(v["PatientName"].asString(), std::string(testEncodingsExpected[i])); |
579 } | |
580 } | |
581 } | |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
582 |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
583 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
584 TEST(ParsedDicomFile, ToJsonFlags1) |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
585 { |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
586 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7053, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag", 1, 1, "OrthancCreator"); |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2107
diff
changeset
|
587 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1000), ValueRepresentation_PersonName, "Declared public tag", 1, 1, ""); |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
588 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
589 ParsedDicomFile f(true); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
590 f.Insert(DicomTag(0x7050, 0x1000), "Some public tag", false, ""); // Even group => public tag |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
591 f.Insert(DicomTag(0x7052, 0x1000), "Some unknown tag", false, ""); // Even group => public, unknown tag |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
592 f.Insert(DicomTag(0x7053, 0x1000), "Some private tag", false, "OrthancCreator"); // Odd group => private tag |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
593 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
594 Json::Value v; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
595 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
596 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
597 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
598 ASSERT_FALSE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
599 ASSERT_FALSE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
600 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
601 ASSERT_EQ(Json::stringValue, v["7050,1000"].type()); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
602 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
603 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
604 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_IncludeBinary | DicomToJsonFlags_ConvertBinaryToNull), 0); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
605 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
606 ASSERT_EQ(7u, v.getMemberNames().size()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
607 ASSERT_FALSE(v.isMember("7052,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
608 ASSERT_TRUE(v.isMember("7050,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
609 ASSERT_TRUE(v.isMember("7053,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
610 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
611 ASSERT_EQ(Json::nullValue, v["7053,1000"].type()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
612 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
613 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags), 0); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
614 ASSERT_EQ(Json::objectValue, v.type()); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
615 ASSERT_EQ(6u, v.getMemberNames().size()); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
616 ASSERT_FALSE(v.isMember("7052,1000")); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
617 ASSERT_TRUE(v.isMember("7050,1000")); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
618 ASSERT_FALSE(v.isMember("7053,1000")); |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
619 |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
620 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_IncludeBinary), 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
621 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
622 ASSERT_EQ(7u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
623 ASSERT_FALSE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
624 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
625 ASSERT_TRUE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
626 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
627 std::string mime, content; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
628 ASSERT_EQ(Json::stringValue, v["7053,1000"].type()); |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
629 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7053,1000"].asString())); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
630 ASSERT_EQ("application/octet-stream", mime); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
631 ASSERT_EQ("Some private tag", content); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
632 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
633 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludeBinary | DicomToJsonFlags_ConvertBinaryToNull), 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
634 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
635 ASSERT_EQ(7u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
636 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
637 ASSERT_TRUE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
638 ASSERT_FALSE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
639 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
640 ASSERT_EQ(Json::nullValue, v["7052,1000"].type()); |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
641 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
642 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludeBinary), 0); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
643 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
644 ASSERT_EQ(7u, v.getMemberNames().size()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
645 ASSERT_TRUE(v.isMember("7050,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
646 ASSERT_TRUE(v.isMember("7052,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
647 ASSERT_FALSE(v.isMember("7053,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
648 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
649 ASSERT_EQ(Json::stringValue, v["7052,1000"].type()); |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
650 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7052,1000"].asString())); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
651 ASSERT_EQ("application/octet-stream", mime); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
652 ASSERT_EQ("Some unknown tag", content); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
653 |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
654 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_IncludeBinary | DicomToJsonFlags_ConvertBinaryToNull), 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
655 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
656 ASSERT_EQ(8u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
657 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
658 ASSERT_TRUE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
659 ASSERT_TRUE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
660 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
661 ASSERT_EQ(Json::nullValue, v["7052,1000"].type()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
662 ASSERT_EQ(Json::nullValue, v["7053,1000"].type()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
663 } |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
664 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
665 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
666 TEST(ParsedDicomFile, ToJsonFlags2) |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
667 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
668 ParsedDicomFile f(true); |
3832
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
669 |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
670 { |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
671 // "ParsedDicomFile" uses Little Endian => 'B' (least significant |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
672 // byte) will be stored first in the memory buffer and in the |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
673 // file, then 'A'. Hence the expected "BA" value below. |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
674 Uint16 v[] = { 'A' * 256 + 'B', 0 }; |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
675 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertUint16Array(DCM_PixelData, v, 2).good()); |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
676 } |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
677 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
678 Json::Value v; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
679 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
680 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
681 ASSERT_EQ(5u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
682 ASSERT_FALSE(v.isMember("7fe0,0010")); |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
683 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
684 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePixelData | DicomToJsonFlags_ConvertBinaryToNull), 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
685 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
686 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
687 ASSERT_TRUE(v.isMember("7fe0,0010")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
688 ASSERT_EQ(Json::nullValue, v["7fe0,0010"].type()); |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
689 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
690 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePixelData | DicomToJsonFlags_ConvertBinaryToAscii), 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
691 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
692 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
693 ASSERT_TRUE(v.isMember("7fe0,0010")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
694 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type()); |
3832
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
695 ASSERT_EQ("BA", v["7fe0,0010"].asString().substr(0, 2)); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
696 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
697 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePixelData, 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
698 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
699 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
700 ASSERT_TRUE(v.isMember("7fe0,0010")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
701 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type()); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
702 std::string mime, content; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
703 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7fe0,0010"].asString())); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
704 ASSERT_EQ("application/octet-stream", mime); |
3832
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
705 ASSERT_EQ("BA", content.substr(0, 2)); |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
706 } |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
707 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
708 |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
709 TEST(ParsedDicomFile, ToJsonFlags3) |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
710 { |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
711 ParsedDicomFile f(false); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
712 |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
713 { |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
714 Uint8 v[2] = { 0, 0 }; |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
715 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertString(DCM_PatientName, "HELLO^").good()); |
4516
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
716 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertUint32(DcmTag(0x4000, 0x0000), 42).good()); |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
717 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertUint8Array(DCM_PixelData, v, 2).good()); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
718 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertString(DcmTag(0x07fe1, 0x0010), "WORLD^").good()); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
719 } |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
720 |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
721 std::string s; |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
722 Toolbox::EncodeDataUriScheme(s, "application/octet-stream", std::string(2, '\0')); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
723 |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
724 { |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
725 Json::Value v; |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
726 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_IncludePixelData | DicomToJsonFlags_StopAfterPixelData), 0); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
727 ASSERT_EQ(Json::objectValue, v.type()); |
4516
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
728 ASSERT_EQ(3u, v.size()); |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
729 ASSERT_EQ("HELLO^", v["0010,0010"].asString()); |
4516
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
730 ASSERT_EQ("42", v["4000,0000"].asString()); |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
731 ASSERT_EQ(s, v["7fe0,0010"].asString()); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
732 } |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
733 |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
734 { |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
735 Json::Value v; |
4516
671ee7c1fd46
added DicomToJsonFlags_SkipGroupLengths
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4515
diff
changeset
|
736 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_SkipGroupLengths), 0); |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
737 ASSERT_EQ(Json::objectValue, v.type()); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
738 ASSERT_EQ(2u, v.size()); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
739 ASSERT_EQ("HELLO^", v["0010,0010"].asString()); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
740 ASSERT_EQ("WORLD^", v["7fe1,0010"].asString()); |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
741 } |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
742 } |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
743 |
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4507
diff
changeset
|
744 |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
745 TEST(DicomFindAnswers, Basic) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
746 { |
2059 | 747 DicomFindAnswers a(false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
748 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
749 { |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
750 DicomMap m; |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
751 m.SetValue(DICOM_TAG_PATIENT_ID, "hello", false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
752 a.Add(m); |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
753 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
754 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
755 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
756 ParsedDicomFile d(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
757 d.ReplacePlainString(DICOM_TAG_PATIENT_ID, "my"); |
1789 | 758 a.Add(d); |
759 } | |
760 | |
761 { | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
762 DicomMap m; |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
763 m.SetValue(DICOM_TAG_PATIENT_ID, "world", false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
764 a.Add(m); |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
765 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
766 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
767 Json::Value j; |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4700
diff
changeset
|
768 a.ToJson(j, DicomToJsonFormat_Human); |
1789 | 769 ASSERT_EQ(3u, j.size()); |
770 | |
771 //std::cout << j; | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
772 } |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
773 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
774 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
775 TEST(ParsedDicomFile, FromJson) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
776 { |
2117 | 777 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7057, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag2", 1, 1, "ORTHANC"); |
778 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7059, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag3", 1, 1, ""); | |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4693
diff
changeset
|
779 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1002), ValueRepresentation_PersonName, "Declared public tag2", 1, 1, ""); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
780 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
781 Json::Value v; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
782 const std::string sopClassUid = "1.2.840.10008.5.1.4.1.1.1"; // CR Image Storage: |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
783 |
2117 | 784 // Test the private creator |
785 ASSERT_EQ(DcmTag_ERROR_TagName, FromDcmtkBridge::GetTagName(DicomTag(0x7057, 0x1000), "NOPE")); | |
786 ASSERT_EQ("MyPrivateTag2", FromDcmtkBridge::GetTagName(DicomTag(0x7057, 0x1000), "ORTHANC")); | |
787 | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
788 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
789 v["SOPClassUID"] = sopClassUid; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
790 v["SpecificCharacterSet"] = "ISO_IR 148"; // This is latin-5 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
791 v["PatientName"] = "Sébastien"; |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4693
diff
changeset
|
792 v["7050-1002"] = "Some public tag"; // Even group => public tag |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
793 v["7052-1000"] = "Some unknown tag"; // Even group => public, unknown tag |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
794 v["7057-1000"] = "Some private tag"; // Odd group => private tag |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
795 v["7059-1000"] = "Some private tag2"; // Odd group => private tag, with an odd length to test padding |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
796 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
797 std::string s; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
798 Toolbox::EncodeDataUriScheme(s, "application/octet-stream", "Sebastien"); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
799 v["StudyDescription"] = s; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
800 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
801 v["PixelData"] = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; // A red dot of 5x5 pixels |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
802 v["0040,0100"] = Json::arrayValue; // ScheduledProcedureStepSequence |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
803 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
804 Json::Value vv; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
805 vv["Modality"] = "MR"; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
806 v["0040,0100"].append(vv); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
807 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
808 vv["Modality"] = "CT"; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
809 v["0040,0100"].append(vv); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
810 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
811 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
812 const DicomToJsonFlags toJsonFlags = static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeBinary | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
813 DicomToJsonFlags_IncludePixelData | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
814 DicomToJsonFlags_IncludePrivateTags | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
815 DicomToJsonFlags_IncludeUnknownTags | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
816 DicomToJsonFlags_ConvertBinaryToAscii); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
817 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
818 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
819 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
820 std::unique_ptr<ParsedDicomFile> dicom |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
821 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers), "")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
822 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
823 Json::Value vv; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
824 dicom->DatasetToJson(vv, DicomToJsonFormat_Human, toJsonFlags, 0); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
825 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
826 ASSERT_EQ(vv["SOPClassUID"].asString(), sopClassUid); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
827 ASSERT_EQ(vv["MediaStorageSOPClassUID"].asString(), sopClassUid); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
828 ASSERT_TRUE(vv.isMember("SOPInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
829 ASSERT_TRUE(vv.isMember("SeriesInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
830 ASSERT_TRUE(vv.isMember("StudyInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
831 ASSERT_TRUE(vv.isMember("PatientID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
832 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
833 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
834 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
835 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
836 std::unique_ptr<ParsedDicomFile> dicom |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
837 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers), "")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
838 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
839 Json::Value vv; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
840 dicom->DatasetToJson(vv, DicomToJsonFormat_Human, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePixelData), 0); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
841 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
842 std::string mime, content; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
843 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, vv["PixelData"].asString())); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
844 ASSERT_EQ("application/octet-stream", mime); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
845 ASSERT_EQ(5u * 5u * 3u /* the red dot is 5x5 pixels in RGB24 */ + 1 /* for padding */, content.size()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
846 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
847 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
848 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
849 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
850 std::unique_ptr<ParsedDicomFile> dicom |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
851 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_DecodeDataUriScheme), "")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
852 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
853 Json::Value vv; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
854 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, toJsonFlags, 0); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
855 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
856 ASSERT_FALSE(vv.isMember("SOPInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
857 ASSERT_FALSE(vv.isMember("SeriesInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
858 ASSERT_FALSE(vv.isMember("StudyInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
859 ASSERT_FALSE(vv.isMember("PatientID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
860 ASSERT_EQ(2u, vv["0040,0100"].size()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
861 ASSERT_EQ("MR", vv["0040,0100"][0]["0008,0060"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
862 ASSERT_EQ("CT", vv["0040,0100"][1]["0008,0060"].asString()); |
4696
dd6274412ff4
new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4693
diff
changeset
|
863 ASSERT_EQ("Some public tag", vv["7050,1002"].asString()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
864 ASSERT_EQ("Some unknown tag", vv["7052,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
865 ASSERT_EQ("Some private tag", vv["7057,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
866 ASSERT_EQ("Some private tag2", vv["7059,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
867 ASSERT_EQ("Sébastien", vv["0010,0010"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
868 ASSERT_EQ("Sebastien", vv["0008,1030"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
869 ASSERT_EQ("ISO_IR 148", vv["0008,0005"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
870 ASSERT_EQ("5", vv[DICOM_TAG_ROWS.Format()].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
871 ASSERT_EQ("5", vv[DICOM_TAG_COLUMNS.Format()].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
872 ASSERT_TRUE(vv[DICOM_TAG_PIXEL_DATA.Format()].asString().empty()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
873 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
874 } |
1937 | 875 |
876 | |
877 | |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
878 TEST(TestImages, PatternGrayscale8) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
879 { |
2107 | 880 Orthanc::Image image(Orthanc::PixelFormat_Grayscale8, 256, 256, false); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
881 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
882 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
883 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
884 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
885 for (int x = 0; x < 256; x++, p++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
886 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
887 *p = y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
888 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
889 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
890 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
891 Orthanc::ImageAccessor r; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
892 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
893 image.GetRegion(r, 32, 32, 64, 192); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
894 Orthanc::ImageProcessing::Set(r, 0); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
895 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
896 image.GetRegion(r, 160, 32, 64, 192); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
897 Orthanc::ImageProcessing::Set(r, 255); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
898 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
899 std::string saved; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
900 |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
901 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
902 ParsedDicomFile f(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
903 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
904 f.ReplacePlainString(DICOM_TAG_STUDY_INSTANCE_UID, "1.2.276.0.7230010.3.1.2.2831176407.321.1458901422.884998"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
905 f.ReplacePlainString(DICOM_TAG_PATIENT_ID, "ORTHANC"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
906 f.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Orthanc"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
907 f.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, "Patterns"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
908 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale8"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
909 f.EmbedImage(image); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
910 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
911 f.SaveToMemoryBuffer(saved); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
912 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
913 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
914 { |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
915 Orthanc::ParsedDicomFile f(saved); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
916 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
917 std::unique_ptr<Orthanc::ImageAccessor> decoded(f.DecodeFrame(0)); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
918 ASSERT_EQ(256u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
919 ASSERT_EQ(256u, decoded->GetHeight()); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
920 ASSERT_EQ(Orthanc::PixelFormat_Grayscale8, decoded->GetFormat()); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
921 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
922 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
923 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
924 const void* a = image.GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
925 const void* b = decoded->GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
926 ASSERT_EQ(0, memcmp(a, b, 256)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
927 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
928 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
929 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
930 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
931 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
932 TEST(TestImages, PatternRGB) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
933 { |
2107 | 934 Orthanc::Image image(Orthanc::PixelFormat_RGB24, 384, 256, false); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
935 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
936 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
937 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
938 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
939 for (int x = 0; x < 128; x++, p += 3) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
940 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
941 p[0] = y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
942 p[1] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
943 p[2] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
944 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
945 for (int x = 128; x < 128 * 2; x++, p += 3) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
946 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
947 p[0] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
948 p[1] = 255 - y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
949 p[2] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
950 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
951 for (int x = 128 * 2; x < 128 * 3; x++, p += 3) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
952 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
953 p[0] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
954 p[1] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
955 p[2] = y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
956 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
957 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
958 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
959 std::string saved; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
960 |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
961 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
962 ParsedDicomFile f(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
963 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
964 f.ReplacePlainString(DICOM_TAG_STUDY_INSTANCE_UID, "1.2.276.0.7230010.3.1.2.2831176407.321.1458901422.884998"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
965 f.ReplacePlainString(DICOM_TAG_PATIENT_ID, "ORTHANC"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
966 f.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Orthanc"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
967 f.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, "Patterns"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
968 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "RGB24"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
969 f.EmbedImage(image); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
970 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
971 f.SaveToMemoryBuffer(saved); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
972 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
973 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
974 { |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
975 Orthanc::ParsedDicomFile f(saved); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
976 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
977 std::unique_ptr<Orthanc::ImageAccessor> decoded(f.DecodeFrame(0)); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
978 ASSERT_EQ(384u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
979 ASSERT_EQ(256u, decoded->GetHeight()); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
980 ASSERT_EQ(Orthanc::PixelFormat_RGB24, decoded->GetFormat()); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
981 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
982 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
983 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
984 const void* a = image.GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
985 const void* b = decoded->GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
986 ASSERT_EQ(0, memcmp(a, b, 3 * 384)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
987 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
988 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
989 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
990 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
991 |
1940 | 992 TEST(TestImages, PatternUint16) |
1937 | 993 { |
2107 | 994 Orthanc::Image image(Orthanc::PixelFormat_Grayscale16, 256, 256, false); |
1937 | 995 |
996 uint16_t v = 0; | |
997 for (int y = 0; y < 256; y++) | |
998 { | |
999 uint16_t *p = reinterpret_cast<uint16_t*>(image.GetRow(y)); | |
1000 for (int x = 0; x < 256; x++, v++, p++) | |
1001 { | |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4519
diff
changeset
|
1002 *p = v; |
1937 | 1003 } |
1004 } | |
1005 | |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1006 Orthanc::ImageAccessor r; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1007 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1008 image.GetRegion(r, 32, 32, 64, 192); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1009 Orthanc::ImageProcessing::Set(r, 0); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1010 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1011 image.GetRegion(r, 160, 32, 64, 192); |
1940 | 1012 Orthanc::ImageProcessing::Set(r, 65535); |
1013 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1014 std::string saved; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1015 |
1940 | 1016 { |
1017 ParsedDicomFile f(true); | |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1018 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1019 f.ReplacePlainString(DICOM_TAG_STUDY_INSTANCE_UID, "1.2.276.0.7230010.3.1.2.2831176407.321.1458901422.884998"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1020 f.ReplacePlainString(DICOM_TAG_PATIENT_ID, "ORTHANC"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1021 f.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Orthanc"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1022 f.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, "Patterns"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1023 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale16"); |
1940 | 1024 f.EmbedImage(image); |
1025 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1026 f.SaveToMemoryBuffer(saved); |
1940 | 1027 } |
1937 | 1028 |
1940 | 1029 { |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1030 Orthanc::ParsedDicomFile f(saved); |
1940 | 1031 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1032 std::unique_ptr<Orthanc::ImageAccessor> decoded(f.DecodeFrame(0)); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
1033 ASSERT_EQ(256u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
1034 ASSERT_EQ(256u, decoded->GetHeight()); |
1940 | 1035 ASSERT_EQ(Orthanc::PixelFormat_Grayscale16, decoded->GetFormat()); |
1036 | |
1037 for (int y = 0; y < 256; y++) | |
1038 { | |
1039 const void* a = image.GetConstRow(y); | |
1040 const void* b = decoded->GetConstRow(y); | |
1041 ASSERT_EQ(0, memcmp(a, b, 512)); | |
1042 } | |
1043 } | |
1937 | 1044 } |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1045 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1046 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1047 TEST(TestImages, PatternInt16) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1048 { |
2107 | 1049 Orthanc::Image image(Orthanc::PixelFormat_SignedGrayscale16, 256, 256, false); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1050 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1051 int16_t v = -32768; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1052 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1053 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1054 int16_t *p = reinterpret_cast<int16_t*>(image.GetRow(y)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1055 for (int x = 0; x < 256; x++, v++, p++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1056 { |
4532
11bfea08341a
fix ParsedDicomImage::EmbedImage() on big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4519
diff
changeset
|
1057 *p = v; |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1058 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1059 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1060 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1061 Orthanc::ImageAccessor r; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1062 image.GetRegion(r, 32, 32, 64, 192); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1063 Orthanc::ImageProcessing::Set(r, -32768); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1064 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
1065 image.GetRegion(r, 160, 32, 64, 192); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1066 Orthanc::ImageProcessing::Set(r, 32767); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1067 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1068 std::string saved; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1069 |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1070 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1071 ParsedDicomFile f(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1072 f.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.7"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1073 f.ReplacePlainString(DICOM_TAG_STUDY_INSTANCE_UID, "1.2.276.0.7230010.3.1.2.2831176407.321.1458901422.884998"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1074 f.ReplacePlainString(DICOM_TAG_PATIENT_ID, "ORTHANC"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1075 f.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Orthanc"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1076 f.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, "Patterns"); |
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
1077 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "SignedGrayscale16"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1078 f.EmbedImage(image); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1079 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1080 f.SaveToMemoryBuffer(saved); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1081 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1082 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1083 { |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
1084 Orthanc::ParsedDicomFile f(saved); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1085 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1086 std::unique_ptr<Orthanc::ImageAccessor> decoded(f.DecodeFrame(0)); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
1087 ASSERT_EQ(256u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
1088 ASSERT_EQ(256u, decoded->GetHeight()); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1089 ASSERT_EQ(Orthanc::PixelFormat_SignedGrayscale16, decoded->GetFormat()); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1090 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1091 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1092 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1093 const void* a = image.GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1094 const void* b = decoded->GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1095 ASSERT_EQ(0, memcmp(a, b, 512)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1096 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1097 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
1098 } |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1099 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1100 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1101 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1102 static void CheckEncoding(ParsedDicomFile& dicom, |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1103 Encoding expected) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1104 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1105 const char* value = NULL; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1106 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->findAndGetString(DCM_SpecificCharacterSet, value).good()); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1107 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1108 Encoding encoding; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1109 ASSERT_TRUE(GetDicomEncoding(encoding, value)); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1110 ASSERT_EQ(expected, encoding); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1111 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1112 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1113 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1114 TEST(ParsedDicomFile, DicomMapEncodings1) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1115 { |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
1116 SetDefaultDicomEncoding(Encoding_Ascii); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
1117 ASSERT_EQ(Encoding_Ascii, GetDefaultDicomEncoding()); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1118 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1119 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1120 DicomMap m; |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1121 ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1122 ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card()); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1123 CheckEncoding(dicom, Encoding_Ascii); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1124 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1125 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1126 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1127 DicomMap m; |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1128 ParsedDicomFile dicom(m, Encoding_Latin4, false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1129 ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card()); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1130 CheckEncoding(dicom, Encoding_Latin4); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1131 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1132 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1133 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1134 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1135 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false); |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1136 ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1137 ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card()); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1138 CheckEncoding(dicom, Encoding_Latin5); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1139 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1140 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1141 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1142 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1143 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false); |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1144 ParsedDicomFile dicom(m, Encoding_Latin1, false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1145 ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card()); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1146 CheckEncoding(dicom, Encoding_Latin5); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1147 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1148 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1149 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1150 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1151 TEST(ParsedDicomFile, DicomMapEncodings2) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1152 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1153 const char* utf8 = NULL; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1154 for (unsigned int i = 0; i < testEncodingsCount; i++) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1155 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1156 if (testEncodings[i] == Encoding_Utf8) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1157 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1158 utf8 = testEncodingsEncoded[i]; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1159 break; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1160 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1161 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1162 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1163 ASSERT_TRUE(utf8 != NULL); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1164 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1165 for (unsigned int i = 0; i < testEncodingsCount; i++) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1166 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1167 // 1251 codepage is not supported by the core DICOM standard, ignore it |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1168 if (testEncodings[i] != Encoding_Windows1251) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1169 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1170 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1171 // Sanity check to test the proper behavior of "EncodingTests.py" |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1172 std::string encoded = Toolbox::ConvertFromUtf8(testEncodingsExpected[i], testEncodings[i]); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1173 ASSERT_STREQ(testEncodingsEncoded[i], encoded.c_str()); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1174 std::string decoded = Toolbox::ConvertToUtf8(encoded, testEncodings[i], false); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1175 ASSERT_STREQ(testEncodingsExpected[i], decoded.c_str()); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1176 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1177 if (testEncodings[i] != Encoding_Chinese) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1178 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1179 // A specific source string is used in "EncodingTests.py" to |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1180 // test against Chinese, it is normal that it does not correspond to UTF8 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1181 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1182 const std::string tmp = Toolbox::ConvertToUtf8( |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1183 Toolbox::ConvertFromUtf8(utf8, testEncodings[i]), testEncodings[i], false); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1184 ASSERT_STREQ(testEncodingsExpected[i], tmp.c_str()); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1185 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1186 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1187 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1188 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1189 Json::Value v; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1190 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1191 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1192 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1193 m.SetValue(DICOM_TAG_PATIENT_NAME, testEncodingsExpected[i], false); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1194 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1195 ParsedDicomFile dicom(m, testEncodings[i], false); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1196 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1197 const char* encoded = NULL; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1198 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->findAndGetString(DCM_PatientName, encoded).good()); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1199 ASSERT_STREQ(testEncodingsEncoded[i], encoded); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1200 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1201 dicom.DatasetToJson(v, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1202 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1203 Encoding encoding; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1204 ASSERT_TRUE(GetDicomEncoding(encoding, v["SpecificCharacterSet"].asCString())); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1205 ASSERT_EQ(encoding, testEncodings[i]); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1206 ASSERT_STREQ(testEncodingsExpected[i], v["PatientName"].asCString()); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1207 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1208 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1209 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1210 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1211 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1212 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, GetDicomSpecificCharacterSet(testEncodings[i]), false); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1213 m.SetValue(DICOM_TAG_PATIENT_NAME, testEncodingsExpected[i], false); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1214 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1215 ParsedDicomFile dicom(m, testEncodings[i], false); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1216 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1217 Json::Value v2; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1218 dicom.DatasetToJson(v2, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1219 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1220 ASSERT_EQ(v2["PatientName"].asString(), v["PatientName"].asString()); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1221 ASSERT_EQ(v2["SpecificCharacterSet"].asString(), v["SpecificCharacterSet"].asString()); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1222 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1223 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1224 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1225 } |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1226 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1227 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1228 TEST(ParsedDicomFile, ChangeEncoding) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1229 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1230 for (unsigned int i = 0; i < testEncodingsCount; i++) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1231 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1232 // 1251 codepage is not supported by the core DICOM standard, ignore it |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1233 if (testEncodings[i] != Encoding_Windows1251) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1234 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1235 DicomMap m; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1236 m.SetValue(DICOM_TAG_PATIENT_NAME, testEncodingsExpected[i], false); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1237 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1238 std::string tag; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1239 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1240 ParsedDicomFile dicom(m, Encoding_Utf8, false); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1241 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1242 ASSERT_EQ(Encoding_Utf8, dicom.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1243 ASSERT_FALSE(hasCodeExtensions); |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1244 ASSERT_TRUE(dicom.GetTagValue(tag, DICOM_TAG_PATIENT_NAME)); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1245 ASSERT_EQ(tag, testEncodingsExpected[i]); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1246 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1247 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1248 Json::Value v; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1249 dicom.DatasetToJson(v, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1250 ASSERT_STREQ(v["SpecificCharacterSet"].asCString(), "ISO_IR 192"); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1251 ASSERT_STREQ(v["PatientName"].asCString(), testEncodingsExpected[i]); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1252 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1253 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1254 dicom.ChangeEncoding(testEncodings[i]); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1255 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1256 ASSERT_EQ(testEncodings[i], dicom.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1257 ASSERT_FALSE(hasCodeExtensions); |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1258 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1259 const char* c = NULL; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1260 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->findAndGetString(DCM_PatientName, c).good()); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1261 EXPECT_STREQ(c, testEncodingsEncoded[i]); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1262 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1263 ASSERT_TRUE(dicom.GetTagValue(tag, DICOM_TAG_PATIENT_NAME)); // Decodes to UTF-8 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1264 EXPECT_EQ(tag, testEncodingsExpected[i]); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1265 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1266 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1267 Json::Value v; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1268 dicom.DatasetToJson(v, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1269 ASSERT_STREQ(v["SpecificCharacterSet"].asCString(), GetDicomSpecificCharacterSet(testEncodings[i])); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1270 ASSERT_STREQ(v["PatientName"].asCString(), testEncodingsExpected[i]); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1271 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1272 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1273 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1274 } |
2326
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1275 |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1276 |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1277 TEST(Toolbox, CaseWithAccents) |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1278 { |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1279 ASSERT_EQ(toUpperResult, Toolbox::ToUpperCaseWithAccents(toUpperSource)); |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1280 } |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1281 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1282 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1283 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1284 TEST(ParsedDicomFile, InvalidCharacterSets) |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1285 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1286 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1287 // No encoding provided, fallback to default encoding |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1288 DicomMap m; |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1289 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1290 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1291 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1292 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1293 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1294 ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1295 ASSERT_FALSE(hasCodeExtensions); |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1296 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1297 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1298 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1299 // Valid encoding, "ISO_IR 13" is Japanese |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1300 DicomMap m; |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1301 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 13", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1302 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1303 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1304 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1305 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1306 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1307 ASSERT_EQ(Encoding_Japanese, d.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1308 ASSERT_FALSE(hasCodeExtensions); |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1309 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1310 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1311 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1312 // Invalid value for an encoding ("nope" is not in the DICOM standard) |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1313 DicomMap m; |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1314 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "nope", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1315 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1316 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1317 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false), |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3974
diff
changeset
|
1318 OrthancException); |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1319 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1320 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1321 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1322 // Invalid encoding, as provided as a binary string |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1323 DicomMap m; |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1324 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 13", true); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1325 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1326 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1327 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false), |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3974
diff
changeset
|
1328 OrthancException); |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1329 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1330 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1331 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1332 // Encoding provided as an empty string, fallback to default encoding |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1333 // In Orthanc <= 1.3.1, this test was throwing an exception |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1334 DicomMap m; |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1335 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1336 m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false); |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1337 |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
1338 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1339 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1340 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1341 ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1342 ASSERT_FALSE(hasCodeExtensions); |
2445
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1343 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1344 } |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1345 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1346 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1347 |
4515
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1348 TEST(ParsedDicomFile, FloatPrecision) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1349 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1350 Float32 v; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1351 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1352 switch (Toolbox::DetectEndianness()) |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1353 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1354 case Endianness_Little: |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1355 reinterpret_cast<uint8_t*>(&v)[3] = 0x4E; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1356 reinterpret_cast<uint8_t*>(&v)[2] = 0x9C; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1357 reinterpret_cast<uint8_t*>(&v)[1] = 0xAD; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1358 reinterpret_cast<uint8_t*>(&v)[0] = 0x8F; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1359 break; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1360 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1361 case Endianness_Big: |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1362 reinterpret_cast<uint8_t*>(&v)[0] = 0x4E; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1363 reinterpret_cast<uint8_t*>(&v)[1] = 0x9C; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1364 reinterpret_cast<uint8_t*>(&v)[2] = 0xAD; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1365 reinterpret_cast<uint8_t*>(&v)[3] = 0x8F; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1366 break; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1367 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1368 default: |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1369 throw OrthancException(ErrorCode_InternalError); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1370 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1371 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1372 ParsedDicomFile f(false); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1373 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertFloat32(DCM_ExaminedBodyThickness /* VR: FL */, v).good()); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1374 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1375 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1376 Float32 u; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1377 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->findAndGetFloat32(DCM_ExaminedBodyThickness, u).good()); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1378 ASSERT_FLOAT_EQ(u, v); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1379 ASSERT_TRUE(memcmp(&u, &v, 4) == 0); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1380 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1381 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1382 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1383 Json::Value json; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1384 f.DatasetToJson(json, DicomToJsonFormat_Short, DicomToJsonFlags_None, 256); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1385 ASSERT_EQ("1314310016", json["0010,9431"].asString()); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1386 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1387 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1388 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1389 DicomMap summary; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1390 f.ExtractDicomSummary(summary, 256); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1391 ASSERT_EQ("1314310016", summary.GetStringValue(DicomTag(0x0010, 0x9431), "nope", false)); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1392 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1393 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1394 { |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1395 // This flavor uses "Json::Value" serialization |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1396 DicomWebJsonVisitor visitor; |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1397 f.Apply(visitor); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1398 Float32 u = visitor.GetResult() ["00109431"]["Value"][0].asFloat(); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1399 ASSERT_FLOAT_EQ(u, v); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1400 ASSERT_TRUE(memcmp(&u, &v, 4) == 0); |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1401 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1402 } |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1403 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1404 |
8734caa12448
Improved precision of floating-point numbers in DICOM-as-JSON and DICOM summary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4514
diff
changeset
|
1405 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1406 TEST(Toolbox, RemoveIso2022EscapeSequences) |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1407 { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1408 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1409 // | one-byte control messages | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1410 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1411 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1412 static const uint8_t iso2022_cstr_oneByteControl[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1413 0x0f, 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1414 0x0e, 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1415 0x8e, 0x1b, 0x4e, 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1416 0x8f, 0x1b, 0x4f, 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1417 0x8e, 0x1b, 0x4a, 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1418 0x8f, 0x1b, 0x4a, 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1419 0x50, 0x51, 0x52, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1420 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1421 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1422 static const uint8_t iso2022_cstr_oneByteControl_ref[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1423 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1424 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1425 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1426 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1427 0x8e, 0x1b, 0x4a, 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1428 0x8f, 0x1b, 0x4a, 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1429 0x50, 0x51, 0x52, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1430 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1431 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1432 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1433 // | two-byte control messages | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1434 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1435 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1436 static const uint8_t iso2022_cstr_twoByteControl[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1437 0x1b, 0x6e, 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1438 0x1b, 0x6f, 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1439 0x1b, 0x4e, 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1440 0x1b, 0x4f, 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1441 0x1b, 0x7e, 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1442 0x1b, 0x7d, 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1443 0x1b, 0x7c, 0x47, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1444 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1445 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1446 static const uint8_t iso2022_cstr_twoByteControl_ref[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1447 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1448 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1449 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1450 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1451 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1452 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1453 0x47, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1454 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1455 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1456 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1457 // | various-length escape sequences | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1458 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1459 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1460 static const uint8_t iso2022_cstr_escapeSequence[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1461 0x1b, 0x40, 0x41, // 1b and 40 should not be removed (invalid esc seq) |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1462 0x1b, 0x50, 0x42, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1463 0x1b, 0x7f, 0x43, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1464 0x1b, 0x21, 0x4a, 0x44, // this will match |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1465 0x1b, 0x20, 0x21, 0x2f, 0x40, 0x45, // this will match |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1466 0x1b, 0x20, 0x21, 0x2f, 0x2f, 0x40, 0x46, // this will match too |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1467 0x1b, 0x20, 0x21, 0x2f, 0x1f, 0x47, 0x48, 0x00 // this will NOT match! |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1468 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1469 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1470 static const uint8_t iso2022_cstr_escapeSequence_ref[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1471 0x1b, 0x40, 0x41, // 1b and 40 should not be removed (invalid esc seq) |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1472 0x1b, 0x50, 0x42, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1473 0x1b, 0x7f, 0x43, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1474 0x44, // this will match |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1475 0x45, // this will match |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1476 0x46, // this will match too |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1477 0x1b, 0x20, 0x21, 0x2f, 0x1f, 0x47, 0x48, 0x00 // this will NOT match! |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1478 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1479 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1480 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1481 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1482 // | a real-world japanese sample | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1483 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1484 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1485 static const uint8_t iso2022_cstr_real_ir13[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1486 0xd4, 0xcf, 0xc0, 0xde, 0x5e, 0xc0, 0xdb, 0xb3, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1487 0x3d, 0x1b, 0x24, 0x42, 0x3b, 0x33, 0x45, 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1488 0x1b, 0x28, 0x4a, 0x5e, 0x1b, 0x24, 0x42, 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1489 0x40, 0x4f, 0x3a, 0x1b, 0x28, 0x4a, 0x3d, 0x1b, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1490 0x24, 0x42, 0x24, 0x64, 0x24, 0x5e, 0x24, 0x40, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1491 0x1b, 0x28, 0x4a, 0x5e, 0x1b, 0x24, 0x42, 0x24, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1492 0x3f, 0x24, 0x6d, 0x24, 0x26, 0x1b, 0x28, 0x4a, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1493 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1494 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1495 static const uint8_t iso2022_cstr_real_ir13_ref[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1496 0xd4, 0xcf, 0xc0, 0xde, 0x5e, 0xc0, 0xdb, 0xb3, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1497 0x3d, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1498 0x3b, 0x33, 0x45, 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1499 0x5e, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1500 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1501 0x40, 0x4f, 0x3a, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1502 0x3d, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1503 0x24, 0x64, 0x24, 0x5e, 0x24, 0x40, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1504 0x5e, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1505 0x24, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1506 0x3f, 0x24, 0x6d, 0x24, 0x26, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1507 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1508 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1509 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1510 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1511 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1512 // | the actual test | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1513 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1514 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1515 std::string iso2022_str_oneByteControl( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1516 reinterpret_cast<const char*>(iso2022_cstr_oneByteControl)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1517 std::string iso2022_str_oneByteControl_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1518 reinterpret_cast<const char*>(iso2022_cstr_oneByteControl_ref)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1519 std::string iso2022_str_twoByteControl( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1520 reinterpret_cast<const char*>(iso2022_cstr_twoByteControl)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1521 std::string iso2022_str_twoByteControl_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1522 reinterpret_cast<const char*>(iso2022_cstr_twoByteControl_ref)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1523 std::string iso2022_str_escapeSequence( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1524 reinterpret_cast<const char*>(iso2022_cstr_escapeSequence)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1525 std::string iso2022_str_escapeSequence_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1526 reinterpret_cast<const char*>(iso2022_cstr_escapeSequence_ref)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1527 std::string iso2022_str_real_ir13( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1528 reinterpret_cast<const char*>(iso2022_cstr_real_ir13)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1529 std::string iso2022_str_real_ir13_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1530 reinterpret_cast<const char*>(iso2022_cstr_real_ir13_ref)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1531 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1532 std::string dest; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1533 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1534 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_oneByteControl); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1535 ASSERT_EQ(dest, iso2022_str_oneByteControl_ref); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1536 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1537 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_twoByteControl); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1538 ASSERT_EQ(dest, iso2022_str_twoByteControl_ref); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1539 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1540 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_escapeSequence); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1541 ASSERT_EQ(dest, iso2022_str_escapeSequence_ref); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1542 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1543 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_real_ir13); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1544 ASSERT_EQ(dest, iso2022_str_real_ir13_ref); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1545 } |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1546 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1547 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1548 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1549 static std::string DecodeFromSpecification(const std::string& s) |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1550 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1551 std::vector<std::string> tokens; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1552 Toolbox::TokenizeString(tokens, s, ' '); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1553 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1554 std::string result; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1555 result.resize(tokens.size()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1556 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1557 for (size_t i = 0; i < tokens.size(); i++) |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1558 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1559 std::vector<std::string> components; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1560 Toolbox::TokenizeString(components, tokens[i], '/'); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1561 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1562 if (components.size() != 2) |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1563 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1564 throw; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1565 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1566 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1567 int a = boost::lexical_cast<int>(components[0]); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1568 int b = boost::lexical_cast<int>(components[1]); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1569 if (a < 0 || a > 15 || |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1570 b < 0 || b > 15 || |
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1571 (a == 0 && b == 0)) |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1572 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1573 throw; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1574 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1575 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1576 result[i] = static_cast<uint8_t>(a * 16 + b); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1577 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1578 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1579 return result; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1580 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1581 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1582 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1583 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1584 // Compatibility wrapper |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1585 static pugi::xpath_node SelectNode(const pugi::xml_document& doc, |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1586 const char* xpath) |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1587 { |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1588 #if PUGIXML_VERSION <= 140 |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1589 return doc.select_single_node(xpath); // Deprecated in pugixml 1.5 |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1590 #else |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1591 return doc.select_node(xpath); |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1592 #endif |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1593 } |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1594 |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1595 |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1596 TEST(Toolbox, EncodingsKorean) |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1597 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1598 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_I.2.html |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1599 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1600 std::string korean = DecodeFromSpecification( |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1601 "04/08 06/15 06/14 06/07 05/14 04/07 06/09 06/12 06/04 06/15 06/14 06/07 03/13 " |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1602 "01/11 02/04 02/09 04/03 15/11 15/03 05/14 01/11 02/04 02/09 04/03 13/01 12/14 " |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1603 "13/04 13/07 03/13 01/11 02/04 02/09 04/03 12/08 10/11 05/14 01/11 02/04 02/09 " |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1604 "04/03 11/01 14/06 11/05 11/15"); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1605 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1606 // This array can be re-generated using command-line: |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1607 // echo -n "Hong^Gildong=..." | hexdump -v -e '14/1 "0x%02x, "' -e '"\n"' |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1608 static const uint8_t utf8raw[] = { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1609 0x48, 0x6f, 0x6e, 0x67, 0x5e, 0x47, 0x69, 0x6c, 0x64, 0x6f, 0x6e, 0x67, 0x3d, 0xe6, |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1610 0xb4, 0xaa, 0x5e, 0xe5, 0x90, 0x89, 0xe6, 0xb4, 0x9e, 0x3d, 0xed, 0x99, 0x8d, 0x5e, |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1611 0xea, 0xb8, 0xb8, 0xeb, 0x8f, 0x99 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1612 }; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1613 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1614 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw)); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1615 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1616 ParsedDicomFile dicom(false); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1617 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 149"); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1618 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1619 (DCM_PatientName, korean.c_str(), OFBool(true)).good()); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1620 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1621 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1622 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1623 ASSERT_EQ(Encoding_Korean, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1624 ASSERT_TRUE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1625 |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1626 std::string value; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1627 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1628 ASSERT_EQ(utf8, value); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1629 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1630 DicomWebJsonVisitor visitor; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1631 dicom.Apply(visitor); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1632 ASSERT_EQ(utf8.substr(0, 12), visitor.GetResult()["00100010"]["Value"][0]["Alphabetic"].asString()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1633 ASSERT_EQ(utf8.substr(13, 10), visitor.GetResult()["00100010"]["Value"][0]["Ideographic"].asString()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1634 ASSERT_EQ(utf8.substr(24), visitor.GetResult()["00100010"]["Value"][0]["Phonetic"].asString()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1635 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1636 #if ORTHANC_ENABLE_PUGIXML == 1 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1637 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.3.html#table_F.3.1-1 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1638 std::string xml; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1639 visitor.FormatXml(xml); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1640 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1641 pugi::xml_document doc; |
3222 | 1642 doc.load_buffer(xml.c_str(), xml.size()); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1643 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1644 pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); |
3420
0a0e7eca95ae
fix encoding in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3342
diff
changeset
|
1645 ASSERT_STREQ("ISO 2022 IR 149", node.node().text().as_string()); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1646 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1647 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1648 ASSERT_STREQ("CS", node.node().attribute("vr").value()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1649 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1650 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1651 ASSERT_STREQ("PN", node.node().attribute("vr").value()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1652 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1653 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1654 ASSERT_STREQ("Hong", node.node().text().as_string()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1655 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1656 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1657 ASSERT_STREQ("Gildong", node.node().text().as_string()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1658 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1659 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1660 ASSERT_EQ(utf8.substr(13, 3), node.node().text().as_string()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1661 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1662 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1663 ASSERT_EQ(utf8.substr(17, 6), node.node().text().as_string()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1664 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1665 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1666 ASSERT_EQ(utf8.substr(24, 3), node.node().text().as_string()); |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1667 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1668 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1669 ASSERT_EQ(utf8.substr(28), node.node().text().as_string()); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1670 #endif |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1671 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1672 { |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1673 DicomMap m; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1674 m.FromDicomWeb(visitor.GetResult()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1675 ASSERT_EQ(2u, m.GetSize()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1676 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1677 std::string s; |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1678 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_SPECIFIC_CHARACTER_SET, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1679 ASSERT_EQ("ISO 2022 IR 149", s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1680 |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1681 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1682 std::vector<std::string> v; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1683 Toolbox::TokenizeString(v, s, '='); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1684 ASSERT_EQ(3u, v.size()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1685 ASSERT_EQ("Hong^Gildong", v[0]); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1686 ASSERT_EQ(utf8, s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1687 } |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1688 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1689 |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1690 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1691 TEST(Toolbox, EncodingsJapaneseKanji) |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1692 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1693 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_H.3.html |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1694 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1695 std::string japanese = DecodeFromSpecification( |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1696 "05/09 06/01 06/13 06/01 06/04 06/01 05/14 05/04 06/01 07/02 06/15 07/05 03/13 " |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1697 "01/11 02/04 04/02 03/11 03/03 04/05 04/04 01/11 02/08 04/02 05/14 01/11 02/04 " |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1698 "04/02 04/02 04/00 04/15 03/10 01/11 02/08 04/02 03/13 01/11 02/04 04/02 02/04 " |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1699 "06/04 02/04 05/14 02/04 04/00 01/11 02/08 04/02 05/14 01/11 02/04 04/02 02/04 " |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1700 "03/15 02/04 06/13 02/04 02/06 01/11 02/08 04/02"); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1701 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1702 // This array can be re-generated using command-line: |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1703 // echo -n "Yamada^Tarou=..." | hexdump -v -e '14/1 "0x%02x, "' -e '"\n"' |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1704 static const uint8_t utf8raw[] = { |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1705 0x59, 0x61, 0x6d, 0x61, 0x64, 0x61, 0x5e, 0x54, 0x61, 0x72, 0x6f, 0x75, 0x3d, 0xe5, |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1706 0xb1, 0xb1, 0xe7, 0x94, 0xb0, 0x5e, 0xe5, 0xa4, 0xaa, 0xe9, 0x83, 0x8e, 0x3d, 0xe3, |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1707 0x82, 0x84, 0xe3, 0x81, 0xbe, 0xe3, 0x81, 0xa0, 0x5e, 0xe3, 0x81, 0x9f, 0xe3, 0x82, |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1708 0x8d, 0xe3, 0x81, 0x86 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1709 }; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1710 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1711 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw)); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1712 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1713 ParsedDicomFile dicom(false); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1714 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 87"); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1715 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1716 (DCM_PatientName, japanese.c_str(), OFBool(true)).good()); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1717 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1718 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1719 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1720 ASSERT_EQ(Encoding_JapaneseKanji, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1721 ASSERT_TRUE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1722 |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1723 std::string value; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1724 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1725 ASSERT_EQ(utf8, value); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1726 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1727 DicomWebJsonVisitor visitor; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1728 dicom.Apply(visitor); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1729 ASSERT_EQ(utf8.substr(0, 12), visitor.GetResult()["00100010"]["Value"][0]["Alphabetic"].asString()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1730 ASSERT_EQ(utf8.substr(13, 13), visitor.GetResult()["00100010"]["Value"][0]["Ideographic"].asString()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1731 ASSERT_EQ(utf8.substr(27), visitor.GetResult()["00100010"]["Value"][0]["Phonetic"].asString()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1732 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1733 #if ORTHANC_ENABLE_PUGIXML == 1 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1734 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.3.html#table_F.3.1-1 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1735 std::string xml; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1736 visitor.FormatXml(xml); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1737 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1738 pugi::xml_document doc; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1739 doc.load_buffer(xml.c_str(), xml.size()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1740 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1741 pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); |
3420
0a0e7eca95ae
fix encoding in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3342
diff
changeset
|
1742 ASSERT_STREQ("ISO 2022 IR 87", node.node().text().as_string()); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1743 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1744 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1745 ASSERT_STREQ("CS", node.node().attribute("vr").value()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1746 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1747 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1748 ASSERT_STREQ("PN", node.node().attribute("vr").value()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1749 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1750 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1751 ASSERT_STREQ("Yamada", node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1752 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1753 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1754 ASSERT_STREQ("Tarou", node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1755 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1756 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1757 ASSERT_EQ(utf8.substr(13, 6), node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1758 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1759 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1760 ASSERT_EQ(utf8.substr(20, 6), node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1761 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1762 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1763 ASSERT_EQ(utf8.substr(27, 9), node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1764 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1765 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1766 ASSERT_EQ(utf8.substr(37), node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1767 #endif |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1768 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1769 { |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1770 DicomMap m; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1771 m.FromDicomWeb(visitor.GetResult()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1772 ASSERT_EQ(2u, m.GetSize()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1773 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1774 std::string s; |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1775 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_SPECIFIC_CHARACTER_SET, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1776 ASSERT_EQ("ISO 2022 IR 87", s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1777 |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1778 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1779 std::vector<std::string> v; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1780 Toolbox::TokenizeString(v, s, '='); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1781 ASSERT_EQ(3u, v.size()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1782 ASSERT_EQ("Yamada^Tarou", v[0]); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1783 ASSERT_EQ(utf8, s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1784 } |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1785 } |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1786 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1787 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1788 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1789 TEST(Toolbox, EncodingsChinese3) |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1790 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1791 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_J.3.html |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1792 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1793 static const uint8_t chinese[] = { |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1794 0x57, 0x61, 0x6e, 0x67, 0x5e, 0x58, 0x69, 0x61, 0x6f, 0x44, 0x6f, |
3229 | 1795 0x6e, 0x67, 0x3d, 0xcd, 0xf5, 0x5e, 0xd0, 0xa1, 0xb6, 0xab, 0x3d, 0x00 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1796 }; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1797 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1798 ParsedDicomFile dicom(false); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1799 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1800 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1801 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good()); |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1802 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1803 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1804 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1805 ASSERT_EQ(Encoding_Chinese, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1806 ASSERT_FALSE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1807 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1808 std::string value; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1809 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1810 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1811 std::vector<std::string> tokens; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1812 Orthanc::Toolbox::TokenizeString(tokens, value, '='); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1813 ASSERT_EQ(3u, tokens.size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1814 ASSERT_EQ("Wang^XiaoDong", tokens[0]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1815 ASSERT_TRUE(tokens[2].empty()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1816 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1817 std::vector<std::string> middle; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1818 Orthanc::Toolbox::TokenizeString(middle, tokens[1], '^'); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1819 ASSERT_EQ(2u, middle.size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1820 ASSERT_EQ(3u, middle[0].size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1821 ASSERT_EQ(6u, middle[1].size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1822 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1823 // CDF5 in GB18030 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1824 ASSERT_EQ(static_cast<char>(0xe7), middle[0][0]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1825 ASSERT_EQ(static_cast<char>(0x8e), middle[0][1]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1826 ASSERT_EQ(static_cast<char>(0x8b), middle[0][2]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1827 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1828 // D0A1 in GB18030 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1829 ASSERT_EQ(static_cast<char>(0xe5), middle[1][0]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1830 ASSERT_EQ(static_cast<char>(0xb0), middle[1][1]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1831 ASSERT_EQ(static_cast<char>(0x8f), middle[1][2]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1832 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1833 // B6AB in GB18030 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1834 ASSERT_EQ(static_cast<char>(0xe4), middle[1][3]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1835 ASSERT_EQ(static_cast<char>(0xb8), middle[1][4]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1836 ASSERT_EQ(static_cast<char>(0x9c), middle[1][5]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1837 } |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1838 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1839 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1840 TEST(Toolbox, EncodingsChinese4) |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1841 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1842 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_J.4.html |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1843 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1844 static const uint8_t chinese[] = { |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1845 0x54, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x6c, 0x69, 0x6e, |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1846 0x65, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x73, 0xd6, 0xd0, 0xce, |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1847 0xc4, 0x2e, 0x0d, 0x0a, 0x54, 0x68, 0x65, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1848 0x64, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1849 0x65, 0x73, 0xd6, 0xd0, 0xce, 0xc4, 0x2c, 0x20, 0x74, 0x6f, 0x6f, 0x2e, 0x0d, |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1850 0x0a, 0x54, 0x68, 0x65, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x20, 0x6c, 0x69, |
3229 | 1851 0x6e, 0x65, 0x2e, 0x0d, 0x0a, 0x00 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1852 }; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1853 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1854 static const uint8_t patternRaw[] = { |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1855 0xe4, 0xb8, 0xad, 0xe6, 0x96, 0x87 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1856 }; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1857 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1858 const std::string pattern(reinterpret_cast<const char*>(patternRaw), sizeof(patternRaw)); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1859 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1860 ParsedDicomFile dicom(false); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1861 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1862 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1863 (DCM_PatientComments, reinterpret_cast<const char*>(chinese), OFBool(true)).good()); |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1864 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1865 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1866 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1867 ASSERT_EQ(Encoding_Chinese, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1868 ASSERT_FALSE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1869 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1870 std::string value; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1871 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_COMMENTS)); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1872 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1873 std::vector<std::string> lines; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1874 Orthanc::Toolbox::TokenizeString(lines, value, '\n'); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1875 ASSERT_EQ(4u, lines.size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1876 ASSERT_TRUE(boost::starts_with(lines[0], "The first line includes")); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1877 ASSERT_TRUE(boost::ends_with(lines[0], ".\r")); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1878 ASSERT_TRUE(lines[0].find(pattern) != std::string::npos); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1879 ASSERT_TRUE(boost::starts_with(lines[1], "The second line includes")); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1880 ASSERT_TRUE(boost::ends_with(lines[1], ", too.\r")); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1881 ASSERT_TRUE(lines[1].find(pattern) != std::string::npos); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1882 ASSERT_EQ("The third line.\r", lines[2]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1883 ASSERT_FALSE(lines[1].find(pattern) == std::string::npos); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1884 ASSERT_TRUE(lines[3].empty()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1885 } |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1886 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1887 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1888 TEST(Toolbox, EncodingsSimplifiedChinese2) |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1889 { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1890 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_K.2.html |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1891 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1892 static const uint8_t chinese[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1893 0x5a, 0x68, 0x61, 0x6e, 0x67, 0x5e, 0x58, 0x69, 0x61, 0x6f, 0x44, 0x6f, |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1894 0x6e, 0x67, 0x3d, 0x1b, 0x24, 0x29, 0x41, 0xd5, 0xc5, 0x5e, 0x1b, 0x24, |
3229 | 1895 0x29, 0x41, 0xd0, 0xa1, 0xb6, 0xab, 0x3d, 0x20, 0x00 |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1896 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1897 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1898 // echo -n "Zhang^XiaoDong=..." | hexdump -v -e '14/1 "0x%02x, "' -e '"\n"' |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1899 static const uint8_t utf8[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1900 0x5a, 0x68, 0x61, 0x6e, 0x67, 0x5e, 0x58, 0x69, 0x61, 0x6f, 0x44, 0x6f, 0x6e, 0x67, |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1901 0x3d, 0xe5, 0xbc, 0xa0, 0x5e, 0xe5, 0xb0, 0x8f, 0xe4, 0xb8, 0x9c, 0x3d |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1902 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1903 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1904 ParsedDicomFile dicom(false); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1905 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58"); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1906 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1907 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good()); |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1908 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1909 bool hasCodeExtensions; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1910 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1911 ASSERT_EQ(Encoding_SimplifiedChinese, encoding); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1912 ASSERT_TRUE(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1913 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1914 std::string value; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1915 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1916 ASSERT_EQ(value, std::string(reinterpret_cast<const char*>(utf8), sizeof(utf8))); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1917 } |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1918 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1919 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1920 TEST(Toolbox, EncodingsSimplifiedChinese3) |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1921 { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1922 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_K.2.html |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1923 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1924 static const uint8_t chinese[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1925 0x31, 0x2e, 0x1b, 0x24, 0x29, 0x41, 0xb5, 0xda, 0xd2, 0xbb, 0xd0, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xa1, 0xa3, 0x0d, 0x0a, |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1926 0x32, 0x2e, 0x1b, 0x24, 0x29, 0x41, 0xb5, 0xda, 0xb6, 0xfe, 0xd0, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xa1, 0xa3, 0x0d, 0x0a, |
3229 | 1927 0x33, 0x2e, 0x1b, 0x24, 0x29, 0x41, 0xb5, 0xda, 0xc8, 0xfd, 0xd0, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xa1, 0xa3, 0x0d, 0x0a, 0x00 |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1928 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1929 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1930 static const uint8_t line1[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1931 0x31, 0x2e, 0xe7, 0xac, 0xac, 0xe4, 0xb8, 0x80, 0xe8, 0xa1, 0x8c, 0xe6, 0x96, 0x87, |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1932 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r' |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1933 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1934 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1935 static const uint8_t line2[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1936 0x32, 0x2e, 0xe7, 0xac, 0xac, 0xe4, 0xba, 0x8c, 0xe8, 0xa1, 0x8c, 0xe6, 0x96, 0x87, |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1937 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r' |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1938 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1939 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1940 static const uint8_t line3[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1941 0x33, 0x2e, 0xe7, 0xac, 0xac, 0xe4, 0xb8, 0x89, 0xe8, 0xa1, 0x8c, 0xe6, 0x96, 0x87, |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1942 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r' |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1943 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1944 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1945 ParsedDicomFile dicom(false); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1946 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58"); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1947 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1948 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good()); |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1949 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1950 bool hasCodeExtensions; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1951 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1952 ASSERT_EQ(Encoding_SimplifiedChinese, encoding); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1953 ASSERT_TRUE(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1954 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1955 std::string value; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1956 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1957 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1958 std::vector<std::string> lines; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1959 Toolbox::TokenizeString(lines, value, '\n'); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1960 ASSERT_EQ(4u, lines.size()); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1961 ASSERT_EQ(std::string(reinterpret_cast<const char*>(line1), sizeof(line1)), lines[0]); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1962 ASSERT_EQ(std::string(reinterpret_cast<const char*>(line2), sizeof(line2)), lines[1]); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1963 ASSERT_EQ(std::string(reinterpret_cast<const char*>(line3), sizeof(line3)), lines[2]); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1964 ASSERT_TRUE(lines[3].empty()); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1965 } |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1966 |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
1967 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1968 static void SetTagKey(ParsedDicomFile& dicom, |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1969 const DicomTag& tag, |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1970 const DicomTag& value) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1971 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1972 // This function emulates a call to function |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1973 // "dicom.GetDcmtkObject().getDataset()->putAndInsertTagKey(tag, |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1974 // value)" that was not available in DCMTK 3.6.0 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1975 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1976 std::unique_ptr<DcmAttributeTag> element(new DcmAttributeTag(ToDcmtkBridge::Convert(tag))); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1977 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1978 DcmTagKey v = ToDcmtkBridge::Convert(value); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1979 if (!element->putTagVal(v).good()) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1980 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1981 throw OrthancException(ErrorCode_InternalError); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1982 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1983 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1984 dicom.GetDcmtkObject().getDataset()->insert(element.release()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1985 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1986 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1987 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1988 TEST(DicomWebJson, ValueRepresentation) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1989 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1990 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.3.html |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1991 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1992 ParsedDicomFile dicom(false); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1993 dicom.ReplacePlainString(DicomTag(0x0040, 0x0241), "AE"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1994 dicom.ReplacePlainString(DicomTag(0x0010, 0x1010), "AS"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1995 SetTagKey(dicom, DicomTag(0x0020, 0x9165), DicomTag(0x0010, 0x0020)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1996 dicom.ReplacePlainString(DicomTag(0x0008, 0x0052), "CS"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1997 dicom.ReplacePlainString(DicomTag(0x0008, 0x0012), "DA"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1998 dicom.ReplacePlainString(DicomTag(0x0010, 0x1020), "42"); // DS |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1999 dicom.ReplacePlainString(DicomTag(0x0008, 0x002a), "DT"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2000 dicom.ReplacePlainString(DicomTag(0x0010, 0x9431), "43"); // FL |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2001 dicom.ReplacePlainString(DicomTag(0x0008, 0x1163), "44"); // FD |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2002 dicom.ReplacePlainString(DicomTag(0x0008, 0x1160), "45"); // IS |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2003 dicom.ReplacePlainString(DicomTag(0x0008, 0x0070), "LO"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2004 dicom.ReplacePlainString(DicomTag(0x0010, 0x4000), "LT"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2005 dicom.ReplacePlainString(DicomTag(0x0028, 0x2000), "OB"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2006 dicom.ReplacePlainString(DicomTag(0x7fe0, 0x0009), "3.14159"); // OD (other double) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2007 dicom.ReplacePlainString(DicomTag(0x0064, 0x0009), "2.71828"); // OF (other float) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2008 dicom.ReplacePlainString(DicomTag(0x0066, 0x0040), "46"); // OL (other long) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2009 ASSERT_THROW(dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "O"), OrthancException); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2010 dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "OWOW"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2011 dicom.ReplacePlainString(DicomTag(0x0010, 0x0010), "PN"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2012 dicom.ReplacePlainString(DicomTag(0x0008, 0x0050), "SH"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2013 dicom.ReplacePlainString(DicomTag(0x0018, 0x6020), "-15"); // SL |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2014 dicom.ReplacePlainString(DicomTag(0x0018, 0x9219), "-16"); // SS |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2015 dicom.ReplacePlainString(DicomTag(0x0008, 0x0081), "ST"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2016 dicom.ReplacePlainString(DicomTag(0x0008, 0x0013), "TM"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2017 dicom.ReplacePlainString(DicomTag(0x0008, 0x0119), "UC"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2018 dicom.ReplacePlainString(DicomTag(0x0008, 0x0016), "UI"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2019 dicom.ReplacePlainString(DicomTag(0x0008, 0x1161), "128"); // UL |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2020 dicom.ReplacePlainString(DicomTag(0x4342, 0x1234), "UN"); // Inexistent tag |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2021 dicom.ReplacePlainString(DicomTag(0x0008, 0x0120), "UR"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2022 dicom.ReplacePlainString(DicomTag(0x0008, 0x0301), "17"); // US |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2023 dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2024 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2025 DicomWebJsonVisitor visitor; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2026 dicom.Apply(visitor); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2027 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2028 std::string s; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2029 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2030 // The tag (0002,0002) is "Media Storage SOP Class UID" and is |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2031 // automatically copied by DCMTK from tag (0008,0016) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2032 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2033 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2034 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2035 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2036 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2037 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2038 ASSERT_EQ("AT", visitor.GetResult() ["00209165"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2039 ASSERT_EQ("00100020", visitor.GetResult() ["00209165"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2040 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2041 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2042 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2043 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2044 ASSERT_EQ("DS", visitor.GetResult() ["00101020"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2045 ASSERT_FLOAT_EQ(42.0f, visitor.GetResult() ["00101020"]["Value"][0].asFloat()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2046 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2047 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2048 ASSERT_EQ("FL", visitor.GetResult() ["00109431"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2049 ASSERT_FLOAT_EQ(43.0f, visitor.GetResult() ["00109431"]["Value"][0].asFloat()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2050 ASSERT_EQ("FD", visitor.GetResult() ["00081163"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2051 ASSERT_FLOAT_EQ(44.0f, visitor.GetResult() ["00081163"]["Value"][0].asFloat()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2052 ASSERT_EQ("IS", visitor.GetResult() ["00081160"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2053 ASSERT_FLOAT_EQ(45.0f, visitor.GetResult() ["00081160"]["Value"][0].asFloat()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2054 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2055 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2056 ASSERT_EQ("LT", visitor.GetResult() ["00104000"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2057 ASSERT_EQ("LT", visitor.GetResult() ["00104000"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2058 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2059 ASSERT_EQ("OB", visitor.GetResult() ["00282000"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2060 Toolbox::DecodeBase64(s, visitor.GetResult() ["00282000"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2061 ASSERT_EQ("OB", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2062 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2063 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2064 ASSERT_EQ("OD", visitor.GetResult() ["7FE00009"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2065 ASSERT_FLOAT_EQ(3.14159f, boost::lexical_cast<float>(visitor.GetResult() ["7FE00009"]["Value"][0].asString())); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2066 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2067 ASSERT_EQ("UN", visitor.GetResult() ["7FE00009"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2068 Toolbox::DecodeBase64(s, visitor.GetResult() ["7FE00009"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2069 ASSERT_EQ(8u, s.size()); // Because of padding |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2070 ASSERT_EQ(0, s[7]); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2071 ASSERT_EQ("3.14159", s.substr(0, 7)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2072 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2073 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2074 ASSERT_EQ("OF", visitor.GetResult() ["00640009"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2075 ASSERT_FLOAT_EQ(2.71828f, boost::lexical_cast<float>(visitor.GetResult() ["00640009"]["Value"][0].asString())); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2076 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2077 #if DCMTK_VERSION_NUMBER < 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2078 ASSERT_EQ("UN", visitor.GetResult() ["00660040"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2079 Toolbox::DecodeBase64(s, visitor.GetResult() ["00660040"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2080 ASSERT_EQ("46", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2081 #elif DCMTK_VERSION_NUMBER == 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2082 ASSERT_EQ("UL", visitor.GetResult() ["00660040"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2083 ASSERT_EQ(46, visitor.GetResult() ["00660040"]["Value"][0].asInt()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2084 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2085 ASSERT_EQ("OL", visitor.GetResult() ["00660040"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2086 ASSERT_EQ(46, visitor.GetResult() ["00660040"]["Value"][0].asInt()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2087 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2088 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2089 ASSERT_EQ("OW", visitor.GetResult() ["00281201"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2090 Toolbox::DecodeBase64(s, visitor.GetResult() ["00281201"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2091 ASSERT_EQ("OWOW", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2092 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2093 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2094 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["Value"][0]["Alphabetic"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2095 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2096 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2097 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2098 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2099 ASSERT_EQ("SL", visitor.GetResult() ["00186020"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2100 ASSERT_EQ(-15, visitor.GetResult() ["00186020"]["Value"][0].asInt()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2101 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2102 ASSERT_EQ("SS", visitor.GetResult() ["00189219"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2103 ASSERT_EQ(-16, visitor.GetResult() ["00189219"]["Value"][0].asInt()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2104 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2105 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2106 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2107 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2108 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2109 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2110 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2111 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2112 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2113 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2114 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2115 ASSERT_EQ("UN", visitor.GetResult() ["00080119"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2116 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080119"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2117 ASSERT_EQ("UC", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2118 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2119 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2120 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2121 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2122 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2123 ASSERT_EQ("UL", visitor.GetResult() ["00081161"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2124 ASSERT_EQ(128u, visitor.GetResult() ["00081161"]["Value"][0].asUInt()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2125 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2126 ASSERT_EQ("UN", visitor.GetResult() ["43421234"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2127 Toolbox::DecodeBase64(s, visitor.GetResult() ["43421234"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2128 ASSERT_EQ("UN", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2129 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2130 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2131 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2132 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2133 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2134 ASSERT_EQ("UN", visitor.GetResult() ["00080120"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2135 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080120"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2136 ASSERT_EQ("UR", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2137 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2138 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2139 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2140 ASSERT_EQ("US", visitor.GetResult() ["00080301"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2141 ASSERT_EQ(17u, visitor.GetResult() ["00080301"]["Value"][0].asUInt()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2142 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2143 ASSERT_EQ("UN", visitor.GetResult() ["00080301"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2144 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080301"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2145 ASSERT_EQ("17", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2146 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2147 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2148 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2149 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2150 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2151 std::string xml; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2152 visitor.FormatXml(xml); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2153 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2154 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2155 DicomMap m; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2156 m.FromDicomWeb(visitor.GetResult()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2157 ASSERT_EQ(31u, m.GetSize()); |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2158 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2159 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0002, 0x0002), false)); ASSERT_EQ("UI", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2160 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0040, 0x0241), false)); ASSERT_EQ("AE", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2161 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x1010), false)); ASSERT_EQ("AS", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2162 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0020, 0x9165), false)); ASSERT_EQ("00100020", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2163 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0052), false)); ASSERT_EQ("CS", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2164 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0012), false)); ASSERT_EQ("DA", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2165 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x1020), false)); ASSERT_EQ("42", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2166 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x002a), false)); ASSERT_EQ("DT", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2167 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x9431), false)); ASSERT_EQ("43", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2168 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1163), false)); ASSERT_EQ("44", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2169 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1160), false)); ASSERT_EQ("45", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2170 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0070), false)); ASSERT_EQ("LO", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2171 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x4000), false)); ASSERT_EQ("LT", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2172 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0028, 0x2000), true)); ASSERT_EQ("OB", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2173 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7fe0, 0x0009), true)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2174 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2175 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2176 ASSERT_FLOAT_EQ(3.14159f, boost::lexical_cast<float>(s)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2177 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2178 ASSERT_EQ(8u, s.size()); // Because of padding |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2179 ASSERT_EQ(0, s[7]); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2180 ASSERT_EQ("3.14159", s.substr(0, 7)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2181 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2182 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2183 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0064, 0x0009), true)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2184 ASSERT_FLOAT_EQ(2.71828f, boost::lexical_cast<float>(s)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2185 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0028, 0x1201), true)); ASSERT_EQ("OWOW", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2186 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x0010), false)); ASSERT_EQ("PN", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2187 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0050), false)); ASSERT_EQ("SH", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2188 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0018, 0x6020), false)); ASSERT_EQ("-15", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2189 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0018, 0x9219), false)); ASSERT_EQ("-16", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2190 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0081), false)); ASSERT_EQ("ST", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2191 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0013), false)); ASSERT_EQ("TM", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2192 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0016), false)); ASSERT_EQ("UI", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2193 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1161), false)); ASSERT_EQ("128", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2194 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x4342, 0x1234), true)); ASSERT_EQ("UN", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2195 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0040, 0x0031), false)); ASSERT_EQ("UT", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2196 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2197 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2198 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0066, 0x0040), false)); ASSERT_EQ("46", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2199 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0119), false)); ASSERT_EQ("UC", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2200 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0120), false)); ASSERT_EQ("UR", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2201 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0301), false)); ASSERT_EQ("17", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2202 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2203 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0066, 0x0040), true)); ASSERT_EQ("46", s); // OL |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2204 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0119), true)); ASSERT_EQ("UC", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2205 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0120), true)); ASSERT_EQ("UR", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2206 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0301), true)); ASSERT_EQ("17", s); // US (but tag unknown to DCMTK 3.6.0) |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2207 #endif |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2208 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2209 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2210 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2211 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2212 TEST(DicomWebJson, Sequence) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2213 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2214 ParsedDicomFile dicom(false); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2215 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2216 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2217 std::unique_ptr<DcmSequenceOfItems> sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2218 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2219 for (unsigned int i = 0; i < 3; i++) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2220 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2221 std::unique_ptr<DcmItem> item(new DcmItem); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2222 std::string s = "item" + boost::lexical_cast<std::string>(i); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2223 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, s.c_str(), OFFalse); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2224 ASSERT_TRUE(sequence->insert(item.release(), false, false).good()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2225 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2226 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2227 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->insert(sequence.release(), false, false).good()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2228 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2229 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2230 DicomWebJsonVisitor visitor; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2231 dicom.Apply(visitor); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2232 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2233 ASSERT_EQ("SQ", visitor.GetResult() ["00081115"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2234 ASSERT_EQ(3u, visitor.GetResult() ["00081115"]["Value"].size()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2235 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2236 std::set<std::string> items; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2237 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2238 for (Json::Value::ArrayIndex i = 0; i < 3; i++) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2239 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2240 ASSERT_EQ(1u, visitor.GetResult() ["00081115"]["Value"][i].size()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2241 ASSERT_EQ(1u, visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["Value"].size()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2242 ASSERT_EQ("UI", visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2243 items.insert(visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["Value"][0].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2244 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2245 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2246 ASSERT_EQ(3u, items.size()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2247 ASSERT_TRUE(items.find("item0") != items.end()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2248 ASSERT_TRUE(items.find("item1") != items.end()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2249 ASSERT_TRUE(items.find("item2") != items.end()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2250 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2251 std::string xml; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2252 visitor.FormatXml(xml); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2253 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2254 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2255 DicomMap m; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2256 m.FromDicomWeb(visitor.GetResult()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2257 ASSERT_EQ(0u, m.GetSize()); // Sequences are not handled by DicomMap |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2258 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2259 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2260 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2261 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2262 TEST(ParsedDicomCache, Basic) |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2263 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2264 ParsedDicomCache cache(10); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2265 ASSERT_EQ(0u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2266 ASSERT_EQ(0u, cache.GetNumberOfItems()); |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2267 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2268 DicomMap tags; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2269 tags.SetValue(DICOM_TAG_PATIENT_ID, "patient1", false); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2270 cache.Acquire("a", new ParsedDicomFile(tags, Encoding_Latin1, true), 20); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2271 ASSERT_EQ(20u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2272 ASSERT_EQ(1u, cache.GetNumberOfItems()); |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2273 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2274 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2275 ParsedDicomCache::Accessor accessor(cache, "b"); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2276 ASSERT_FALSE(accessor.IsValid()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2277 ASSERT_THROW(accessor.GetDicom(), OrthancException); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2278 ASSERT_THROW(accessor.GetFileSize(), OrthancException); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2279 } |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2280 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2281 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2282 ParsedDicomCache::Accessor accessor(cache, "a"); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2283 ASSERT_TRUE(accessor.IsValid()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2284 std::string s; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2285 ASSERT_TRUE(accessor.GetDicom().GetTagValue(s, DICOM_TAG_PATIENT_ID)); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2286 ASSERT_EQ("patient1", s); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2287 ASSERT_EQ(20u, accessor.GetFileSize()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2288 } |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2289 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2290 tags.SetValue(DICOM_TAG_PATIENT_ID, "patient2", false); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2291 cache.Acquire("b", new ParsedDicomFile(tags, Encoding_Latin1, true), 5); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2292 ASSERT_EQ(5u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2293 ASSERT_EQ(1u, cache.GetNumberOfItems()); |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2294 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2295 cache.Acquire("c", new ParsedDicomFile(true), 5); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2296 ASSERT_EQ(10u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2297 ASSERT_EQ(2u, cache.GetNumberOfItems()); |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2298 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2299 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2300 ParsedDicomCache::Accessor accessor(cache, "b"); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2301 ASSERT_TRUE(accessor.IsValid()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2302 std::string s; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2303 ASSERT_TRUE(accessor.GetDicom().GetTagValue(s, DICOM_TAG_PATIENT_ID)); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2304 ASSERT_EQ("patient2", s); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2305 ASSERT_EQ(5u, accessor.GetFileSize()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2306 } |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2307 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2308 cache.Acquire("d", new ParsedDicomFile(true), 5); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2309 ASSERT_EQ(10u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2310 ASSERT_EQ(2u, cache.GetNumberOfItems()); |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2311 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2312 ASSERT_TRUE(ParsedDicomCache::Accessor(cache, "b").IsValid()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2313 ASSERT_FALSE(ParsedDicomCache::Accessor(cache, "c").IsValid()); // recycled by LRU |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2314 ASSERT_TRUE(ParsedDicomCache::Accessor(cache, "d").IsValid()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2315 |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2316 cache.Invalidate("d"); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2317 ASSERT_EQ(5u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2318 ASSERT_EQ(1u, cache.GetNumberOfItems()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2319 ASSERT_TRUE(ParsedDicomCache::Accessor(cache, "b").IsValid()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2320 ASSERT_FALSE(ParsedDicomCache::Accessor(cache, "d").IsValid()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2321 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2322 cache.Acquire("e", new ParsedDicomFile(true), 15); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2323 ASSERT_EQ(15u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2324 ASSERT_EQ(1u, cache.GetNumberOfItems()); |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2325 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2326 ASSERT_FALSE(ParsedDicomCache::Accessor(cache, "c").IsValid()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2327 ASSERT_FALSE(ParsedDicomCache::Accessor(cache, "d").IsValid()); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2328 ASSERT_TRUE(ParsedDicomCache::Accessor(cache, "e").IsValid()); |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2329 |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2330 cache.Invalidate("e"); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2331 ASSERT_EQ(0u, cache.GetCurrentSize()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2332 ASSERT_EQ(0u, cache.GetNumberOfItems()); |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
2333 ASSERT_FALSE(ParsedDicomCache::Accessor(cache, "e").IsValid()); |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2334 } |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2335 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
2336 |
4735
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2337 static bool MyIsMatch(const DicomPath& a, |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2338 const DicomPath& b) |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2339 { |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2340 bool expected = DicomPath::IsMatch(a, b); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2341 |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2342 std::vector<DicomTag> prefixTags; |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2343 std::vector<size_t> prefixIndexes; |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2344 |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2345 for (size_t i = 0; i < b.GetPrefixLength(); i++) |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2346 { |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2347 prefixTags.push_back(b.GetPrefixTag(i)); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2348 prefixIndexes.push_back(b.GetPrefixIndex(i)); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2349 } |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2350 |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2351 if (expected == DicomPath::IsMatch(a, prefixTags, prefixIndexes, b.GetFinalTag())) |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2352 { |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2353 return expected; |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2354 } |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2355 else |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2356 { |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2357 throw OrthancException(ErrorCode_InternalError); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2358 } |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2359 } |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2360 |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2361 |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2362 TEST(DicomModification, DicomPath) |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2363 { |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2364 // Those are samples inspired by those from "man dcmodify" |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2365 |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2366 static const DicomTag DICOM_TAG_ACQUISITION_MATRIX(0x0018, 0x1310); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2367 static const DicomTag DICOM_TAG_REFERENCED_PERFORMED_PROCEDURE_STEP_SEQUENCE(0x0008, 0x1111); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2368 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2369 DicomPath path = DicomPath::Parse("(0010,0010)"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2370 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2371 ASSERT_EQ(0u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2372 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2373 ASSERT_THROW(path.GetPrefixTag(0), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2374 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2375 path = DicomPath::Parse("0018,1310"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2376 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2377 ASSERT_EQ(0u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2378 ASSERT_EQ(DICOM_TAG_ACQUISITION_MATRIX, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2379 ASSERT_EQ("(0018,1310)", path.Format()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2380 |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2381 // The following sample won't work without DCMTK |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2382 path = DicomPath::Parse("PatientID"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2383 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2384 ASSERT_EQ(0u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2385 ASSERT_EQ(DICOM_TAG_PATIENT_ID, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2386 ASSERT_EQ("(0010,0020)", path.Format()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2387 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2388 path = DicomPath::Parse("(0018,1310)"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2389 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2390 ASSERT_EQ(0u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2391 ASSERT_EQ(DICOM_TAG_ACQUISITION_MATRIX, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2392 ASSERT_EQ("(0018,1310)", path.Format()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2393 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2394 path = DicomPath::Parse("(0008,1111)[0].PatientName"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2395 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2396 ASSERT_EQ(1u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2397 ASSERT_EQ(DICOM_TAG_REFERENCED_PERFORMED_PROCEDURE_STEP_SEQUENCE, path.GetPrefixTag(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2398 ASSERT_FALSE(path.IsPrefixUniversal(0)); |
4700
863383e7e582
fix warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
2399 ASSERT_EQ(0u, path.GetPrefixIndex(0)); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2400 ASSERT_THROW(path.GetPrefixTag(1), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2401 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2402 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2403 path = DicomPath::Parse("(0008,1111)[1].(0008,1111)[2].(0010,0010)"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2404 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2405 ASSERT_EQ(2u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2406 ASSERT_EQ(DICOM_TAG_REFERENCED_PERFORMED_PROCEDURE_STEP_SEQUENCE, path.GetPrefixTag(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2407 ASSERT_FALSE(path.IsPrefixUniversal(0)); |
4700
863383e7e582
fix warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
2408 ASSERT_EQ(1u, path.GetPrefixIndex(0)); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2409 ASSERT_EQ(DICOM_TAG_REFERENCED_PERFORMED_PROCEDURE_STEP_SEQUENCE, path.GetPrefixTag(1)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2410 ASSERT_FALSE(path.IsPrefixUniversal(1)); |
4700
863383e7e582
fix warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
2411 ASSERT_EQ(2u, path.GetPrefixIndex(1)); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2412 ASSERT_THROW(path.GetPrefixTag(2), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2413 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2414 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2415 path = DicomPath::Parse("(0008,1111)[*].PatientName"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2416 ASSERT_TRUE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2417 ASSERT_EQ(1u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2418 ASSERT_EQ(DICOM_TAG_REFERENCED_PERFORMED_PROCEDURE_STEP_SEQUENCE, path.GetPrefixTag(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2419 ASSERT_TRUE(path.IsPrefixUniversal(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2420 ASSERT_THROW(path.GetPrefixIndex(0), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2421 ASSERT_THROW(path.GetPrefixTag(1), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2422 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2423 ASSERT_EQ("(0008,1111)[*].(0010,0010)", path.Format()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2424 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2425 path = DicomPath::Parse("(0008,1111)[1].(0008,1111)[*].(0010,0010)"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2426 ASSERT_TRUE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2427 ASSERT_EQ(2u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2428 ASSERT_EQ(DICOM_TAG_REFERENCED_PERFORMED_PROCEDURE_STEP_SEQUENCE, path.GetPrefixTag(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2429 ASSERT_FALSE(path.IsPrefixUniversal(0)); |
4700
863383e7e582
fix warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
2430 ASSERT_EQ(1u, path.GetPrefixIndex(0)); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2431 ASSERT_EQ(DICOM_TAG_REFERENCED_PERFORMED_PROCEDURE_STEP_SEQUENCE, path.GetPrefixTag(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2432 ASSERT_TRUE(path.IsPrefixUniversal(1)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2433 ASSERT_THROW(path.GetPrefixIndex(1), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2434 ASSERT_THROW(path.GetPrefixTag(2), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2435 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2436 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2437 path = DicomPath::Parse("PatientID[1].PatientName"); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2438 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2439 ASSERT_EQ(1u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2440 ASSERT_EQ(DICOM_TAG_PATIENT_ID, path.GetPrefixTag(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2441 ASSERT_FALSE(path.IsPrefixUniversal(0)); |
4700
863383e7e582
fix warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
2442 ASSERT_EQ(1u, path.GetPrefixIndex(0)); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2443 ASSERT_THROW(path.GetPrefixTag(1), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2444 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2445 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2446 path = DicomPath::Parse(" PatientID [ 42 ] . PatientName "); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2447 ASSERT_FALSE(path.HasUniversal()); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2448 ASSERT_EQ(1u, path.GetPrefixLength()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2449 ASSERT_EQ(DICOM_TAG_PATIENT_ID, path.GetPrefixTag(0)); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2450 ASSERT_FALSE(path.IsPrefixUniversal(0)); |
4700
863383e7e582
fix warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4696
diff
changeset
|
2451 ASSERT_EQ(42u, path.GetPrefixIndex(0)); |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2452 ASSERT_THROW(path.GetPrefixTag(1), OrthancException); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2453 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, path.GetFinalTag()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2454 ASSERT_EQ("(0010,0020)[42].(0010,0010)", path.Format()); |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2455 |
4689
ead3b81f4541
added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4685
diff
changeset
|
2456 ASSERT_THROW(path.SetPrefixIndex(1, 44), OrthancException); |
ead3b81f4541
added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4685
diff
changeset
|
2457 path.SetPrefixIndex(0, 44); |
ead3b81f4541
added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4685
diff
changeset
|
2458 ASSERT_EQ("(0010,0020)[44].(0010,0010)", path.Format()); |
ead3b81f4541
added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4685
diff
changeset
|
2459 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2460 ASSERT_THROW(DicomPath::Parse("nope"), OrthancException); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2461 ASSERT_THROW(DicomPath::Parse("(0010,0010)[.PatientID"), OrthancException); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2462 ASSERT_THROW(DicomPath::Parse("(0010,0010)[].PatientID"), OrthancException); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2463 ASSERT_THROW(DicomPath::Parse("(0010,0010[].PatientID"), OrthancException); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2464 ASSERT_THROW(DicomPath::Parse("(0010,0010)0].PatientID"), OrthancException); |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2465 ASSERT_THROW(DicomPath::Parse("(0010,0010)[-1].PatientID"), OrthancException); |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2466 |
4735
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2467 ASSERT_TRUE(MyIsMatch(DicomPath::Parse("(0010,0010)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2468 DicomPath::Parse("(0010,0010)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2469 ASSERT_FALSE(MyIsMatch(DicomPath::Parse("(0010,0010)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2470 DicomPath::Parse("(0010,0020)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2471 ASSERT_TRUE(MyIsMatch(DicomPath::Parse("(0010,0010)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2472 DicomPath::Parse("(0010,0010)[1].(0010,0020)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2473 ASSERT_FALSE(MyIsMatch(DicomPath::Parse("(0010,0010)[1].(0010,0020)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2474 DicomPath::Parse("(0010,0010)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2475 ASSERT_TRUE(MyIsMatch(DicomPath::Parse("(0010,0010)[1].(0010,0020)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2476 DicomPath::Parse("(0010,0010)[1].(0010,0020)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2477 ASSERT_TRUE(MyIsMatch(DicomPath::Parse("(0010,0010)[*].(0010,0020)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2478 DicomPath::Parse("(0010,0010)[1].(0010,0020)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2479 ASSERT_FALSE(MyIsMatch(DicomPath::Parse("(0010,0010)[2].(0010,0020)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2480 DicomPath::Parse("(0010,0010)[1].(0010,0020)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2481 ASSERT_THROW(MyIsMatch(DicomPath::Parse("(0010,0010)[1].(0010,0020)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2482 DicomPath::Parse("(0010,0010)[*].(0010,0020)")), OrthancException); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2483 ASSERT_TRUE(MyIsMatch(DicomPath::Parse("(0010,0010)[*].(0010,0020)[*].(0010,0030)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2484 DicomPath::Parse("(0010,0010)[1].(0010,0020)[2].(0010,0030)[3].(0010,0040)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2485 ASSERT_TRUE(MyIsMatch(DicomPath::Parse("(0010,0010)[1].(0010,0020)[2].(0010,0030)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2486 DicomPath::Parse("(0010,0010)[1].(0010,0020)[2].(0010,0030)[3].(0010,0040)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2487 ASSERT_FALSE(MyIsMatch(DicomPath::Parse("(0010,0010)[1].(0010,0020)[3].(0010,0030)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2488 DicomPath::Parse("(0010,0010)[1].(0010,0020)[2].(0010,0030)[3].(0010,0040)"))); |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2489 ASSERT_FALSE(MyIsMatch(DicomPath::Parse("(0010,0010)[2].(0010,0020)[2].(0010,0030)"), |
e17fdc43ef6c
optimized version of DicomPath::IsMatch()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4734
diff
changeset
|
2490 DicomPath::Parse("(0010,0010)[1].(0010,0020)[2].(0010,0030)[3].(0010,0040)"))); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2491 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2492 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2493 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2494 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2495 TEST(ParsedDicomFile, DicomPath) |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2496 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2497 Json::Value v = Json::objectValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2498 v["PatientName"] = "Hello"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2499 v["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2500 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2501 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2502 Json::Value a = Json::arrayValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2503 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2504 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2505 Json::Value item = Json::objectValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2506 item["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2507 item["ReferencedSOPInstanceUID"] = "1.2.840.113619.2.176.2025.1499492.7040.1171286241.719"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2508 a.append(item); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2509 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2510 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2511 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2512 Json::Value item = Json::objectValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2513 item["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; // ReferencedSOPClassUID |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2514 item["ReferencedSOPInstanceUID"] = "1.2.840.113619.2.176.2025.1499492.7040.1171286241.726"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2515 a.append(item); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2516 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2517 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2518 v["ReferencedImageSequence"] = a; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2519 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2520 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2521 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2522 Json::Value a = Json::arrayValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2523 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2524 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2525 Json::Value item = Json::objectValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2526 item["StudyInstanceUID"] = "1.2.840.113704.1.111.7016.1342451220.40"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2527 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2528 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2529 Json::Value b = Json::arrayValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2530 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2531 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2532 Json::Value c = Json::objectValue; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2533 c["CodeValue"] = "122403"; |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4689
diff
changeset
|
2534 c["0008,103e"] = "WORLD"; // Series description |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2535 b.append(c); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2536 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2537 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2538 item["PurposeOfReferenceCodeSequence"] = b; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2539 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2540 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2541 a.append(item); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2542 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2543 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2544 v["RelatedSeriesSequence"] = a; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2545 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2546 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2547 static const char* CODE_VALUE = "0008,0100"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2548 static const char* PATIENT_ID = "0010,0020"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2549 static const char* PATIENT_NAME = "0010,0010"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2550 static const char* PURPOSE_CODE_SEQ = "0040,a170"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2551 static const char* REF_IM_SEQ = "0008,1140"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2552 static const char* REF_SOP_CLASS = "0008,1150"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2553 static const char* REF_SOP_INSTANCE = "0008,1155"; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2554 static const char* REL_SERIES_SEQ = "0008,1250"; |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2555 static const char* STUDY_INSTANCE_UID = "0020,000d"; |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2556 |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2557 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2558 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2559 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2560 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2561 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2562 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2563 ASSERT_EQ(5u, vv.size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2564 ASSERT_TRUE(vv.isMember(PATIENT_NAME)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2565 ASSERT_EQ(2u, vv[REF_IM_SEQ].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2566 ASSERT_EQ(1u, vv[REL_SERIES_SEQ].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2567 ASSERT_EQ(2u, vv[REF_IM_SEQ][0].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2568 ASSERT_EQ(2u, vv[REL_SERIES_SEQ][0].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2569 ASSERT_EQ(1u, vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2570 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2571 ASSERT_TRUE(vv[REF_IM_SEQ][0].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2572 ASSERT_TRUE(vv[REF_IM_SEQ][1].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2573 ASSERT_TRUE(vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0].isMember(CODE_VALUE)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2574 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2575 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2576 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2577 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2578 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2579 dicom->RemovePath(DicomPath::Parse("ReferencedImageSequence[*].ReferencedSOPClassUID")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2580 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2581 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2582 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2583 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2584 ASSERT_EQ(2u, vv[REF_IM_SEQ].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2585 ASSERT_EQ(1u, vv[REF_IM_SEQ][0].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2586 ASSERT_EQ(1u, vv[REF_IM_SEQ][1].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2587 ASSERT_FALSE(vv[REF_IM_SEQ][0].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2588 ASSERT_FALSE(vv[REF_IM_SEQ][1].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2589 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2590 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2591 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2592 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2593 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2594 dicom->RemovePath(DicomPath::Parse("ReferencedImageSequence[0].ReferencedSOPClassUID")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2595 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2596 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2597 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2598 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2599 ASSERT_EQ(2u, vv[REF_IM_SEQ].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2600 ASSERT_EQ(1u, vv[REF_IM_SEQ][0].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2601 ASSERT_EQ(2u, vv[REF_IM_SEQ][1].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2602 ASSERT_FALSE(vv[REF_IM_SEQ][0].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2603 ASSERT_TRUE(vv[REF_IM_SEQ][1].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2604 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2605 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2606 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2607 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2608 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2609 dicom->RemovePath(DicomPath::Parse("ReferencedImageSequence[1].ReferencedSOPClassUID")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2610 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2611 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2612 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2613 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2614 ASSERT_EQ(2u, vv[REF_IM_SEQ].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2615 ASSERT_EQ(2u, vv[REF_IM_SEQ][0].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2616 ASSERT_EQ(1u, vv[REF_IM_SEQ][1].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2617 ASSERT_TRUE(vv[REF_IM_SEQ][0].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2618 ASSERT_FALSE(vv[REF_IM_SEQ][1].isMember(REF_SOP_CLASS)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2619 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2620 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2621 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2622 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2623 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2624 dicom->RemovePath(DicomPath::Parse("RelatedSeriesSequence[0].PurposeOfReferenceCodeSequence[0].CodeValue")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2625 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2626 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2627 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2628 |
4744 | 2629 static const char* SERIES_DESCRIPTION = "0008,103e"; |
2630 | |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4689
diff
changeset
|
2631 ASSERT_EQ("WORLD", vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0][SERIES_DESCRIPTION].asString()); |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2632 ASSERT_FALSE(vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0].isMember(CODE_VALUE)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2633 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2634 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2635 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2636 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2637 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2638 dicom->RemovePath(DicomPath::Parse("RelatedSeriesSequence[0].PurposeOfReferenceCodeSequence")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2639 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2640 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2641 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2642 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2643 ASSERT_EQ(1u, vv[REL_SERIES_SEQ][0].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2644 ASSERT_FALSE(vv[REL_SERIES_SEQ][0].isMember(PURPOSE_CODE_SEQ)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2645 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2646 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2647 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2648 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2649 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2650 dicom->RemovePath(DicomPath::Parse("RelatedSeriesSequence")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2651 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2652 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2653 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2654 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2655 ASSERT_FALSE(vv.isMember(REL_SERIES_SEQ)); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2656 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2657 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2658 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2659 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2660 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2661 dicom->RemovePath(DicomPath(DICOM_TAG_PATIENT_NAME)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2662 dicom->ReplacePath(DicomPath::Parse("ReferencedImageSequence[*].ReferencedSOPClassUID"), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2663 "Hello1", false, DicomReplaceMode_ThrowIfAbsent, ""); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2664 ASSERT_THROW(dicom->ReplacePath(DicomPath::Parse("ReferencedImageSequence[*].PatientID"), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2665 "Hello2", false, DicomReplaceMode_ThrowIfAbsent, ""), OrthancException); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2666 dicom->ReplacePath(DicomPath::Parse("ReferencedImageSequence[*].PatientID"), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2667 "Hello3", false, DicomReplaceMode_InsertIfAbsent, ""); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2668 dicom->ReplacePath(DicomPath::Parse("ReferencedImageSequence[*].PatientName"), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2669 "Hello4", false, DicomReplaceMode_IgnoreIfAbsent, ""); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2670 dicom->ReplacePath(DicomPath::Parse("RelatedSeriesSequence[*].PurposeOfReferenceCodeSequence[*].CodeValue"), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2671 "Hello5", false, DicomReplaceMode_ThrowIfAbsent, ""); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2672 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2673 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2674 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2675 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2676 ASSERT_EQ(4u, vv.size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2677 ASSERT_FALSE(vv.isMember(PATIENT_NAME)); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2678 ASSERT_EQ("Hello1", vv[REF_IM_SEQ][0][REF_SOP_CLASS].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2679 ASSERT_EQ("Hello3", vv[REF_IM_SEQ][0][PATIENT_ID].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2680 ASSERT_EQ("Hello1", vv[REF_IM_SEQ][1][REF_SOP_CLASS].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2681 ASSERT_EQ("Hello3", vv[REF_IM_SEQ][1][PATIENT_ID].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2682 ASSERT_EQ("Hello5", vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0][CODE_VALUE].asString()); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2683 } |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2684 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2685 { |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2686 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2687 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2688 dicom->ReplacePath(DicomPath::Parse("ReferencedImageSequence[1].ReferencedSOPClassUID"), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2689 "Hello1", false, DicomReplaceMode_ThrowIfAbsent, ""); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2690 dicom->ReplacePath(DicomPath::Parse("RelatedSeriesSequence[0].PurposeOfReferenceCodeSequence[0].CodeValue"), |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2691 "Hello2", false, DicomReplaceMode_ThrowIfAbsent, ""); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2692 |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2693 Json::Value vv; |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2694 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2695 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2696 ASSERT_EQ("1.2.840.10008.5.1.4.1.1.4", vv[REF_IM_SEQ][0][REF_SOP_CLASS].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2697 ASSERT_EQ("Hello1", vv[REF_IM_SEQ][1][REF_SOP_CLASS].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2698 ASSERT_EQ("Hello2", vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0][CODE_VALUE].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2699 } |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2700 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2701 { |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2702 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2703 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2704 dicom->ClearPath(DicomPath::Parse("ReferencedImageSequence[1].ReferencedSOPClassUID"), true); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2705 dicom->ClearPath(DicomPath::Parse("RelatedSeriesSequence[0].PurposeOfReferenceCodeSequence[0].CodeValue"), true); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2706 dicom->ClearPath(DicomPath::Parse("ReferencedImageSequence[0].PatientID"), false); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2707 dicom->ClearPath(DicomPath::Parse("ReferencedImageSequence[0].PatientName"), true); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2708 |
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2709 Json::Value vv; |
4683
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2710 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2711 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2712 ASSERT_EQ(3u, vv[REF_IM_SEQ][0].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2713 ASSERT_EQ(2u, vv[REF_IM_SEQ][1].size()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2714 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2715 ASSERT_EQ("1.2.840.10008.5.1.4.1.1.4", vv[REF_IM_SEQ][0][REF_SOP_CLASS].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2716 ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.719", vv[REF_IM_SEQ][0][REF_SOP_INSTANCE].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2717 ASSERT_EQ("", vv[REF_IM_SEQ][0][PATIENT_ID].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2718 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2719 ASSERT_EQ("", vv[REF_IM_SEQ][1][REF_SOP_CLASS].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2720 ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", vv[REF_IM_SEQ][1][REF_SOP_INSTANCE].asString()); |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2721 |
7182f5732480
use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4682
diff
changeset
|
2722 ASSERT_EQ("", vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0][CODE_VALUE].asString()); |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
2723 } |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2724 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2725 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2726 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2727 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2728 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2729 DicomModification modif; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2730 modif.Replace(DicomPath(DICOM_TAG_PATIENT_NAME), "Hello1", false); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2731 modif.Replace(DicomPath::Parse("ReferencedImageSequence[1].ReferencedSOPClassUID"), "Hello2", false); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2732 modif.Replace(DicomPath::Parse("RelatedSeriesSequence[0].PurposeOfReferenceCodeSequence[0].CodeValue"), "Hello3", false); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2733 modif.Apply(*dicom); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2734 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2735 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2736 Json::Value vv; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2737 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2738 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2739 ASSERT_TRUE(vv.isMember(PATIENT_NAME)); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2740 ASSERT_EQ("Hello1", vv[PATIENT_NAME].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2741 ASSERT_EQ("1.2.840.10008.5.1.4.1.1.4", vv[REF_IM_SEQ][0][REF_SOP_CLASS].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2742 ASSERT_EQ("Hello2", vv[REF_IM_SEQ][1][REF_SOP_CLASS].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2743 ASSERT_EQ("Hello3", vv[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0][CODE_VALUE].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2744 ASSERT_EQ(2u, vv[REL_SERIES_SEQ][0].size()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2745 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2746 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2747 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2748 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2749 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2750 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2751 DicomModification modif; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2752 modif.Remove(DicomPath(DICOM_TAG_PATIENT_NAME)); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2753 modif.Remove(DicomPath::Parse("ReferencedImageSequence[1].ReferencedSOPClassUID")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2754 modif.Remove(DicomPath::Parse("RelatedSeriesSequence[0].PurposeOfReferenceCodeSequence")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2755 modif.Apply(*dicom); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2756 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2757 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2758 Json::Value vv; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2759 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2760 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2761 ASSERT_FALSE(vv.isMember(PATIENT_NAME)); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2762 ASSERT_EQ(2u, vv[REF_IM_SEQ][0].size()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2763 ASSERT_TRUE(vv[REF_IM_SEQ][0].isMember(REF_SOP_CLASS)); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2764 ASSERT_EQ(1u, vv[REF_IM_SEQ][1].size()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2765 ASSERT_FALSE(vv[REF_IM_SEQ][1].isMember(REF_SOP_CLASS)); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2766 ASSERT_EQ(1u, vv[REL_SERIES_SEQ][0].size()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2767 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2768 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2769 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2770 std::unique_ptr<ParsedDicomFile> dicom1(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2771 std::unique_ptr<ParsedDicomFile> dicom2(dicom1->Clone(true)); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2772 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2773 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2774 DicomModification modif; |
5334
5b2a5cc64cb1
upgraded anonymization to Basic Profile of PS 3.15-2023b Table E.1-1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5323
diff
changeset
|
2775 modif.SetupAnonymization(DicomVersion_2023b); |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2776 modif.Apply(*dicom1); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2777 modif.Apply(*dicom2); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2778 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2779 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2780 // Same anonymization context and same input DICOM => hence, same output DICOM |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2781 Json::Value vv1, vv2; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2782 dicom1->DatasetToJson(vv1, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2783 dicom2->DatasetToJson(vv2, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2784 ASSERT_EQ(vv1.toStyledString(), vv2.toStyledString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2785 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2786 ASSERT_TRUE(Toolbox::IsUuid(vv1[PATIENT_NAME].asString())); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2787 ASSERT_EQ("1.2.840.10008.5.1.4.1.1.4", vv1[REF_IM_SEQ][0][REF_SOP_CLASS].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2788 ASSERT_NE("1.2.840.113619.2.176.2025.1499492.7040.1171286241.719", vv1[REF_IM_SEQ][0][REF_SOP_INSTANCE].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2789 ASSERT_NE("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", vv1[REF_IM_SEQ][1][REF_SOP_INSTANCE].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2790 ASSERT_NE("1.2.840.113704.1.111.7016.1342451220.40", vv1[REL_SERIES_SEQ][0][STUDY_INSTANCE_UID].asString()); |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2791 |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2792 // Contrarily to Orthanc 1.9.4, the "SERIES_DESCRIPTION" is also removed from nested sequences |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2793 ASSERT_EQ(1u, vv1[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0].size()); |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2794 ASSERT_EQ("122403", vv1[REL_SERIES_SEQ][0][PURPOSE_CODE_SEQ][0]["0008,0100"].asString()); |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2795 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2796 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2797 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2798 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2799 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2800 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2801 DicomModification modif; |
5334
5b2a5cc64cb1
upgraded anonymization to Basic Profile of PS 3.15-2023b Table E.1-1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5323
diff
changeset
|
2802 modif.SetupAnonymization(DicomVersion_2023b); |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2803 modif.Keep(DicomPath::Parse("ReferencedImageSequence[1].ReferencedSOPInstanceUID")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2804 modif.Keep(DicomPath::Parse("RelatedSeriesSequence")); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2805 modif.Apply(*dicom); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2806 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2807 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2808 Json::Value vv; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2809 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2810 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2811 ASSERT_NE("1.2.840.113619.2.176.2025.1499492.7040.1171286241.719", vv[REF_IM_SEQ][0][REF_SOP_INSTANCE].asString()); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2812 ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", vv[REF_IM_SEQ][1][REF_SOP_INSTANCE].asString()); // kept |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2813 ASSERT_EQ("1.2.840.113704.1.111.7016.1342451220.40", vv[REL_SERIES_SEQ][0][STUDY_INSTANCE_UID].asString()); // kept |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4683
diff
changeset
|
2814 } |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2815 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2816 { |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2817 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2818 |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2819 DicomMap m; |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
2820 ASSERT_TRUE(dicom->LookupSequenceItem(m, DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE), 0)); |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2821 ASSERT_EQ(2u, m.GetSize()); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2822 ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.719", |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2823 m.GetStringValue(DICOM_TAG_REFERENCED_SOP_INSTANCE_UID, "", false)); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2824 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
2825 ASSERT_TRUE(dicom->LookupSequenceItem(m, DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE), 1)); |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2826 ASSERT_EQ(2u, m.GetSize()); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2827 ASSERT_EQ("1.2.840.113619.2.176.2025.1499492.7040.1171286241.726", |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2828 m.GetStringValue(DICOM_TAG_REFERENCED_SOP_INSTANCE_UID, "", false)); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2829 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
2830 ASSERT_FALSE(dicom->LookupSequenceItem(m, DicomPath(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE), 2)); |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2831 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
2832 ASSERT_TRUE(dicom->LookupSequenceItem(m, DicomPath(DicomTag(0x0008, 0x1250), 0, DicomTag(0x0040, 0xa170)), 0)); |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2833 ASSERT_EQ(2u, m.GetSize()); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2834 ASSERT_EQ("122403", m.GetStringValue(DicomTag(0x0008, 0x0100), "", false)); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2835 ASSERT_EQ("WORLD", m.GetStringValue(DICOM_TAG_SERIES_DESCRIPTION, "", false)); |
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2836 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
2837 ASSERT_FALSE(dicom->LookupSequenceItem(m, DicomPath(DicomTag(0x0008, 0x1250), 0, DicomTag(0x0040, 0xa170)), 1)); |
4771
9f207131c7f4
added ParsedDicomFile::LookupSubSequence()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4744
diff
changeset
|
2838 } |
4681
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2839 } |
c5528c7847a6
new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4532
diff
changeset
|
2840 |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2841 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2842 TEST(FromDcmtkBridge, VisitorRemoveTag) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2843 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2844 class V : public ITagVisitor |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2845 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2846 private: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2847 uint32_t seen_; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2848 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2849 public: |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2850 V() : seen_(0) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2851 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2852 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2853 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2854 unsigned int GetSeen() const |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2855 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2856 return seen_; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2857 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2858 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2859 virtual Action VisitNotSupported(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2860 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2861 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2862 ValueRepresentation vr) ORTHANC_OVERRIDE |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2863 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2864 seen_ |= (1 << 0); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2865 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2866 if (parentTags.size() == 0u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2867 parentIndexes.size() == 0u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2868 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_PixelData) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2869 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2870 return Action_Remove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2871 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2872 else |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2873 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2874 throw OrthancException(ErrorCode_InternalError); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2875 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2876 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2877 |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2878 virtual Action VisitSequence(const std::vector<DicomTag>& parentTags, |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2879 const std::vector<size_t>& parentIndexes, |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2880 const DicomTag& tag, |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2881 size_t countItems) ORTHANC_OVERRIDE |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2882 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2883 seen_ |= (1 << 1); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2884 |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2885 if (parentTags.size() == 0u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2886 parentIndexes.size() == 0u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2887 tag == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2888 countItems == 1) |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2889 { |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2890 return Action_None; |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2891 } |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2892 else if (parentTags.size() == 1u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2893 parentIndexes.size() == 1u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2894 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2895 parentIndexes[0] == 0u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2896 countItems == 0 && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2897 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_ReferencedPatientSequence) |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2898 { |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2899 return Action_Remove; |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2900 } |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2901 else if (parentTags.size() == 1u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2902 parentIndexes.size() == 1u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2903 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2904 parentIndexes[0] == 0u && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2905 countItems == 1 && |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
2906 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_ReferencedStudySequence) |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2907 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2908 return Action_Remove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2909 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2910 else |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2911 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2912 throw OrthancException(ErrorCode_InternalError); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2913 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2914 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2915 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2916 virtual Action VisitIntegers(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2917 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2918 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2919 ValueRepresentation vr, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2920 const std::vector<int64_t>& values) ORTHANC_OVERRIDE |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2921 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2922 seen_ |= (1 << 2); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2923 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2924 if (parentTags.size() == 0u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2925 parentIndexes.size() == 0u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2926 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_TagAngleSecondAxis && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2927 values.size() == 2 && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2928 values[0] == 12 && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2929 values[1] == 13) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2930 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2931 return Action_Remove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2932 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2933 else |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2934 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2935 throw OrthancException(ErrorCode_InternalError); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2936 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2937 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2938 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2939 virtual Action VisitDoubles(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2940 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2941 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2942 ValueRepresentation vr, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2943 const std::vector<double>& values) ORTHANC_OVERRIDE |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2944 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2945 seen_ |= (1 << 3); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2946 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2947 if (parentTags.size() == 1u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2948 parentIndexes.size() == 1u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2949 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2950 parentIndexes[0] == 0u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2951 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_ExaminedBodyThickness && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2952 values.size() == 3 && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2953 std::abs(values[0] - 42.0f) <= 0.001f && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2954 std::abs(values[1] - 43.0f) <= 0.001f && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2955 std::abs(values[2] - 47.0f) <= 0.001f) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2956 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2957 return Action_Remove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2958 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2959 else |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2960 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2961 throw OrthancException(ErrorCode_InternalError); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2962 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2963 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2964 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2965 virtual Action VisitAttributes(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2966 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2967 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2968 const std::vector<DicomTag>& values) ORTHANC_OVERRIDE |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2969 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2970 seen_ |= (1 << 4); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2971 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2972 if (parentTags.size() == 1u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2973 parentIndexes.size() == 1u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2974 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2975 parentIndexes[0] == 0u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2976 DcmTagKey(tag.GetGroup(), tag.GetElement()) == DCM_DimensionIndexPointer && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2977 values.size() == 2 && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2978 values[0] == DICOM_TAG_STUDY_DATE && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2979 values[1] == DICOM_TAG_STUDY_TIME) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2980 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2981 return Action_Remove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2982 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2983 else |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2984 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2985 throw OrthancException(ErrorCode_InternalError); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2986 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2987 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2988 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2989 virtual Action VisitBinary(const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2990 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2991 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2992 ValueRepresentation vr, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2993 const void* data, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2994 size_t size) ORTHANC_OVERRIDE |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2995 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2996 seen_ |= (1 << 5); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2997 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2998 if (parentTags.size() == 1u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
2999 parentIndexes.size() == 1u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3000 parentTags[0] == DICOM_TAG_REFERENCED_IMAGE_SEQUENCE && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3001 parentIndexes[0] == 0u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3002 tag.GetGroup() == 0x0011 && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3003 tag.GetElement() == 0x1311 && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3004 size == 4u && |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3005 memcmp(data, "abcd", 4) == 0) |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3006 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3007 return Action_Remove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3008 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3009 else |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3010 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3011 throw OrthancException(ErrorCode_InternalError); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3012 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3013 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3014 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3015 virtual Action VisitString(std::string& newValue, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3016 const std::vector<DicomTag>& parentTags, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3017 const std::vector<size_t>& parentIndexes, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3018 const DicomTag& tag, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3019 ValueRepresentation vr, |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3020 const std::string& value) ORTHANC_OVERRIDE |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3021 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3022 seen_ |= (1 << 6); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3023 return Action_Remove; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3024 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3025 }; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3026 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3027 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3028 std::unique_ptr<ParsedDicomFile> dicom; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3029 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3030 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3031 Json::Value v = Json::objectValue; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3032 v["PatientName"] = "Hello"; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3033 v["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3034 v["ReferencedImageSequence"][0]["ReferencedSOPClassUID"] = "1.2.840.10008.5.1.4.1.1.4"; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3035 v["ReferencedImageSequence"][0]["ReferencedSOPInstanceUID"] = "1.2.840.113619.2.176.2025.1499492.7040.1171286241.719"; |
4737
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
3036 v["ReferencedImageSequence"][0]["ReferencedPatientSequence"] = Json::arrayValue; // Empty nested sequence |
979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4736
diff
changeset
|
3037 v["ReferencedImageSequence"][0]["ReferencedStudySequence"][0]["PatientID"] = "Hello"; // Non-empty nested sequence |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3038 v["ReferencedImageSequence"][0]["0011,1311"] = "abcd"; // Binary |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3039 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3040 dicom.reset(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "PrivateCreator")); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3041 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3042 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3043 // Test value multiplicity (cannot be done using "ParsedDicomFile::CreateFromJson()") |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3044 const int16_t a[] = { 12, 13 }; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3045 std::unique_ptr<DcmSignedShort> s(new DcmSignedShort(DCM_TagAngleSecondAxis)); // VisitIntegers() |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3046 ASSERT_TRUE(s->putSint16Array(a, 2).good()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3047 dicom->GetDcmtkObject().getDataset()->insert(s.release()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3048 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3049 |
4736
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
3050 DcmItem *parent = NULL; |
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
3051 ASSERT_TRUE(dicom->GetDcmtkObject().getDataset()->findAndGetSequenceItem(DCM_ReferencedImageSequence, parent, 0).good()); |
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
3052 |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3053 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3054 const float a[] = { 42, 43, 47 }; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3055 std::unique_ptr<DcmFloatingPointSingle> s(new DcmFloatingPointSingle(DCM_ExaminedBodyThickness)); // VisitDoubles() |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3056 ASSERT_TRUE(s->putFloat32Array(a, 3).good()); |
4736
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
3057 parent->insert(s.release()); |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3058 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3059 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3060 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3061 const uint16_t a[] = { 0x0008, 0x0020, 0x0008, 0x0030 }; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3062 std::unique_ptr<DcmAttributeTag> s(new DcmAttributeTag(DCM_DimensionIndexPointer)); // VisitAttributes() |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3063 ASSERT_TRUE(s->putUint16Array(a, 2).good()); |
4736
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
3064 parent->insert(s.release()); |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3065 } |
4736
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
3066 |
bf852fd773b7
fix unit test FromDcmtkBridge.VisitorRemoveTag on DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4735
diff
changeset
|
3067 ASSERT_TRUE(dicom->GetDcmtkObject().getDataset()->insert(new DcmPixelItem(DCM_PixelData)).good()); // VisitNotSupported() |
4734
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3068 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3069 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3070 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3071 V visitor; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3072 dicom->Apply(visitor); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3073 ASSERT_EQ(127u, visitor.GetSeen()); // Make sure all the methods have been applied |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3074 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3075 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3076 { |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3077 Json::Value b; |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3078 dicom->DatasetToJson(b, DicomToJsonFormat_Short, DicomToJsonFlags_Default, 0); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3079 ASSERT_EQ(Json::objectValue, b.type()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3080 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3081 Json::Value::Members members = b.getMemberNames(); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3082 ASSERT_EQ(1u, members.size()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3083 ASSERT_EQ("0008,1140", members[0]); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3084 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3085 // Check that "b["0008,1140"]" is a sequence with one single empty object |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3086 ASSERT_EQ(Json::arrayValue, b["0008,1140"].type()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3087 ASSERT_EQ(1u, b["0008,1140"].size()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3088 ASSERT_EQ(Json::objectValue, b["0008,1140"][0].type()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3089 ASSERT_EQ(0u, b["0008,1140"][0].size()); |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3090 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3091 } |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3092 |
b51c08bd5c38
added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
3093 |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
3094 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3095 TEST(ParsedDicomFile, ImageInformation) |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3096 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3097 double wc, ww; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3098 double ri, rs; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3099 PhotometricInterpretation p; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3100 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3101 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3102 ParsedDicomFile dicom(false); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3103 dicom.GetDefaultWindowing(wc, ww, 5); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3104 dicom.GetRescale(ri, rs, 5); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3105 ASSERT_DOUBLE_EQ(128.0, wc); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3106 ASSERT_DOUBLE_EQ(256.0, ww); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3107 ASSERT_FALSE(dicom.LookupPhotometricInterpretation(p)); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3108 ASSERT_DOUBLE_EQ(0.0, ri); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3109 ASSERT_DOUBLE_EQ(1.0, rs); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3110 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3111 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3112 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3113 ParsedDicomFile dicom(false); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3114 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_BitsStored, "4").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3115 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_PhotometricInterpretation, "RGB").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3116 dicom.GetDefaultWindowing(wc, ww, 5); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3117 ASSERT_DOUBLE_EQ(8.0, wc); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3118 ASSERT_DOUBLE_EQ(16.0, ww); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3119 ASSERT_TRUE(dicom.LookupPhotometricInterpretation(p)); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3120 ASSERT_EQ(PhotometricInterpretation_RGB, p); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3121 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3122 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3123 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3124 ParsedDicomFile dicom(false); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3125 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_WindowCenter, "12").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3126 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_WindowWidth, "-22").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3127 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_RescaleIntercept, "-22").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3128 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_RescaleSlope, "-23").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3129 dicom.GetDefaultWindowing(wc, ww, 5); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3130 dicom.GetRescale(ri, rs, 5); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3131 ASSERT_DOUBLE_EQ(12.0, wc); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3132 ASSERT_DOUBLE_EQ(-22.0, ww); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3133 ASSERT_DOUBLE_EQ(-22.0, ri); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3134 ASSERT_DOUBLE_EQ(-23.0, rs); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3135 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3136 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3137 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3138 ParsedDicomFile dicom(false); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3139 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_WindowCenter, "12\\13\\14").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3140 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_WindowWidth, "-22\\-23\\-24").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3141 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_RescaleIntercept, "32\\33\\34").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3142 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DCM_RescaleSlope, "-42\\-43\\-44").good()); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3143 dicom.GetDefaultWindowing(wc, ww, 5); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3144 dicom.GetRescale(ri, rs, 5); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3145 ASSERT_DOUBLE_EQ(12.0, wc); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3146 ASSERT_DOUBLE_EQ(-22.0, ww); |
4782 | 3147 ASSERT_DOUBLE_EQ(0.0, ri); |
3148 ASSERT_DOUBLE_EQ(1.0, rs); | |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3149 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3150 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3151 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3152 // Philips multiframe |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3153 Json::Value v = Json::objectValue; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3154 v["PerFrameFunctionalGroupsSequence"][0]["FrameVOILUTSequence"][0]["WindowCenter"] = "614"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3155 v["PerFrameFunctionalGroupsSequence"][0]["FrameVOILUTSequence"][0]["WindowWidth"] = "1067"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3156 v["PerFrameFunctionalGroupsSequence"][0]["PixelValueTransformationSequence"][0]["RescaleIntercept"] = "12"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3157 v["PerFrameFunctionalGroupsSequence"][0]["PixelValueTransformationSequence"][0]["RescaleSlope"] = "2.551648"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3158 v["PerFrameFunctionalGroupsSequence"][1]["FrameVOILUTSequence"][0]["WindowCenter"] = "-61"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3159 v["PerFrameFunctionalGroupsSequence"][1]["FrameVOILUTSequence"][0]["WindowWidth"] = "-63"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3160 v["PerFrameFunctionalGroupsSequence"][1]["PixelValueTransformationSequence"][0]["RescaleIntercept"] = "13"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3161 v["PerFrameFunctionalGroupsSequence"][1]["PixelValueTransformationSequence"][0]["RescaleSlope"] = "-14"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3162 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3163 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3164 dicom->GetDefaultWindowing(wc, ww, 0); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3165 dicom->GetRescale(ri, rs, 0); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3166 ASSERT_DOUBLE_EQ(614.0, wc); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3167 ASSERT_DOUBLE_EQ(1067.0, ww); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3168 ASSERT_DOUBLE_EQ(12.0, ri); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3169 ASSERT_DOUBLE_EQ(2.551648, rs); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3170 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3171 dicom->GetDefaultWindowing(wc, ww, 1); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3172 dicom->GetRescale(ri, rs, 1); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3173 ASSERT_DOUBLE_EQ(-61.0, wc); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3174 ASSERT_DOUBLE_EQ(-63.0, ww); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3175 ASSERT_DOUBLE_EQ(13.0, ri); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3176 ASSERT_DOUBLE_EQ(-14.0, rs); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3177 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3178 dicom->GetDefaultWindowing(wc, ww, 2); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3179 dicom->GetRescale(ri, rs, 2); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3180 ASSERT_DOUBLE_EQ(128.0, wc); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3181 ASSERT_DOUBLE_EQ(256.0, ww); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3182 ASSERT_DOUBLE_EQ(0.0, ri); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3183 ASSERT_DOUBLE_EQ(1.0, rs); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3184 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3185 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3186 { |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3187 // RT-DOSE |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3188 Json::Value v = Json::objectValue; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3189 v["RescaleIntercept"] = "10"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3190 v["RescaleSlope"] = "20"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3191 v["PerFrameFunctionalGroupsSequence"][0]["PixelValueTransformationSequence"][0]["RescaleIntercept"] = "30"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3192 v["PerFrameFunctionalGroupsSequence"][0]["PixelValueTransformationSequence"][0]["RescaleSlope"] = "40"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3193 std::unique_ptr<ParsedDicomFile> dicom(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3194 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3195 dicom->GetRescale(ri, rs, 0); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3196 ASSERT_DOUBLE_EQ(10.0, ri); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3197 ASSERT_DOUBLE_EQ(20.0, rs); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3198 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3199 v["SOPClassUID"] = "1.2.840.10008.5.1.4.1.1.481.2"; |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3200 dicom.reset(ParsedDicomFile::CreateFromJson(v, DicomFromJsonFlags_None, "")); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3201 dicom->GetRescale(ri, rs, 0); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3202 ASSERT_DOUBLE_EQ(0.0, ri); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3203 ASSERT_DOUBLE_EQ(1.0, rs); |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3204 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3205 } |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3206 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3207 |
4788
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3208 TEST(DicomMap, DicomWebWithInteger64) |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3209 { |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3210 /** |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3211 * This failed in Orthanc <= 1.9.7 with |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3212 * "http://localhost:8042/dicom-web/studies/1.3.6.1.4.1.14519.5.2.1.314316487728501506587013300243937537423/series/1.3.6.1.4.1.1459.5.2.1.62266640231940987006694557463549207147/instances/1.3.6.1.4.1.14519.5.2.1.147718809116229175846174241356499989705/metadata" |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3213 * of patient "GLIOMA01-i_03A6" from collection "ICDC-Glioma" of |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3214 * TCIA. |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3215 **/ |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3216 Json::Value v = Json::objectValue; |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3217 v["00191297"]["Value"][0] = 29362240; |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3218 v["00191297"]["Value"][1] = Json::Int64(4294948074l); |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3219 v["00191297"]["vr"] = "UL"; |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3220 DicomMap m; |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3221 m.FromDicomWeb(v); |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3222 } |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3223 |
b47ee86a0d10
support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4782
diff
changeset
|
3224 |
5318
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3225 TEST(ParsedDicomFile, InjectEmptyPixelData) |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3226 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3227 static const char* PIXEL_DATA = "7FE00010"; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3228 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3229 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3230 ParsedDicomFile dicom(true); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3231 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3232 DicomWebJsonVisitor visitor; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3233 dicom.Apply(visitor); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3234 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3235 ASSERT_FALSE(visitor.GetResult().isMember(PIXEL_DATA)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3236 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3237 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3238 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3239 ParsedDicomFile dicom(true); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3240 dicom.InjectEmptyPixelData(ValueRepresentation_OtherByte); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3241 dicom.InjectEmptyPixelData(ValueRepresentation_OtherWord); // Must be ignored |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3242 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3243 DicomWebJsonVisitor visitor; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3244 dicom.Apply(visitor); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3245 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3246 ASSERT_TRUE(visitor.GetResult().isMember(PIXEL_DATA)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3247 ASSERT_EQ(2u, visitor.GetResult() [PIXEL_DATA].size()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3248 ASSERT_EQ("", visitor.GetResult() [PIXEL_DATA]["InlineBinary"].asString()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3249 ASSERT_EQ("OB", visitor.GetResult() [PIXEL_DATA]["vr"].asString()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3250 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3251 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3252 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3253 ParsedDicomFile dicom(true); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3254 dicom.InjectEmptyPixelData(ValueRepresentation_OtherWord); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3255 dicom.InjectEmptyPixelData(ValueRepresentation_OtherByte); // Must be ignored |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3256 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3257 DicomWebJsonVisitor visitor; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3258 dicom.Apply(visitor); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3259 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3260 ASSERT_TRUE(visitor.GetResult().isMember(PIXEL_DATA)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3261 ASSERT_EQ(2u, visitor.GetResult() [PIXEL_DATA].size()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3262 ASSERT_EQ("", visitor.GetResult() [PIXEL_DATA]["InlineBinary"].asString()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3263 ASSERT_EQ("OW", visitor.GetResult() [PIXEL_DATA]["vr"].asString()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3264 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3265 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3266 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3267 |
5319
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3268 TEST(ParsedDicomFile, RemoveFromPixelData) |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3269 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3270 ParsedDicomFile dicom(true); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3271 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DcmTag(0x7fe0, 0x0000), "").good()); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3272 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DcmTag(0x7fe0, 0x0009), "").good()); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3273 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertUint8Array(DcmTag(0x7fe0, 0x0010), NULL, 0).good()); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3274 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DcmTag(0x7fe0, 0x0011), "").good()); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3275 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString(DcmTag(0x7fe1, 0x0000), "").good()); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3276 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3277 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3278 DicomMap m; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3279 dicom.ExtractDicomSummary(m, 0); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3280 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3281 ASSERT_EQ(10u, m.GetSize()); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3282 ASSERT_TRUE(m.HasTag(DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3283 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3284 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3285 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3286 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3287 ASSERT_TRUE(m.HasTag(0x7fe0, 0x0000)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3288 ASSERT_TRUE(m.HasTag(0x7fe0, 0x0009)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3289 ASSERT_TRUE(m.HasTag(DICOM_TAG_PIXEL_DATA)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3290 ASSERT_TRUE(m.HasTag(0x7fe0, 0x0011)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3291 ASSERT_TRUE(m.HasTag(0x7fe1, 0x0000)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3292 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3293 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3294 dicom.RemoveFromPixelData(); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3295 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3296 { |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3297 DicomMap m; |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3298 dicom.ExtractDicomSummary(m, 0); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3299 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3300 ASSERT_EQ(7u, m.GetSize()); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3301 ASSERT_TRUE(m.HasTag(DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3302 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3303 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3304 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3305 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3306 ASSERT_TRUE(m.HasTag(0x7fe0, 0x0000)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3307 ASSERT_TRUE(m.HasTag(0x7fe0, 0x0009)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3308 ASSERT_FALSE(m.HasTag(DICOM_TAG_PIXEL_DATA)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3309 ASSERT_FALSE(m.HasTag(0x7fe0, 0x0011)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3310 ASSERT_FALSE(m.HasTag(0x7fe1, 0x0000)); |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3311 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3312 } |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3313 |
f2e1ad71e49c
added "OrthancPluginLoadDicomInstance()" to load DICOM instances from the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5318
diff
changeset
|
3314 |
5322
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3315 TEST(ParsedDicomFile, GuessPixelDataValueRepresentation) |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3316 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3317 typedef std::list< std::pair<E_TransferSyntax, DicomTransferSyntax> > Syntaxes; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3318 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3319 // Create a list of the main non-retired transfer syntaxes, from: |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3320 // https://www.dicomlibrary.com/dicom/transfer-syntax/ |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3321 Syntaxes compressedSyntaxes; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3322 compressedSyntaxes.push_back(std::make_pair(EXS_DeflatedLittleEndianExplicit, DicomTransferSyntax_DeflatedLittleEndianExplicit)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3323 compressedSyntaxes.push_back(std::make_pair(EXS_JPEGProcess1, DicomTransferSyntax_JPEGProcess1)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3324 compressedSyntaxes.push_back(std::make_pair(EXS_JPEGProcess2_4, DicomTransferSyntax_JPEGProcess2_4)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3325 compressedSyntaxes.push_back(std::make_pair(EXS_JPEGProcess14, DicomTransferSyntax_JPEGProcess14)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3326 compressedSyntaxes.push_back(std::make_pair(EXS_JPEGProcess14SV1, DicomTransferSyntax_JPEGProcess14SV1)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3327 compressedSyntaxes.push_back(std::make_pair(EXS_JPEGLSLossless, DicomTransferSyntax_JPEGLSLossless)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3328 compressedSyntaxes.push_back(std::make_pair(EXS_JPEGLSLossy, DicomTransferSyntax_JPEGLSLossy)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3329 compressedSyntaxes.push_back(std::make_pair(EXS_JPEG2000LosslessOnly, DicomTransferSyntax_JPEG2000LosslessOnly)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3330 compressedSyntaxes.push_back(std::make_pair(EXS_JPEG2000, DicomTransferSyntax_JPEG2000)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3331 compressedSyntaxes.push_back(std::make_pair(EXS_JPEG2000MulticomponentLosslessOnly, DicomTransferSyntax_JPEG2000MulticomponentLosslessOnly)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3332 compressedSyntaxes.push_back(std::make_pair(EXS_JPEG2000Multicomponent, DicomTransferSyntax_JPEG2000Multicomponent)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3333 compressedSyntaxes.push_back(std::make_pair(EXS_JPIPReferenced, DicomTransferSyntax_JPIPReferenced)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3334 compressedSyntaxes.push_back(std::make_pair(EXS_JPIPReferencedDeflate, DicomTransferSyntax_JPIPReferencedDeflate)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3335 compressedSyntaxes.push_back(std::make_pair(EXS_RLELossless, DicomTransferSyntax_RLELossless)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3336 compressedSyntaxes.push_back(std::make_pair(EXS_MPEG2MainProfileAtMainLevel, DicomTransferSyntax_MPEG2MainProfileAtMainLevel)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3337 compressedSyntaxes.push_back(std::make_pair(EXS_MPEG4HighProfileLevel4_1, DicomTransferSyntax_MPEG4HighProfileLevel4_1)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3338 compressedSyntaxes.push_back(std::make_pair(EXS_MPEG4BDcompatibleHighProfileLevel4_1, DicomTransferSyntax_MPEG4BDcompatibleHighProfileLevel4_1)); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3339 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3340 for (unsigned int i = 0; i < 3; i++) |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3341 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3342 unsigned int bitsAllocated; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3343 switch (i) |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3344 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3345 case 0: bitsAllocated = 1; break; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3346 case 1: bitsAllocated = 8; break; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3347 case 2: bitsAllocated = 16; break; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3348 default: |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3349 throw OrthancException(ErrorCode_InternalError); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3350 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3351 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3352 for (Syntaxes::const_iterator it = compressedSyntaxes.begin(); it != compressedSyntaxes.end(); ++it) |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3353 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3354 // All the compressed transfer syntaxes must have "OB" pixel data |
5323
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3355 ASSERT_EQ(ValueRepresentation_OtherByte, DicomImageInformation::GuessPixelDataValueRepresentation(it->second, bitsAllocated)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3356 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3357 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3358 DicomMap dicom; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3359 dicom.SetValue(DICOM_TAG_BITS_ALLOCATED, boost::lexical_cast<std::string>(bitsAllocated), false); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3360 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation(it->second)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3361 } |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3362 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3363 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3364 DicomMap dicom; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3365 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation(it->second)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3366 } |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3367 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3368 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3369 ParsedDicomFile dicom(true); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3370 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertUint16(DCM_BitsAllocated, bitsAllocated).good()); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3371 ASSERT_TRUE(dicom.GetDcmtkObject().chooseRepresentation(it->first, NULL).good()); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3372 dicom.GetDcmtkObject().removeAllButCurrentRepresentations(); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3373 DicomTransferSyntax ts; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3374 ASSERT_TRUE(dicom.LookupTransferSyntax(ts)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3375 ASSERT_EQ(ts, it->second); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3376 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation()); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3377 } |
5322
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3378 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3379 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3380 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3381 // Little endian implicit is always OW |
5323
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3382 ASSERT_EQ(ValueRepresentation_OtherWord, DicomImageInformation::GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianImplicit, bitsAllocated)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3383 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3384 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3385 DicomMap dicom; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3386 dicom.SetValue(DICOM_TAG_BITS_ALLOCATED, boost::lexical_cast<std::string>(bitsAllocated), false); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3387 ASSERT_EQ(ValueRepresentation_OtherWord, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianImplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3388 } |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3389 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3390 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3391 DicomMap dicom; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3392 ASSERT_EQ(ValueRepresentation_OtherWord, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianImplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3393 } |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3394 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3395 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3396 ParsedDicomFile dicom(true); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3397 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertUint16(DCM_BitsAllocated, bitsAllocated).good()); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3398 ASSERT_TRUE(dicom.GetDcmtkObject().chooseRepresentation(EXS_LittleEndianImplicit, NULL).good()); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3399 dicom.GetDcmtkObject().removeAllButCurrentRepresentations(); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3400 ASSERT_EQ(ValueRepresentation_OtherWord, dicom.GuessPixelDataValueRepresentation()); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3401 } |
5322
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3402 } |
5323
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3403 |
5322
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3404 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3405 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3406 // Explicit little and big endian with <= 8 bpp is OB |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3407 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3408 for (unsigned int i = 0; i < 2; i++) |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3409 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3410 unsigned int bitsAllocated; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3411 switch (i) |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3412 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3413 case 0: bitsAllocated = 1; break; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3414 case 1: bitsAllocated = 8; break; |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3415 default: |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3416 throw OrthancException(ErrorCode_InternalError); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3417 } |
5323
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3418 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3419 ASSERT_EQ(ValueRepresentation_OtherByte, DicomImageInformation::GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianExplicit, bitsAllocated)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3420 ASSERT_EQ(ValueRepresentation_OtherByte, DicomImageInformation::GuessPixelDataValueRepresentation(DicomTransferSyntax_BigEndianExplicit, bitsAllocated)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3421 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3422 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3423 DicomMap dicom; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3424 dicom.SetValue(DICOM_TAG_BITS_ALLOCATED, boost::lexical_cast<std::string>(bitsAllocated), false); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3425 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianExplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3426 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_BigEndianExplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3427 } |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3428 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3429 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3430 DicomMap dicom; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3431 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianExplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3432 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_BigEndianExplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3433 } |
5322
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3434 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3435 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3436 ParsedDicomFile dicom(true); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3437 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertUint16(DCM_BitsAllocated, bitsAllocated).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3438 ASSERT_TRUE(dicom.GetDcmtkObject().chooseRepresentation(EXS_LittleEndianExplicit, NULL).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3439 dicom.GetDcmtkObject().removeAllButCurrentRepresentations(); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3440 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3441 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3442 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3443 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3444 ParsedDicomFile dicom(true); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3445 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertUint16(DCM_BitsAllocated, bitsAllocated).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3446 ASSERT_TRUE(dicom.GetDcmtkObject().chooseRepresentation(EXS_BigEndianExplicit, NULL).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3447 dicom.GetDcmtkObject().removeAllButCurrentRepresentations(); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3448 ASSERT_EQ(ValueRepresentation_OtherByte, dicom.GuessPixelDataValueRepresentation()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3449 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3450 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3451 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3452 // Explicit little and big endian with > 8 bpp is OW |
5323
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3453 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3454 ASSERT_EQ(ValueRepresentation_OtherWord, DicomImageInformation::GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianExplicit, 16)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3455 ASSERT_EQ(ValueRepresentation_OtherWord, DicomImageInformation::GuessPixelDataValueRepresentation(DicomTransferSyntax_BigEndianExplicit, 16)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3456 |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3457 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3458 DicomMap dicom; |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3459 dicom.SetValue(DICOM_TAG_BITS_ALLOCATED, "16", false); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3460 ASSERT_EQ(ValueRepresentation_OtherWord, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_LittleEndianExplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3461 ASSERT_EQ(ValueRepresentation_OtherWord, dicom.GuessPixelDataValueRepresentation(DicomTransferSyntax_BigEndianExplicit)); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5322
diff
changeset
|
3462 } |
5322
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3463 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3464 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3465 ParsedDicomFile dicom(true); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3466 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertUint16(DCM_BitsAllocated, 16).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3467 ASSERT_TRUE(dicom.GetDcmtkObject().chooseRepresentation(EXS_LittleEndianExplicit, NULL).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3468 dicom.GetDcmtkObject().removeAllButCurrentRepresentations(); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3469 ASSERT_EQ(ValueRepresentation_OtherWord, dicom.GuessPixelDataValueRepresentation()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3470 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3471 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3472 { |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3473 ParsedDicomFile dicom(true); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3474 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertUint16(DCM_BitsAllocated, 16).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3475 ASSERT_TRUE(dicom.GetDcmtkObject().chooseRepresentation(EXS_BigEndianExplicit, NULL).good()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3476 dicom.GetDcmtkObject().removeAllButCurrentRepresentations(); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3477 ASSERT_EQ(ValueRepresentation_OtherWord, dicom.GuessPixelDataValueRepresentation()); |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3478 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3479 } |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3480 |
a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5319
diff
changeset
|
3481 |
5361 | 3482 #if ORTHANC_SANDBOXED != 1 |
5318
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3483 TEST(ParsedDicomFile, DISABLED_InjectEmptyPixelData2) |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3484 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3485 static const char* PIXEL_DATA = "7FE00010"; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3486 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3487 for (int i = 0; i <= DicomTransferSyntax_XML; i++) |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3488 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3489 DicomTransferSyntax a = (DicomTransferSyntax) i; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3490 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3491 std::string path = (std::string(getenv("HOME")) + |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3492 "/Subversion/orthanc-tests/Database/TransferSyntaxes/" + |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3493 std::string(GetTransferSyntaxUid(a)) + ".dcm"); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3494 if (Orthanc::SystemToolbox::IsRegularFile(path)) |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3495 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3496 printf("\n======= %s\n", GetTransferSyntaxUid(a)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3497 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3498 std::string source; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3499 Orthanc::SystemToolbox::ReadFile(source, path); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3500 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3501 ParsedDicomFile dicom(source); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3502 std::unique_ptr<DcmElement> removal(dicom.GetDcmtkObject().getDataset()->remove(DCM_PixelData)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3503 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3504 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3505 DicomWebJsonVisitor visitor; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3506 dicom.Apply(visitor); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3507 ASSERT_FALSE(visitor.GetResult().isMember(PIXEL_DATA)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3508 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3509 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3510 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3511 DicomWebJsonVisitor visitor; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3512 dicom.InjectEmptyPixelData(ValueRepresentation_OtherByte); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3513 dicom.Apply(visitor); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3514 ASSERT_TRUE(visitor.GetResult().isMember(PIXEL_DATA)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3515 ASSERT_EQ("OB", visitor.GetResult() [PIXEL_DATA]["vr"].asString()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3516 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3517 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3518 removal.reset(dicom.GetDcmtkObject().getDataset()->remove(DCM_PixelData)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3519 |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3520 { |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3521 DicomWebJsonVisitor visitor; |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3522 dicom.InjectEmptyPixelData(ValueRepresentation_OtherWord); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3523 dicom.Apply(visitor); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3524 ASSERT_TRUE(visitor.GetResult().isMember(PIXEL_DATA)); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3525 ASSERT_EQ("OW", visitor.GetResult() [PIXEL_DATA]["vr"].asString()); |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3526 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3527 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3528 } |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3529 } |
5361 | 3530 #endif |
5318
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3531 |
4777
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3532 |
3b78ba359db3
Support detection of windowing and rescale in Philips multiframe images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4771
diff
changeset
|
3533 |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
3534 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
3535 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
3536 #include "../Sources/DicomNetworking/DicomStoreUserConnection.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
3537 #include "../Sources/DicomParsing/DcmtkTranscoder.h" |
3882
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3880
diff
changeset
|
3538 |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3539 TEST(Toto, DISABLED_Transcode3) |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3540 { |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3541 DicomAssociationParameters p; |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3542 p.SetRemotePort(2000); |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3543 |
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
3544 DicomStoreUserConnection scu(p); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
3545 scu.SetCommonClassesProposed(false); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
3546 scu.SetRetiredBigEndianProposed(true); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
3547 |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3548 DcmtkTranscoder transcoder; |
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
3549 |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3550 for (int j = 0; j < 2; j++) |
5318
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3551 { |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3552 for (int i = 0; i <= DicomTransferSyntax_XML; i++) |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3553 { |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3554 DicomTransferSyntax a = (DicomTransferSyntax) i; |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3555 |
5318
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3556 std::string path = (std::string(getenv("HOME")) + |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3557 "/Subversion/orthanc-tests/Database/TransferSyntaxes/" + |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3558 std::string(GetTransferSyntaxUid(a)) + ".dcm"); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3559 if (Orthanc::SystemToolbox::IsRegularFile(path)) |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
3560 { |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3561 printf("\n======= %s\n", GetTransferSyntaxUid(a)); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3562 |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3563 std::string source; |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3564 Orthanc::SystemToolbox::ReadFile(source, path); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3565 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3566 std::string c, k; |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3567 try |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
3568 { |
4465
fe774d8e904b
New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
3569 scu.Transcode(c, k, transcoder, source.c_str(), source.size(), |
5442
ac68a4383e51
improved C-Store negotiation and logging
Alain Mazy <am@osimis.io>
parents:
5439
diff
changeset
|
3570 DicomTransferSyntax_LittleEndianExplicit, false, "", 0); |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
3571 } |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3572 catch (OrthancException& e) |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
3573 { |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3574 if (e.GetErrorCode() == ErrorCode_NotImplemented) |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3575 { |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3576 LOG(ERROR) << "cannot transcode " << GetTransferSyntaxUid(a); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3577 } |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3578 else |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3579 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3580 throw; |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
3581 } |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
3582 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
3583 } |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3584 } |
5318
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3585 } |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3586 } |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3587 |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
3588 |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3589 TEST(Toto, DISABLED_Transcode4) |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3590 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3591 std::unique_ptr<DcmFileFormat> toto; |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3592 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3593 { |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3594 std::string source; |
5318
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3595 Orthanc::SystemToolbox::ReadFile(source, std::string(getenv("HOME")) + |
68e15471b408
added ParsedDicomFile::InjectEmptyPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5291
diff
changeset
|
3596 "/Subversion/orthanc-tests/Database/KarstenHilbertRF.dcm"); |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3597 toto.reset(FromDcmtkBridge::LoadFromMemoryBuffer(source.c_str(), source.size())); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3598 } |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
3599 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
3600 const std::string sourceUid = IDicomTranscoder::GetSopInstanceUid(*toto); |
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
3601 |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3602 DicomTransferSyntax sourceSyntax; |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3603 ASSERT_TRUE(FromDcmtkBridge::LookupOrthancTransferSyntax(sourceSyntax, *toto)); |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3604 |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3605 DcmtkTranscoder transcoder; |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3606 |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3607 for (int i = 0; i <= DicomTransferSyntax_XML; i++) |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3608 { |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3609 DicomTransferSyntax a = (DicomTransferSyntax) i; |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
3610 |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
3611 std::set<DicomTransferSyntax> s; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
3612 s.insert(a); |
3888
e46b7a997f0a
IDicomTranscoder::TranscodeToBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3887
diff
changeset
|
3613 |
e46b7a997f0a
IDicomTranscoder::TranscodeToBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3887
diff
changeset
|
3614 std::string t; |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3615 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
3616 IDicomTranscoder::DicomImage source, target; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
3617 source.AcquireParsed(dynamic_cast<DcmFileFormat*>(toto->clone())); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
3618 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
3619 if (!transcoder.Transcode(target, source, s, true)) |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3620 { |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3621 printf("**************** CANNOT: [%s] => [%s]\n", |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3622 GetTransferSyntaxUid(sourceSyntax), GetTransferSyntaxUid(a)); |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3623 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3624 else |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3625 { |
3910 | 3626 DicomTransferSyntax targetSyntax; |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
3627 ASSERT_TRUE(FromDcmtkBridge::LookupOrthancTransferSyntax(targetSyntax, target.GetParsed())); |
3910 | 3628 |
3909
6762a97deabc
removed useless abstraction IDicomTranscoder::TranscodeToBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
3629 ASSERT_EQ(targetSyntax, a); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3630 bool lossy = (a == DicomTransferSyntax_JPEGProcess1 || |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3631 a == DicomTransferSyntax_JPEGProcess2_4 || |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3632 a == DicomTransferSyntax_JPEGLSLossy); |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3633 |
4158
32ac045109a6
fix compiler warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
3634 printf("SIZE: %d\n", static_cast<int>(t.size())); |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
3635 if (sourceUid == IDicomTranscoder::GetSopInstanceUid(target.GetParsed())) |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3636 { |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
3637 ASSERT_FALSE(lossy); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3638 } |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3639 else |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3640 { |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
3641 ASSERT_TRUE(lossy); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
3642 } |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3643 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3644 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3645 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
3646 |
3882
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3880
diff
changeset
|
3647 #endif |