Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp @ 4248:38b24aa98ed3
new lua sample: ClassifyUsingAet.lua
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 13 Oct 2020 15:36:48 +0200 |
parents | 4d42408da117 |
children | 50b0c69b653a |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3518
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * Lesser General Public License for more details. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
16 * |
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
|
17 * 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
|
18 * 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
|
19 * <http://www.gnu.org/licenses/>. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
20 **/ |
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 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
23 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
24 // 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
|
25 # include <OrthancFramework.h> |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
26 #endif |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
27 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
28 #if !defined(ORTHANC_ENABLE_DCMTK_TRANSCODING) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
29 # error ORTHANC_ENABLE_DCMTK_TRANSCODING is not defined |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
30 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
31 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
32 #if !defined(ORTHANC_ENABLE_PUGIXML) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
33 # error ORTHANC_ENABLE_PUGIXML is not defined |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
34 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
35 |
4062 | 36 #include <gtest/gtest.h> |
782 | 37 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
38 #include "../Sources/Compatibility.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
39 #include "../Sources/DicomNetworking/DicomFindAnswers.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
40 #include "../Sources/DicomParsing/DicomModification.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
41 #include "../Sources/DicomParsing/DicomWebJsonVisitor.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
42 #include "../Sources/DicomParsing/FromDcmtkBridge.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
43 #include "../Sources/DicomParsing/ToDcmtkBridge.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
44 #include "../Sources/Endianness.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
45 #include "../Sources/Images/Image.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
46 #include "../Sources/Images/ImageBuffer.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
47 #include "../Sources/Images/ImageProcessing.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
48 #include "../Sources/Images/PngReader.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
49 #include "../Sources/Images/PngWriter.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
50 #include "../Sources/OrthancException.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
51 #include "../Sources/SystemToolbox.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
52 #include "../Resources/CodeGeneration/EncodingTests.h" |
782 | 53 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
54 #include <dcmtk/dcmdata/dcdeftag.h> |
1690 | 55 #include <dcmtk/dcmdata/dcelem.h> |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
56 #include <dcmtk/dcmdata/dcvrat.h> |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
57 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
58 #include <boost/algorithm/string/predicate.hpp> |
1690 | 59 |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
60 #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
|
61 # include <pugixml.hpp> |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
62 # if !defined(PUGIXML_VERSION) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
63 # error PUGIXML_VERSION is not available |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
64 # endif |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
65 #endif |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
66 |
782 | 67 using namespace Orthanc; |
68 | |
69 TEST(DicomFormat, Tag) | |
70 { | |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2107
diff
changeset
|
71 ASSERT_EQ("PatientName", FromDcmtkBridge::GetTagName(DicomTag(0x0010, 0x0010), "")); |
782 | 72 |
73 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription"); | |
74 ASSERT_EQ(0x0008, t.GetGroup()); | |
75 ASSERT_EQ(0x103E, t.GetElement()); | |
76 | |
77 t = FromDcmtkBridge::ParseTag("0020-e040"); | |
78 ASSERT_EQ(0x0020, t.GetGroup()); | |
79 ASSERT_EQ(0xe040, t.GetElement()); | |
80 | |
81 // Test ==() and !=() operators | |
82 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020)); | |
83 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020)); | |
84 } | |
85 | |
86 | |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
87 TEST(DicomModification, Basic) |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
88 { |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
89 DicomModification m; |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
90 m.SetupAnonymization(DicomVersion_2008); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
91 //m.SetLevel(DicomRootLevel_Study); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
92 //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
|
93 //m.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "coucou"); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
94 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
95 ParsedDicomFile o(true); |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
96 o.SaveToFile("UnitTestsResults/anon.dcm"); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
97 |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
98 for (int i = 0; i < 10; i++) |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
99 { |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
100 char b[1024]; |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
101 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
|
102 std::unique_ptr<ParsedDicomFile> f(o.Clone(false)); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
103 if (i > 4) |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
104 o.ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, "coucou"); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
105 m.Apply(*f); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
106 f->SaveToFile(b); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
107 } |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
108 } |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
109 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
110 |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
111 TEST(DicomModification, Anonymization) |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
112 { |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
113 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
|
114 |
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
|
115 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
|
116 const DicomTag privateTag2(FromDcmtkBridge::ParseTag("0031-1020")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
117 ASSERT_TRUE(privateTag.IsPrivate()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
118 ASSERT_TRUE(privateTag2.IsPrivate()); |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
119 ASSERT_EQ(0x0031, privateTag2.GetGroup()); |
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
120 ASSERT_EQ(0x1020, privateTag2.GetElement()); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
121 |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
122 std::string s; |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
123 ParsedDicomFile o(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
124 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
|
125 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
|
126 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
|
127 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
|
128 ASSERT_STREQ("private tag", s.c_str()); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
129 |
1307
f796207e3df1
Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
142 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
|
143 ASSERT_FALSE(Toolbox::IsUuid(s)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
144 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
145 DicomModification m; |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
146 m.SetupAnonymization(DicomVersion_2008); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
147 m.Keep(privateTag); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
148 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
149 m.Apply(o); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
150 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
151 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
|
152 ASSERT_TRUE(Toolbox::IsUuid(s)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
153 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
|
154 ASSERT_STREQ("private tag", s.c_str()); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
155 |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
156 m.SetupAnonymization(DicomVersion_2008); |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
157 m.Apply(o); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
158 ASSERT_FALSE(o.GetTagValue(s, privateTag)); |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
159 } |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
160 |
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
161 |
802 | 162 #include <dcmtk/dcmdata/dcuid.h> |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
163 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
164 TEST(DicomModification, Png) |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
165 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
166 // 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
|
167 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
|
168 |
1641
4e56b5a206b7
Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
169 std::string m, cc; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
170 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
|
171 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
172 ASSERT_EQ("image/png", m); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
173 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
174 PngReader reader; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
175 reader.ReadFromMemory(cc); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
176 |
1492 | 177 ASSERT_EQ(5u, reader.GetHeight()); |
178 ASSERT_EQ(5u, reader.GetWidth()); | |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
179 ASSERT_EQ(PixelFormat_RGBA32, reader.GetFormat()); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
180 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
181 ParsedDicomFile o(true); |
1562 | 182 o.EmbedContent(s); |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
183 o.SaveToFile("UnitTestsResults/png1.dcm"); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
184 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
185 // Red dot, without alpha channel |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
186 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDTcIn2+8BgAAACJJREFUCNdj/P//PwMjIwME/P/P+J8BBTAxEOL/R9Lx/z8AynoKAXOeiV8AAAAASUVORK5CYII="; |
1562 | 187 o.EmbedContent(s); |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
188 o.SaveToFile("UnitTestsResults/png2.dcm"); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
189 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
190 // Check box in Graylevel8 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
191 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="; |
1562 | 192 o.EmbedContent(s); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
193 //o.ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, UID_DigitalXRayImageStorageForProcessing); |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
194 o.SaveToFile("UnitTestsResults/png3.dcm"); |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
195 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
196 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
197 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
198 // Gradient in Graylevel16 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
199 |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
200 ImageBuffer img; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
201 img.SetWidth(256); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
202 img.SetHeight(256); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
203 img.SetFormat(PixelFormat_Grayscale16); |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
204 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
205 ImageAccessor accessor; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
206 img.GetWriteableAccessor(accessor); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
207 |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1641
diff
changeset
|
208 uint16_t v = 0; |
800
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
209 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
|
210 { |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
211 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
|
212 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
|
213 { |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
214 *p = v; |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
215 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
216 } |
ecedd89055db
generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
217 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
218 o.EmbedImage(accessor); |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
802
diff
changeset
|
219 o.SaveToFile("UnitTestsResults/png4.dcm"); |
800
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 } |
1088
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
222 |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
223 |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
224 TEST(FromDcmtkBridge, Encodings1) |
1088
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
225 { |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
226 for (unsigned int i = 0; i < testEncodingsCount; i++) |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
227 { |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
228 std::string source(testEncodingsEncoded[i]); |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
229 std::string expected(testEncodingsExpected[i]); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
230 std::string s = Toolbox::ConvertToUtf8(source, testEncodings[i], false); |
1695 | 231 //std::cout << EnumerationToString(testEncodings[i]) << std::endl; |
1089 | 232 EXPECT_EQ(expected, s); |
1088
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
233 } |
6fd4434c1bcf
unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
234 } |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
235 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
236 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
237 TEST(FromDcmtkBridge, Enumerations) |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
238 { |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
239 // 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
|
240 Encoding e; |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
241 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
242 ASSERT_FALSE(GetDicomEncoding(e, "")); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
243 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
|
244 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
245 // 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
258 // 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
272 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-4 |
3219 | 273 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
|
274 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
|
275 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
|
276 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
|
277 |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
278 // 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
|
279 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
|
280 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
|
281 ASSERT_TRUE(GetDicomEncoding(e, "GBK")); ASSERT_EQ(Encoding_Chinese, e); |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
282 } |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
283 |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
284 |
1091 | 285 TEST(FromDcmtkBridge, Encodings3) |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
286 { |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
287 for (unsigned int i = 0; i < testEncodingsCount; i++) |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
288 { |
1695 | 289 //std::cout << EnumerationToString(testEncodings[i]) << std::endl; |
1091 | 290 std::string dicom; |
291 | |
292 { | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
293 ParsedDicomFile f(true); |
1091 | 294 f.SetEncoding(testEncodings[i]); |
1695 | 295 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
296 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
|
297 f.Insert(DICOM_TAG_PATIENT_NAME, s, false, ""); |
1091 | 298 f.SaveToMemoryBuffer(dicom); |
299 } | |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
300 |
1347 | 301 if (testEncodings[i] != Encoding_Windows1251) |
1091 | 302 { |
303 ParsedDicomFile g(dicom); | |
304 | |
305 if (testEncodings[i] != Encoding_Ascii) | |
306 { | |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
307 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
308 ASSERT_EQ(testEncodings[i], g.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
309 ASSERT_FALSE(hasCodeExtensions); |
1091 | 310 } |
311 | |
312 std::string tag; | |
313 ASSERT_TRUE(g.GetTagValue(tag, DICOM_TAG_PATIENT_NAME)); | |
314 ASSERT_EQ(std::string(testEncodingsExpected[i]), tag); | |
315 } | |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
316 } |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1089
diff
changeset
|
317 } |
1360 | 318 |
319 | |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
320 TEST(FromDcmtkBridge, ValueRepresentation) |
1360 | 321 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
322 ASSERT_EQ(ValueRepresentation_PersonName, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
323 FromDcmtkBridge::LookupValueRepresentation(DICOM_TAG_PATIENT_NAME)); |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
324 ASSERT_EQ(ValueRepresentation_Date, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
325 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0020) /* StudyDate */)); |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
326 ASSERT_EQ(ValueRepresentation_Time, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
327 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0030) /* StudyTime */)); |
1417
8e23f16a198d
fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
328 ASSERT_EQ(ValueRepresentation_DateTime, |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
329 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x002a) /* AcquisitionDateTime */)); |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
330 ASSERT_EQ(ValueRepresentation_NotSupported, |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
331 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
|
332 } |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
333 |
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
334 |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
335 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
336 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
|
337 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
|
338 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
339 static void CreateSampleJson(Json::Value& a) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
340 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
341 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
342 Json::Value b = Json::objectValue; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
343 b["PatientName"] = "Hello"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
344 b["PatientID"] = "World"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
345 b["StudyDescription"] = "Toto"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
346 a.append(b); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
347 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
348 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
349 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
350 Json::Value b = Json::objectValue; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
351 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
|
352 b["PatientID"] = "World2"; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
353 a.append(b); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
354 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
355 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
356 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
357 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
358 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
359 TEST(ParsedDicomFile, InsertReplaceStrings) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
360 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
361 ParsedDicomFile f(true); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
362 |
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
|
363 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
|
364 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
|
365 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
|
366 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
|
367 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
368 std::string s; |
3949
ef696db8426f
preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
369 ASSERT_TRUE(f.LookupTransferSyntax(s)); |
3974
bd0af2e11325
fix for big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
370 // The default transfer syntax depends on the OS endianness |
bd0af2e11325
fix for big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
371 ASSERT_TRUE(s == GetTransferSyntaxUid(DicomTransferSyntax_LittleEndianExplicit) || |
bd0af2e11325
fix for big-endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
372 s == GetTransferSyntaxUid(DicomTransferSyntax_BigEndianExplicit)); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
373 |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
374 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
|
375 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
|
376 f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession"), false, DicomReplaceMode_IgnoreIfAbsent, ""); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 ASSERT_EQ(s, "Accession3"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
387 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
388 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
|
389 ASSERT_EQ(s, "World"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
390 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
|
391 ASSERT_EQ(s, "Toto"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
392 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
|
393 ASSERT_EQ(s, "Toto"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
394 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
|
395 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
396 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
|
397 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
398 } |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
399 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
400 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
401 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
402 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
403 TEST(ParsedDicomFile, InsertReplaceJson) |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
404 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
405 ParsedDicomFile f(true); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
406 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
407 Json::Value a; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
408 CreateSampleJson(a); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
409 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
410 ASSERT_FALSE(f.HasTag(REFERENCED_STUDY_SEQUENCE)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
411 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
|
412 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
|
413 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
|
414 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
|
415 f.Remove(REFERENCED_STUDY_SEQUENCE); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
416 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
|
417 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
|
418 ASSERT_TRUE(f.HasTag(REFERENCED_STUDY_SEQUENCE)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
419 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 ASSERT_TRUE(f.HasTag(REFERENCED_PATIENT_SEQUENCE)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
427 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
428 { |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
429 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
|
430 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
|
431 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
432 Json::Value c; |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
433 Toolbox::SimplifyDicomAsJson(c, b, DicomToJsonFormat_Human); |
1693
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
434 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
435 ASSERT_EQ(0, c["ReferencedPatientSequence"].compare(a)); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
436 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
|
437 } |
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 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
|
440 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
|
441 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
|
442 |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
443 std::string s; |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
444 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
|
445 ASSERT_EQ(s, a.asString()); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
446 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
|
447 ASSERT_EQ(s, a.asString()); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
448 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
|
449 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
450 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
|
451 ASSERT_EQ(s, "Tata"); |
558b25228a23
creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1692
diff
changeset
|
452 } |
1695 | 453 |
454 | |
455 TEST(ParsedDicomFile, JsonEncoding) | |
456 { | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
457 ParsedDicomFile f(true); |
1695 | 458 |
459 for (unsigned int i = 0; i < testEncodingsCount; i++) | |
460 { | |
461 if (testEncodings[i] != Encoding_Windows1251) | |
462 { | |
463 //std::cout << EnumerationToString(testEncodings[i]) << std::endl; | |
464 f.SetEncoding(testEncodings[i]); | |
465 | |
466 if (testEncodings[i] != Encoding_Ascii) | |
467 { | |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
468 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
469 ASSERT_EQ(testEncodings[i], f.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
470 ASSERT_FALSE(hasCodeExtensions); |
1695 | 471 } |
472 | |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
473 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
|
474 f.Replace(DICOM_TAG_PATIENT_NAME, s, false, DicomReplaceMode_InsertIfAbsent, ""); |
1695 | 475 |
476 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
|
477 f.DatasetToJson(v, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0); |
1695 | 478 ASSERT_EQ(v["PatientName"].asString(), std::string(testEncodingsExpected[i])); |
479 } | |
480 } | |
481 } | |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
482 |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
483 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
484 TEST(ParsedDicomFile, ToJsonFlags1) |
1735
a001f6226c7c
primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
485 { |
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
|
486 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
|
487 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
|
488 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 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
|
493 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
494 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
|
495 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
496 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
497 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
498 ASSERT_FALSE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
499 ASSERT_FALSE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
500 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
501 ASSERT_EQ(Json::stringValue, v["7050,1000"].type()); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
502 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
|
503 |
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
|
504 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
|
505 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
506 ASSERT_EQ(7u, v.getMemberNames().size()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
507 ASSERT_FALSE(v.isMember("7052,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
508 ASSERT_TRUE(v.isMember("7050,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
509 ASSERT_TRUE(v.isMember("7053,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
510 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
511 ASSERT_EQ(Json::nullValue, v["7053,1000"].type()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
512 |
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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 |
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
|
520 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
|
521 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
522 ASSERT_EQ(7u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
523 ASSERT_FALSE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
524 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
525 ASSERT_TRUE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
526 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
527 std::string mime, content; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
528 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
|
529 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7053,1000"].asString())); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
530 ASSERT_EQ("application/octet-stream", mime); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
531 ASSERT_EQ("Some private tag", content); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
532 |
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
|
533 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
|
534 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
535 ASSERT_EQ(7u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
536 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
537 ASSERT_TRUE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
538 ASSERT_FALSE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
539 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
540 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
|
541 |
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
|
542 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
|
543 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
544 ASSERT_EQ(7u, v.getMemberNames().size()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
545 ASSERT_TRUE(v.isMember("7050,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
546 ASSERT_TRUE(v.isMember("7052,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
547 ASSERT_FALSE(v.isMember("7053,1000")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
548 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
549 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
|
550 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7052,1000"].asString())); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
551 ASSERT_EQ("application/octet-stream", mime); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
552 ASSERT_EQ("Some unknown tag", content); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
553 |
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
|
554 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
|
555 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
556 ASSERT_EQ(8u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
557 ASSERT_TRUE(v.isMember("7050,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
558 ASSERT_TRUE(v.isMember("7052,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
559 ASSERT_TRUE(v.isMember("7053,1000")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
560 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
561 ASSERT_EQ(Json::nullValue, v["7052,1000"].type()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
562 ASSERT_EQ(Json::nullValue, v["7053,1000"].type()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
563 } |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
564 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
565 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
566 TEST(ParsedDicomFile, ToJsonFlags2) |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
567 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
568 ParsedDicomFile f(true); |
3832
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
569 |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
570 { |
ab9a0d1e0cc1
Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3767
diff
changeset
|
571 // "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
|
572 // 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
|
573 // 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
|
574 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
|
575 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
|
576 } |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
577 |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
578 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
|
579 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
580 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
581 ASSERT_EQ(5u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
582 ASSERT_FALSE(v.isMember("7fe0,0010")); |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
583 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
584 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
|
585 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
586 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
587 ASSERT_TRUE(v.isMember("7fe0,0010")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
588 ASSERT_EQ(Json::nullValue, v["7fe0,0010"].type()); |
1736
b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1735
diff
changeset
|
589 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
590 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
|
591 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
592 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
593 ASSERT_TRUE(v.isMember("7fe0,0010")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
594 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
|
595 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
|
596 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2126
diff
changeset
|
597 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePixelData, 0); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
598 ASSERT_EQ(Json::objectValue, v.type()); |
1971
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
599 ASSERT_EQ(6u, v.getMemberNames().size()); |
1739
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
600 ASSERT_TRUE(v.isMember("7fe0,0010")); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
601 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type()); |
df331354cea2
include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1736
diff
changeset
|
602 std::string mime, content; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
603 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
|
604 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
|
605 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
|
606 } |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
607 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
608 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
609 TEST(DicomFindAnswers, Basic) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
610 { |
2059 | 611 DicomFindAnswers a(false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
612 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
613 { |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
614 DicomMap m; |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
615 m.SetValue(DICOM_TAG_PATIENT_ID, "hello", false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
616 a.Add(m); |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
617 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
618 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
619 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
620 ParsedDicomFile d(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
621 d.ReplacePlainString(DICOM_TAG_PATIENT_ID, "my"); |
1789 | 622 a.Add(d); |
623 } | |
624 | |
625 { | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
626 DicomMap m; |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
627 m.SetValue(DICOM_TAG_PATIENT_ID, "world", false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
628 a.Add(m); |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
629 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
630 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
631 Json::Value j; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
632 a.ToJson(j, true); |
1789 | 633 ASSERT_EQ(3u, j.size()); |
634 | |
635 //std::cout << j; | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
636 } |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
637 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
638 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
639 TEST(ParsedDicomFile, FromJson) |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
640 { |
2117 | 641 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7057, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag2", 1, 1, "ORTHANC"); |
642 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7059, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag3", 1, 1, ""); | |
643 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1000), ValueRepresentation_PersonName, "Declared public tag2", 1, 1, ""); | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
644 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
645 Json::Value v; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
646 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
|
647 |
2117 | 648 // Test the private creator |
649 ASSERT_EQ(DcmTag_ERROR_TagName, FromDcmtkBridge::GetTagName(DicomTag(0x7057, 0x1000), "NOPE")); | |
650 ASSERT_EQ("MyPrivateTag2", FromDcmtkBridge::GetTagName(DicomTag(0x7057, 0x1000), "ORTHANC")); | |
651 | |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
652 { |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
653 v["SOPClassUID"] = sopClassUid; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
654 v["SpecificCharacterSet"] = "ISO_IR 148"; // This is latin-5 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
655 v["PatientName"] = "Sébastien"; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
656 v["7050-1000"] = "Some public tag"; // Even group => public tag |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
657 v["7052-1000"] = "Some unknown tag"; // Even group => public, unknown tag |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
658 v["7057-1000"] = "Some private tag"; // Odd group => private tag |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
659 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
|
660 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
661 std::string s; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
662 Toolbox::EncodeDataUriScheme(s, "application/octet-stream", "Sebastien"); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
663 v["StudyDescription"] = s; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
664 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
665 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
|
666 v["0040,0100"] = Json::arrayValue; // ScheduledProcedureStepSequence |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
667 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
668 Json::Value vv; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
669 vv["Modality"] = "MR"; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
670 v["0040,0100"].append(vv); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
671 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
672 vv["Modality"] = "CT"; |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
673 v["0040,0100"].append(vv); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
674 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
675 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
676 const DicomToJsonFlags toJsonFlags = static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeBinary | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
677 DicomToJsonFlags_IncludePixelData | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
678 DicomToJsonFlags_IncludePrivateTags | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
679 DicomToJsonFlags_IncludeUnknownTags | |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
680 DicomToJsonFlags_ConvertBinaryToAscii); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
681 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
682 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
683 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
684 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
|
685 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers), "")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
686 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
687 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
|
688 dicom->DatasetToJson(vv, DicomToJsonFormat_Human, toJsonFlags, 0); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
689 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
690 ASSERT_EQ(vv["SOPClassUID"].asString(), sopClassUid); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
691 ASSERT_EQ(vv["MediaStorageSOPClassUID"].asString(), sopClassUid); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
692 ASSERT_TRUE(vv.isMember("SOPInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
693 ASSERT_TRUE(vv.isMember("SeriesInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
694 ASSERT_TRUE(vv.isMember("StudyInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
695 ASSERT_TRUE(vv.isMember("PatientID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
696 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
697 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
698 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
699 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
700 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
|
701 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers), "")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
702 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
703 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
|
704 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
|
705 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
706 std::string mime, content; |
1981
4b545a8b1f95
return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1971
diff
changeset
|
707 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, vv["PixelData"].asString())); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
708 ASSERT_EQ("application/octet-stream", mime); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
709 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
|
710 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
711 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
712 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
713 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
714 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
|
715 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_DecodeDataUriScheme), "")); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
716 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
717 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
|
718 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, toJsonFlags, 0); |
1818
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
719 |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
720 ASSERT_FALSE(vv.isMember("SOPInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
721 ASSERT_FALSE(vv.isMember("SeriesInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
722 ASSERT_FALSE(vv.isMember("StudyInstanceUID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
723 ASSERT_FALSE(vv.isMember("PatientID")); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
724 ASSERT_EQ(2u, vv["0040,0100"].size()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
725 ASSERT_EQ("MR", vv["0040,0100"][0]["0008,0060"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
726 ASSERT_EQ("CT", vv["0040,0100"][1]["0008,0060"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
727 ASSERT_EQ("Some public tag", vv["7050,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
728 ASSERT_EQ("Some unknown tag", vv["7052,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
729 ASSERT_EQ("Some private tag", vv["7057,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
730 ASSERT_EQ("Some private tag2", vv["7059,1000"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
731 ASSERT_EQ("Sébastien", vv["0010,0010"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
732 ASSERT_EQ("Sebastien", vv["0008,1030"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
733 ASSERT_EQ("ISO_IR 148", vv["0008,0005"].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
734 ASSERT_EQ("5", vv[DICOM_TAG_ROWS.Format()].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
735 ASSERT_EQ("5", vv[DICOM_TAG_COLUMNS.Format()].asString()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
736 ASSERT_TRUE(vv[DICOM_TAG_PIXEL_DATA.Format()].asString().empty()); |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
737 } |
1065401501fb
ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
738 } |
1937 | 739 |
740 | |
741 | |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
742 TEST(TestImages, PatternGrayscale8) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
743 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
744 static const char* PATH = "UnitTestsResults/PatternGrayscale8.dcm"; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
745 |
2107 | 746 Orthanc::Image image(Orthanc::PixelFormat_Grayscale8, 256, 256, false); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
747 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
748 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
749 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
750 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
751 for (int x = 0; x < 256; x++, p++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
752 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
753 *p = y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
754 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
755 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
756 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
757 Orthanc::ImageAccessor r; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
758 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
759 image.GetRegion(r, 32, 32, 64, 192); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
760 Orthanc::ImageProcessing::Set(r, 0); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
761 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
762 image.GetRegion(r, 160, 32, 64, 192); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
763 Orthanc::ImageProcessing::Set(r, 255); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
764 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
765 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
766 ParsedDicomFile f(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
767 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
|
768 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
|
769 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
|
770 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
|
771 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
|
772 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale8"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
773 f.EmbedImage(image); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
774 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
775 f.SaveToFile(PATH); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
776 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
777 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
778 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
779 std::string s; |
2140 | 780 Orthanc::SystemToolbox::ReadFile(s, PATH); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
781 Orthanc::ParsedDicomFile f(s); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
782 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
783 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
|
784 ASSERT_EQ(256u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
785 ASSERT_EQ(256u, decoded->GetHeight()); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
786 ASSERT_EQ(Orthanc::PixelFormat_Grayscale8, decoded->GetFormat()); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
787 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
788 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
789 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
790 const void* a = image.GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
791 const void* b = decoded->GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
792 ASSERT_EQ(0, memcmp(a, b, 256)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
793 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
794 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
795 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
796 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
797 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
798 TEST(TestImages, PatternRGB) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
799 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
800 static const char* PATH = "UnitTestsResults/PatternRGB24.dcm"; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
801 |
2107 | 802 Orthanc::Image image(Orthanc::PixelFormat_RGB24, 384, 256, false); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
803 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
804 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
805 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
806 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
807 for (int x = 0; x < 128; x++, p += 3) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
808 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
809 p[0] = y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
810 p[1] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
811 p[2] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
812 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
813 for (int x = 128; x < 128 * 2; x++, p += 3) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
814 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
815 p[0] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
816 p[1] = 255 - y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
817 p[2] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
818 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
819 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
|
820 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
821 p[0] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
822 p[1] = 0; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
823 p[2] = y; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
824 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
825 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
826 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
827 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
828 ParsedDicomFile f(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "RGB24"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
835 f.EmbedImage(image); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
836 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
837 f.SaveToFile(PATH); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
838 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
839 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
840 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
841 std::string s; |
2140 | 842 Orthanc::SystemToolbox::ReadFile(s, PATH); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
843 Orthanc::ParsedDicomFile f(s); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
844 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
845 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
|
846 ASSERT_EQ(384u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
847 ASSERT_EQ(256u, decoded->GetHeight()); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
848 ASSERT_EQ(Orthanc::PixelFormat_RGB24, decoded->GetFormat()); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
849 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
850 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
851 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
852 const void* a = image.GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
853 const void* b = decoded->GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
854 ASSERT_EQ(0, memcmp(a, b, 3 * 384)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
855 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
856 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
857 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
858 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
859 |
1940 | 860 TEST(TestImages, PatternUint16) |
1937 | 861 { |
1940 | 862 static const char* PATH = "UnitTestsResults/PatternGrayscale16.dcm"; |
863 | |
2107 | 864 Orthanc::Image image(Orthanc::PixelFormat_Grayscale16, 256, 256, false); |
1937 | 865 |
866 uint16_t v = 0; | |
867 for (int y = 0; y < 256; y++) | |
868 { | |
869 uint16_t *p = reinterpret_cast<uint16_t*>(image.GetRow(y)); | |
870 for (int x = 0; x < 256; x++, v++, p++) | |
871 { | |
1940 | 872 *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images |
1937 | 873 } |
874 } | |
875 | |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
876 Orthanc::ImageAccessor r; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
877 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
878 image.GetRegion(r, 32, 32, 64, 192); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
879 Orthanc::ImageProcessing::Set(r, 0); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
880 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
881 image.GetRegion(r, 160, 32, 64, 192); |
1940 | 882 Orthanc::ImageProcessing::Set(r, 65535); |
883 | |
884 { | |
885 ParsedDicomFile f(true); | |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
886 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
|
887 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
|
888 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
|
889 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
|
890 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
|
891 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale16"); |
1940 | 892 f.EmbedImage(image); |
893 | |
894 f.SaveToFile(PATH); | |
895 } | |
1937 | 896 |
1940 | 897 { |
898 std::string s; | |
2140 | 899 Orthanc::SystemToolbox::ReadFile(s, PATH); |
1940 | 900 Orthanc::ParsedDicomFile f(s); |
901 | |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
902 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
|
903 ASSERT_EQ(256u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
904 ASSERT_EQ(256u, decoded->GetHeight()); |
1940 | 905 ASSERT_EQ(Orthanc::PixelFormat_Grayscale16, decoded->GetFormat()); |
906 | |
907 for (int y = 0; y < 256; y++) | |
908 { | |
909 const void* a = image.GetConstRow(y); | |
910 const void* b = decoded->GetConstRow(y); | |
911 ASSERT_EQ(0, memcmp(a, b, 512)); | |
912 } | |
913 } | |
1937 | 914 } |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
915 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
916 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
917 TEST(TestImages, PatternInt16) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
918 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
919 static const char* PATH = "UnitTestsResults/PatternSignedGrayscale16.dcm"; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
920 |
2107 | 921 Orthanc::Image image(Orthanc::PixelFormat_SignedGrayscale16, 256, 256, false); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
922 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
923 int16_t v = -32768; |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
924 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
925 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
926 int16_t *p = reinterpret_cast<int16_t*>(image.GetRow(y)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
927 for (int x = 0; x < 256; x++, v++, p++) |
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 *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images |
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 |
2861
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
933 Orthanc::ImageAccessor r; |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
934 image.GetRegion(r, 32, 32, 64, 192); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
935 Orthanc::ImageProcessing::Set(r, -32768); |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
936 |
9b4251721f22
ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2521
diff
changeset
|
937 image.GetRegion(r, 160, 32, 64, 192); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
938 Orthanc::ImageProcessing::Set(r, 32767); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
939 |
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 ParsedDicomFile f(true); |
1982
b5d4f9c156ad
Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1981
diff
changeset
|
942 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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "SignedGrayscale16"); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
948 f.EmbedImage(image); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
949 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
950 f.SaveToFile(PATH); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
951 } |
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 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
954 std::string s; |
2140 | 955 Orthanc::SystemToolbox::ReadFile(s, PATH); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
956 Orthanc::ParsedDicomFile f(s); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
957 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
958 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
|
959 ASSERT_EQ(256u, decoded->GetWidth()); |
869a87c08673
fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1970
diff
changeset
|
960 ASSERT_EQ(256u, decoded->GetHeight()); |
1941
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
961 ASSERT_EQ(Orthanc::PixelFormat_SignedGrayscale16, decoded->GetFormat()); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
962 |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
963 for (int y = 0; y < 256; y++) |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
964 { |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
965 const void* a = image.GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
966 const void* b = decoded->GetConstRow(y); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
967 ASSERT_EQ(0, memcmp(a, b, 512)); |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
968 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
969 } |
d7b176f7dd1b
test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1940
diff
changeset
|
970 } |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
971 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
972 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
973 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
974 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
|
975 Encoding expected) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
976 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
977 const char* value = NULL; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
978 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
|
979 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
980 Encoding encoding; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
981 ASSERT_TRUE(GetDicomEncoding(encoding, value)); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
982 ASSERT_EQ(expected, encoding); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
983 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
984 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
985 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
986 TEST(ParsedDicomFile, DicomMapEncodings1) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
987 { |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
988 SetDefaultDicomEncoding(Encoding_Ascii); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2326
diff
changeset
|
989 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
|
990 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
991 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
992 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
|
993 ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
994 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
|
995 CheckEncoding(dicom, Encoding_Ascii); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
996 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
997 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
998 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
999 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
|
1000 ParsedDicomFile dicom(m, Encoding_Latin4, false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1001 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
|
1002 CheckEncoding(dicom, Encoding_Latin4); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1003 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1004 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1005 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1006 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1007 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
|
1008 ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1009 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
|
1010 CheckEncoding(dicom, Encoding_Latin5); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1011 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1012 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1013 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1014 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1015 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
|
1016 ParsedDicomFile dicom(m, Encoding_Latin1, false); |
2411
82d5e305fbd9
fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
1017 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
|
1018 CheckEncoding(dicom, Encoding_Latin5); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1019 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1020 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1021 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1022 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1023 TEST(ParsedDicomFile, DicomMapEncodings2) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1024 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1025 const char* utf8 = NULL; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1026 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
|
1027 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1028 if (testEncodings[i] == Encoding_Utf8) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1029 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1030 utf8 = testEncodingsEncoded[i]; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1031 break; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1032 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1033 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1034 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1035 ASSERT_TRUE(utf8 != NULL); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1036 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1037 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
|
1038 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1039 // 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
|
1040 if (testEncodings[i] != Encoding_Windows1251) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1041 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1042 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1043 // 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
|
1044 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
|
1045 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
|
1046 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
|
1047 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
|
1048 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1049 if (testEncodings[i] != Encoding_Chinese) |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1050 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1051 // 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
|
1052 // 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
|
1053 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1054 const std::string tmp = Toolbox::ConvertToUtf8( |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1055 Toolbox::ConvertFromUtf8(utf8, testEncodings[i]), testEncodings[i], false); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1056 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
|
1057 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1058 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1059 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1060 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1061 Json::Value v; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1062 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1063 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1064 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1065 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
|
1066 |
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
|
1067 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
|
1068 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1069 const char* encoded = NULL; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1070 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
|
1071 ASSERT_STREQ(testEncodingsEncoded[i], encoded); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1072 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1073 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
|
1074 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1075 Encoding encoding; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1076 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
|
1077 ASSERT_EQ(encoding, testEncodings[i]); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1078 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
|
1079 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1080 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1081 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1082 { |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1083 DicomMap m; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1084 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
|
1085 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
|
1086 |
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
|
1087 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
|
1088 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1089 Json::Value v2; |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1090 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
|
1091 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1092 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
|
1093 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
|
1094 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1095 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1096 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2142
diff
changeset
|
1097 } |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1098 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1099 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1100 TEST(ParsedDicomFile, ChangeEncoding) |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1101 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1102 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
|
1103 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1104 // 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
|
1105 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
|
1106 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1107 DicomMap m; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1108 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
|
1109 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1110 std::string tag; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1111 |
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
|
1112 ParsedDicomFile dicom(m, Encoding_Utf8, false); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1113 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1114 ASSERT_EQ(Encoding_Utf8, dicom.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1115 ASSERT_FALSE(hasCodeExtensions); |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1116 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
|
1117 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
|
1118 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1119 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1120 Json::Value v; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1121 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
|
1122 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
|
1123 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
|
1124 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1125 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1126 dicom.ChangeEncoding(testEncodings[i]); |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1127 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1128 ASSERT_EQ(testEncodings[i], dicom.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1129 ASSERT_FALSE(hasCodeExtensions); |
2207
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1130 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1131 const char* c = NULL; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1132 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
|
1133 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
|
1134 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1135 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
|
1136 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
|
1137 |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1138 { |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1139 Json::Value v; |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1140 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
|
1141 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
|
1142 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
|
1143 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1144 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1145 } |
6dc3bdb4088b
Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1146 } |
2326
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1147 |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1148 |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1149 TEST(Toolbox, CaseWithAccents) |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1150 { |
423d3b692bb9
Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
1151 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
|
1152 } |
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
|
1153 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1154 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1155 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1156 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
|
1157 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1158 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1159 // 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
|
1160 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
|
1161 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
|
1162 |
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
|
1163 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
|
1164 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1165 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1166 ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1167 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
|
1168 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1169 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1170 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1171 // 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
|
1172 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
|
1173 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
|
1174 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
|
1175 |
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
|
1176 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
|
1177 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1178 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1179 ASSERT_EQ(Encoding_Japanese, d.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1180 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
|
1181 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1182 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1183 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1184 // 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
|
1185 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
|
1186 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
|
1187 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
|
1188 |
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
|
1189 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
|
1190 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
|
1191 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1192 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1193 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1194 // 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
|
1195 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
|
1196 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
|
1197 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
|
1198 |
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
|
1199 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
|
1200 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
|
1201 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1202 |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1203 { |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1204 // 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
|
1205 // 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
|
1206 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
|
1207 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
|
1208 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
|
1209 |
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
|
1210 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
|
1211 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1212 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1213 ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1214 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
|
1215 } |
6e5bc5c6d1a4
Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2411
diff
changeset
|
1216 } |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1217 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1218 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1219 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1220 TEST(Toolbox, RemoveIso2022EscapeSequences) |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1221 { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1222 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1223 // | one-byte control messages | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1224 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1225 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1226 static const uint8_t iso2022_cstr_oneByteControl[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1227 0x0f, 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1228 0x0e, 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1229 0x8e, 0x1b, 0x4e, 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1230 0x8f, 0x1b, 0x4f, 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1231 0x8e, 0x1b, 0x4a, 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1232 0x8f, 0x1b, 0x4a, 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1233 0x50, 0x51, 0x52, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1234 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1235 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1236 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
|
1237 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1238 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1239 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1240 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1241 0x8e, 0x1b, 0x4a, 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1242 0x8f, 0x1b, 0x4a, 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1243 0x50, 0x51, 0x52, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1244 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1245 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1246 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1247 // | two-byte control messages | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1248 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1249 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1250 static const uint8_t iso2022_cstr_twoByteControl[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1251 0x1b, 0x6e, 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1252 0x1b, 0x6f, 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1253 0x1b, 0x4e, 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1254 0x1b, 0x4f, 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1255 0x1b, 0x7e, 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1256 0x1b, 0x7d, 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1257 0x1b, 0x7c, 0x47, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1258 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1259 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1260 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
|
1261 0x41, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1262 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1263 0x43, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1264 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1265 0x45, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1266 0x46, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1267 0x47, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1268 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1269 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1270 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1271 // | various-length escape sequences | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1272 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1273 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1274 static const uint8_t iso2022_cstr_escapeSequence[] = { |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1275 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
|
1276 0x1b, 0x50, 0x42, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1277 0x1b, 0x7f, 0x43, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1278 0x1b, 0x21, 0x4a, 0x44, // this will match |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1279 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
|
1280 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
|
1281 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
|
1282 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1283 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1284 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
|
1285 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
|
1286 0x1b, 0x50, 0x42, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1287 0x1b, 0x7f, 0x43, // ditto |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1288 0x44, // this will match |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1289 0x45, // this will match |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1290 0x46, // this will match too |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1291 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
|
1292 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1293 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1294 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1295 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1296 // | a real-world japanese sample | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1297 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1298 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1299 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
|
1300 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
|
1301 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
|
1302 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
|
1303 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
|
1304 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
|
1305 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
|
1306 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
|
1307 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1308 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1309 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
|
1310 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
|
1311 0x3d, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1312 0x3b, 0x33, 0x45, 0x44, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1313 0x5e, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1314 0x42, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1315 0x40, 0x4f, 0x3a, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1316 0x3d, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1317 0x24, 0x64, 0x24, 0x5e, 0x24, 0x40, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1318 0x5e, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1319 0x24, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1320 0x3f, 0x24, 0x6d, 0x24, 0x26, 0x00 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1321 }; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1322 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1323 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1324 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1325 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1326 // | the actual test | |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1327 // +----------------------------------+ |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1328 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1329 std::string iso2022_str_oneByteControl( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1330 reinterpret_cast<const char*>(iso2022_cstr_oneByteControl)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1331 std::string iso2022_str_oneByteControl_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1332 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
|
1333 std::string iso2022_str_twoByteControl( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1334 reinterpret_cast<const char*>(iso2022_cstr_twoByteControl)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1335 std::string iso2022_str_twoByteControl_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1336 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
|
1337 std::string iso2022_str_escapeSequence( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1338 reinterpret_cast<const char*>(iso2022_cstr_escapeSequence)); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1339 std::string iso2022_str_escapeSequence_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1340 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
|
1341 std::string iso2022_str_real_ir13( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1342 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
|
1343 std::string iso2022_str_real_ir13_ref( |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1344 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
|
1345 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1346 std::string dest; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1347 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1348 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_oneByteControl); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1349 ASSERT_EQ(dest, iso2022_str_oneByteControl_ref); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1350 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1351 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_twoByteControl); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1352 ASSERT_EQ(dest, iso2022_str_twoByteControl_ref); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1353 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1354 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_escapeSequence); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1355 ASSERT_EQ(dest, iso2022_str_escapeSequence_ref); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1356 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1357 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_real_ir13); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3083
diff
changeset
|
1358 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
|
1359 } |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1360 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1361 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1362 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1363 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
|
1364 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1365 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
|
1366 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
|
1367 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1368 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
|
1369 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
|
1370 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1371 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
|
1372 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1373 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
|
1374 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
|
1375 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1376 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
|
1377 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1378 throw; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1379 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1380 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1381 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
|
1382 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
|
1383 if (a < 0 || a > 15 || |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1384 b < 0 || b > 15 || |
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1385 (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
|
1386 { |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1387 throw; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1388 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1389 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1390 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
|
1391 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1392 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1393 return result; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1394 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1395 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1396 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1397 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1398 // Compatibility wrapper |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1399 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
|
1400 const char* xpath) |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1401 { |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1402 #if PUGIXML_VERSION <= 140 |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1403 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
|
1404 #else |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1405 return doc.select_node(xpath); |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1406 #endif |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1407 } |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1408 |
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1409 |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1410 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
|
1411 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1412 // 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
|
1413 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1414 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
|
1415 "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
|
1416 "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
|
1417 "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
|
1418 "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
|
1419 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1420 // 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
|
1421 // 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
|
1422 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
|
1423 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
|
1424 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
|
1425 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
|
1426 }; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1427 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1428 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
|
1429 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1430 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
|
1431 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
|
1432 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1433 (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
|
1434 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1435 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1436 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1437 ASSERT_EQ(Encoding_Korean, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1438 ASSERT_TRUE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1439 |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1440 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
|
1441 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
|
1442 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
|
1443 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1444 DicomWebJsonVisitor visitor; |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1445 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
|
1446 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
|
1447 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
|
1448 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
|
1449 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1450 #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
|
1451 // 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
|
1452 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
|
1453 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
|
1454 |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1455 pugi::xml_document doc; |
3222 | 1456 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
|
1457 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1458 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
|
1459 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
|
1460 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1461 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
|
1462 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
|
1463 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1464 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
|
1465 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
|
1466 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1467 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
|
1468 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
|
1469 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1470 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
|
1471 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
|
1472 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1473 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
|
1474 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
|
1475 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1476 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
|
1477 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
|
1478 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1479 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
|
1480 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
|
1481 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1482 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
|
1483 ASSERT_EQ(utf8.substr(28), node.node().text().as_string()); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1484 #endif |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1485 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1486 { |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1487 DicomMap m; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1488 m.FromDicomWeb(visitor.GetResult()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1489 ASSERT_EQ(2u, m.GetSize()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1490 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1491 std::string s; |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1492 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
|
1493 ASSERT_EQ("ISO 2022 IR 149", s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1494 |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1495 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1496 std::vector<std::string> v; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1497 Toolbox::TokenizeString(v, s, '='); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1498 ASSERT_EQ(3u, v.size()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1499 ASSERT_EQ("Hong^Gildong", v[0]); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1500 ASSERT_EQ(utf8, s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1501 } |
3221
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1502 } |
4be505c2ac56
Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3219
diff
changeset
|
1503 |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1504 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1505 TEST(Toolbox, EncodingsJapaneseKanji) |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1506 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1507 // 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
|
1508 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1509 std::string japanese = DecodeFromSpecification( |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1510 "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
|
1511 "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
|
1512 "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
|
1513 "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
|
1514 "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
|
1515 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1516 // This array can be re-generated using command-line: |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1517 // 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
|
1518 static const uint8_t utf8raw[] = { |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1519 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
|
1520 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
|
1521 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
|
1522 0x8d, 0xe3, 0x81, 0x86 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1523 }; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1524 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1525 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw)); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1526 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1527 ParsedDicomFile dicom(false); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1528 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
|
1529 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1530 (DCM_PatientName, japanese.c_str(), OFBool(true)).good()); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1531 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1532 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1533 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1534 ASSERT_EQ(Encoding_JapaneseKanji, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1535 ASSERT_TRUE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1536 |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1537 std::string value; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1538 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1539 ASSERT_EQ(utf8, value); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1540 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1541 DicomWebJsonVisitor visitor; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1542 dicom.Apply(visitor); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1543 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
|
1544 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
|
1545 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
|
1546 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1547 #if ORTHANC_ENABLE_PUGIXML == 1 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1548 // 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
|
1549 std::string xml; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1550 visitor.FormatXml(xml); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1551 |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1552 pugi::xml_document doc; |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1553 doc.load_buffer(xml.c_str(), xml.size()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1554 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1555 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
|
1556 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
|
1557 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1558 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1559 ASSERT_STREQ("CS", node.node().attribute("vr").value()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1560 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1561 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1562 ASSERT_STREQ("PN", node.node().attribute("vr").value()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1563 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1564 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
|
1565 ASSERT_STREQ("Yamada", node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1566 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1567 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
|
1568 ASSERT_STREQ("Tarou", node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1569 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1570 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
|
1571 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
|
1572 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1573 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
|
1574 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
|
1575 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1576 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
|
1577 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
|
1578 |
3311
f2f8aa6f78aa
compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3298
diff
changeset
|
1579 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
|
1580 ASSERT_EQ(utf8.substr(37), node.node().text().as_string()); |
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1581 #endif |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1582 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1583 { |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1584 DicomMap m; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1585 m.FromDicomWeb(visitor.GetResult()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1586 ASSERT_EQ(2u, m.GetSize()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1587 |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1588 std::string s; |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1589 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
|
1590 ASSERT_EQ("ISO 2022 IR 87", s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1591 |
3518
a57c8163d9ae
DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3496
diff
changeset
|
1592 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); |
3496
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1593 std::vector<std::string> v; |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1594 Toolbox::TokenizeString(v, s, '='); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1595 ASSERT_EQ(3u, v.size()); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1596 ASSERT_EQ("Yamada^Tarou", v[0]); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1597 ASSERT_EQ(utf8, s); |
109631ed3564
DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3420
diff
changeset
|
1598 } |
3223
c94f23198946
unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3222
diff
changeset
|
1599 } |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1600 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1601 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1602 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1603 TEST(Toolbox, EncodingsChinese3) |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1604 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1605 // 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
|
1606 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1607 static const uint8_t chinese[] = { |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1608 0x57, 0x61, 0x6e, 0x67, 0x5e, 0x58, 0x69, 0x61, 0x6f, 0x44, 0x6f, |
3229 | 1609 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
|
1610 }; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1611 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1612 ParsedDicomFile dicom(false); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1613 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1614 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1615 (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
|
1616 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1617 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1618 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1619 ASSERT_EQ(Encoding_Chinese, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1620 ASSERT_FALSE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1621 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1622 std::string value; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1623 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1624 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1625 std::vector<std::string> tokens; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1626 Orthanc::Toolbox::TokenizeString(tokens, value, '='); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1627 ASSERT_EQ(3u, tokens.size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1628 ASSERT_EQ("Wang^XiaoDong", tokens[0]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1629 ASSERT_TRUE(tokens[2].empty()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1630 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1631 std::vector<std::string> middle; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1632 Orthanc::Toolbox::TokenizeString(middle, tokens[1], '^'); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1633 ASSERT_EQ(2u, middle.size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1634 ASSERT_EQ(3u, middle[0].size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1635 ASSERT_EQ(6u, middle[1].size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1636 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1637 // CDF5 in GB18030 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1638 ASSERT_EQ(static_cast<char>(0xe7), middle[0][0]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1639 ASSERT_EQ(static_cast<char>(0x8e), middle[0][1]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1640 ASSERT_EQ(static_cast<char>(0x8b), middle[0][2]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1641 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1642 // D0A1 in GB18030 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1643 ASSERT_EQ(static_cast<char>(0xe5), middle[1][0]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1644 ASSERT_EQ(static_cast<char>(0xb0), middle[1][1]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1645 ASSERT_EQ(static_cast<char>(0x8f), middle[1][2]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1646 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1647 // B6AB in GB18030 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1648 ASSERT_EQ(static_cast<char>(0xe4), middle[1][3]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1649 ASSERT_EQ(static_cast<char>(0xb8), middle[1][4]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1650 ASSERT_EQ(static_cast<char>(0x9c), middle[1][5]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1651 } |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1652 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1653 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1654 TEST(Toolbox, EncodingsChinese4) |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1655 { |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1656 // 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
|
1657 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1658 static const uint8_t chinese[] = { |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1659 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
|
1660 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
|
1661 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
|
1662 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
|
1663 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
|
1664 0x0a, 0x54, 0x68, 0x65, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x20, 0x6c, 0x69, |
3229 | 1665 0x6e, 0x65, 0x2e, 0x0d, 0x0a, 0x00 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1666 }; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1667 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1668 static const uint8_t patternRaw[] = { |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1669 0xe4, 0xb8, 0xad, 0xe6, 0x96, 0x87 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1670 }; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1671 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1672 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
|
1673 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1674 ParsedDicomFile dicom(false); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1675 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1676 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1677 (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
|
1678 |
3225
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1679 bool hasCodeExtensions; |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1680 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1681 ASSERT_EQ(Encoding_Chinese, encoding); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1682 ASSERT_FALSE(hasCodeExtensions); |
c85510b5f21d
unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3224
diff
changeset
|
1683 |
3224
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1684 std::string value; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1685 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_COMMENTS)); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1686 |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1687 std::vector<std::string> lines; |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1688 Orthanc::Toolbox::TokenizeString(lines, value, '\n'); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1689 ASSERT_EQ(4u, lines.size()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1690 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
|
1691 ASSERT_TRUE(boost::ends_with(lines[0], ".\r")); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1692 ASSERT_TRUE(lines[0].find(pattern) != std::string::npos); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1693 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
|
1694 ASSERT_TRUE(boost::ends_with(lines[1], ", too.\r")); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1695 ASSERT_TRUE(lines[1].find(pattern) != std::string::npos); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1696 ASSERT_EQ("The third line.\r", lines[2]); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1697 ASSERT_FALSE(lines[1].find(pattern) == std::string::npos); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1698 ASSERT_TRUE(lines[3].empty()); |
6399f5f25498
unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3223
diff
changeset
|
1699 } |
3226
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1700 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1701 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1702 TEST(Toolbox, EncodingsSimplifiedChinese2) |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1703 { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1704 // 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
|
1705 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1706 static const uint8_t chinese[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1707 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
|
1708 0x6e, 0x67, 0x3d, 0x1b, 0x24, 0x29, 0x41, 0xd5, 0xc5, 0x5e, 0x1b, 0x24, |
3229 | 1709 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
|
1710 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1711 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1712 // 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
|
1713 static const uint8_t utf8[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1714 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
|
1715 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
|
1716 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1717 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1718 ParsedDicomFile dicom(false); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1719 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
|
1720 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1721 (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
|
1722 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1723 bool hasCodeExtensions; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1724 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1725 ASSERT_EQ(Encoding_SimplifiedChinese, encoding); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1726 ASSERT_TRUE(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1727 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1728 std::string value; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1729 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1730 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
|
1731 } |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1732 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1733 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1734 TEST(Toolbox, EncodingsSimplifiedChinese3) |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1735 { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1736 // 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
|
1737 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1738 static const uint8_t chinese[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1739 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
|
1740 0x32, 0x2e, 0x1b, 0x24, 0x29, 0x41, 0xb5, 0xda, 0xb6, 0xfe, 0xd0, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xa1, 0xa3, 0x0d, 0x0a, |
3229 | 1741 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
|
1742 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1743 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1744 static const uint8_t line1[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1745 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
|
1746 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r' |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1747 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1748 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1749 static const uint8_t line2[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1750 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
|
1751 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r' |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1752 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1753 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1754 static const uint8_t line3[] = { |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1755 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
|
1756 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r' |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1757 }; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1758 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1759 ParsedDicomFile dicom(false); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1760 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
|
1761 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
3228
4b9cfd92d1ae
preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3226
diff
changeset
|
1762 (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
|
1763 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1764 bool hasCodeExtensions; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1765 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1766 ASSERT_EQ(Encoding_SimplifiedChinese, encoding); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1767 ASSERT_TRUE(hasCodeExtensions); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1768 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1769 std::string value; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1770 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1771 |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1772 std::vector<std::string> lines; |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1773 Toolbox::TokenizeString(lines, value, '\n'); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1774 ASSERT_EQ(4u, lines.size()); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1775 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
|
1776 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
|
1777 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
|
1778 ASSERT_TRUE(lines[3].empty()); |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1779 } |
45e1631febbb
support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3225
diff
changeset
|
1780 |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
1781 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1782 static void SetTagKey(ParsedDicomFile& dicom, |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1783 const DicomTag& tag, |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1784 const DicomTag& value) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1785 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1786 // This function emulates a call to function |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1787 // "dicom.GetDcmtkObject().getDataset()->putAndInsertTagKey(tag, |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1788 // 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
|
1789 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1790 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
|
1791 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1792 DcmTagKey v = ToDcmtkBridge::Convert(value); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1793 if (!element->putTagVal(v).good()) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1794 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1795 throw OrthancException(ErrorCode_InternalError); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1796 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1797 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1798 dicom.GetDcmtkObject().getDataset()->insert(element.release()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1799 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1800 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1801 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1802 TEST(DicomWebJson, ValueRepresentation) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1803 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1804 // 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
|
1805 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1806 ParsedDicomFile dicom(false); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1807 dicom.ReplacePlainString(DicomTag(0x0040, 0x0241), "AE"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1808 dicom.ReplacePlainString(DicomTag(0x0010, 0x1010), "AS"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1809 SetTagKey(dicom, DicomTag(0x0020, 0x9165), DicomTag(0x0010, 0x0020)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1810 dicom.ReplacePlainString(DicomTag(0x0008, 0x0052), "CS"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1811 dicom.ReplacePlainString(DicomTag(0x0008, 0x0012), "DA"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1812 dicom.ReplacePlainString(DicomTag(0x0010, 0x1020), "42"); // DS |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1813 dicom.ReplacePlainString(DicomTag(0x0008, 0x002a), "DT"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1814 dicom.ReplacePlainString(DicomTag(0x0010, 0x9431), "43"); // FL |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1815 dicom.ReplacePlainString(DicomTag(0x0008, 0x1163), "44"); // FD |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1816 dicom.ReplacePlainString(DicomTag(0x0008, 0x1160), "45"); // IS |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1817 dicom.ReplacePlainString(DicomTag(0x0008, 0x0070), "LO"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1818 dicom.ReplacePlainString(DicomTag(0x0010, 0x4000), "LT"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1819 dicom.ReplacePlainString(DicomTag(0x0028, 0x2000), "OB"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1820 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
|
1821 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
|
1822 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
|
1823 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
|
1824 dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "OWOW"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1825 dicom.ReplacePlainString(DicomTag(0x0010, 0x0010), "PN"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1826 dicom.ReplacePlainString(DicomTag(0x0008, 0x0050), "SH"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1827 dicom.ReplacePlainString(DicomTag(0x0018, 0x6020), "-15"); // SL |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1828 dicom.ReplacePlainString(DicomTag(0x0018, 0x9219), "-16"); // SS |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1829 dicom.ReplacePlainString(DicomTag(0x0008, 0x0081), "ST"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1830 dicom.ReplacePlainString(DicomTag(0x0008, 0x0013), "TM"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1831 dicom.ReplacePlainString(DicomTag(0x0008, 0x0119), "UC"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1832 dicom.ReplacePlainString(DicomTag(0x0008, 0x0016), "UI"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1833 dicom.ReplacePlainString(DicomTag(0x0008, 0x1161), "128"); // UL |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1834 dicom.ReplacePlainString(DicomTag(0x4342, 0x1234), "UN"); // Inexistent tag |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1835 dicom.ReplacePlainString(DicomTag(0x0008, 0x0120), "UR"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1836 dicom.ReplacePlainString(DicomTag(0x0008, 0x0301), "17"); // US |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1837 dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT"); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1838 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1839 DicomWebJsonVisitor visitor; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1840 dicom.Apply(visitor); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1841 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1842 std::string s; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1843 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1844 // 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
|
1845 // automatically copied by DCMTK from tag (0008,0016) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1846 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1847 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
|
1848 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1849 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
|
1850 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1851 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
|
1852 ASSERT_EQ("AT", visitor.GetResult() ["00209165"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1853 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
|
1854 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1855 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
|
1856 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1857 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
|
1858 ASSERT_EQ("DS", visitor.GetResult() ["00101020"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1859 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
|
1860 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1861 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
|
1862 ASSERT_EQ("FL", visitor.GetResult() ["00109431"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1863 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
|
1864 ASSERT_EQ("FD", visitor.GetResult() ["00081163"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1865 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
|
1866 ASSERT_EQ("IS", visitor.GetResult() ["00081160"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1867 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
|
1868 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1869 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
|
1870 ASSERT_EQ("LT", visitor.GetResult() ["00104000"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1871 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
|
1872 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1873 ASSERT_EQ("OB", visitor.GetResult() ["00282000"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1874 Toolbox::DecodeBase64(s, visitor.GetResult() ["00282000"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1875 ASSERT_EQ("OB", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1876 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1877 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1878 ASSERT_EQ("OD", visitor.GetResult() ["7FE00009"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1879 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
|
1880 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1881 ASSERT_EQ("UN", visitor.GetResult() ["7FE00009"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1882 Toolbox::DecodeBase64(s, visitor.GetResult() ["7FE00009"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1883 ASSERT_EQ(8u, s.size()); // Because of padding |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1884 ASSERT_EQ(0, s[7]); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1885 ASSERT_EQ("3.14159", s.substr(0, 7)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1886 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1887 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1888 ASSERT_EQ("OF", visitor.GetResult() ["00640009"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1889 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
|
1890 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1891 #if DCMTK_VERSION_NUMBER < 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1892 ASSERT_EQ("UN", visitor.GetResult() ["00660040"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1893 Toolbox::DecodeBase64(s, visitor.GetResult() ["00660040"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1894 ASSERT_EQ("46", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1895 #elif DCMTK_VERSION_NUMBER == 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1896 ASSERT_EQ("UL", visitor.GetResult() ["00660040"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1897 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
|
1898 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1899 ASSERT_EQ("OL", visitor.GetResult() ["00660040"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1900 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
|
1901 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1902 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1903 ASSERT_EQ("OW", visitor.GetResult() ["00281201"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1904 Toolbox::DecodeBase64(s, visitor.GetResult() ["00281201"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1905 ASSERT_EQ("OWOW", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1906 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1907 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1908 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
|
1909 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1910 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1911 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
|
1912 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1913 ASSERT_EQ("SL", visitor.GetResult() ["00186020"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1914 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
|
1915 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1916 ASSERT_EQ("SS", visitor.GetResult() ["00189219"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1917 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
|
1918 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1919 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1920 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
|
1921 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1922 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1923 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
|
1924 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1925 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1926 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1927 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
|
1928 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1929 ASSERT_EQ("UN", visitor.GetResult() ["00080119"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1930 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080119"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1931 ASSERT_EQ("UC", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1932 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1933 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1934 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1935 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
|
1936 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1937 ASSERT_EQ("UL", visitor.GetResult() ["00081161"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1938 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
|
1939 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1940 ASSERT_EQ("UN", visitor.GetResult() ["43421234"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1941 Toolbox::DecodeBase64(s, visitor.GetResult() ["43421234"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1942 ASSERT_EQ("UN", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1943 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1944 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1945 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1946 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
|
1947 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1948 ASSERT_EQ("UN", visitor.GetResult() ["00080120"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1949 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080120"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1950 ASSERT_EQ("UR", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1951 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1952 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1953 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1954 ASSERT_EQ("US", visitor.GetResult() ["00080301"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1955 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
|
1956 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1957 ASSERT_EQ("UN", visitor.GetResult() ["00080301"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1958 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080301"]["InlineBinary"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1959 ASSERT_EQ("17", s); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1960 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1961 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1962 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1963 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
|
1964 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1965 std::string xml; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1966 visitor.FormatXml(xml); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1967 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1968 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1969 DicomMap m; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1970 m.FromDicomWeb(visitor.GetResult()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1971 ASSERT_EQ(31u, m.GetSize()); |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
1972 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1973 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
|
1974 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
|
1975 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
|
1976 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
|
1977 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
|
1978 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
|
1979 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
|
1980 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
|
1981 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
|
1982 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
|
1983 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
|
1984 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
|
1985 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
|
1986 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
|
1987 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
|
1988 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1989 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1990 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
|
1991 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1992 ASSERT_EQ(8u, s.size()); // Because of padding |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1993 ASSERT_EQ(0, s[7]); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1994 ASSERT_EQ("3.14159", s.substr(0, 7)); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1995 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1996 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
1997 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
|
1998 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
|
1999 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
|
2000 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
|
2001 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
|
2002 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
|
2003 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
|
2004 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
|
2005 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
|
2006 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
|
2007 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
|
2008 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
|
2009 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
|
2010 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2011 #if DCMTK_VERSION_NUMBER >= 361 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2012 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
|
2013 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
|
2014 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
|
2015 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
|
2016 #else |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2017 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
|
2018 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
|
2019 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
|
2020 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
|
2021 #endif |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2022 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2023 } |
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 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2026 TEST(DicomWebJson, Sequence) |
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 ParsedDicomFile dicom(false); |
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 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2031 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
|
2032 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2033 for (unsigned int i = 0; i < 3; i++) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2034 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2035 std::unique_ptr<DcmItem> item(new DcmItem); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2036 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
|
2037 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, s.c_str(), OFFalse); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2038 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
|
2039 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2040 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2041 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
|
2042 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2043 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2044 DicomWebJsonVisitor visitor; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2045 dicom.Apply(visitor); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2046 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2047 ASSERT_EQ("SQ", visitor.GetResult() ["00081115"]["vr"].asString()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2048 ASSERT_EQ(3u, visitor.GetResult() ["00081115"]["Value"].size()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2049 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2050 std::set<std::string> items; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2051 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2052 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
|
2053 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2054 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
|
2055 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
|
2056 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
|
2057 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
|
2058 } |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2059 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2060 ASSERT_EQ(3u, items.size()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2061 ASSERT_TRUE(items.find("item0") != items.end()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2062 ASSERT_TRUE(items.find("item1") != items.end()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2063 ASSERT_TRUE(items.find("item2") != items.end()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2064 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2065 std::string xml; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2066 visitor.FormatXml(xml); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2067 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2068 { |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2069 DicomMap m; |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2070 m.FromDicomWeb(visitor.GetResult()); |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2071 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
|
2072 } |
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 |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
2075 |
3727
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2076 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2077 |
090022f1b5e1
auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
2078 #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
|
2079 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
2080 #include "../Sources/DicomNetworking/DicomStoreUserConnection.h" |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
2081 #include "../Sources/DicomParsing/DcmtkTranscoder.h" |
3882
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3880
diff
changeset
|
2082 |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2083 TEST(Toto, DISABLED_Transcode3) |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2084 { |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2085 DicomAssociationParameters p; |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2086 p.SetRemotePort(2000); |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2087 |
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
2088 DicomStoreUserConnection scu(p); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
2089 scu.SetCommonClassesProposed(false); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
2090 scu.SetRetiredBigEndianProposed(true); |
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
2091 |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2092 DcmtkTranscoder transcoder; |
3885
e23026566536
removed unused functions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3884
diff
changeset
|
2093 |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2094 for (int j = 0; j < 2; j++) |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2095 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
|
2096 { |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2097 DicomTransferSyntax a = (DicomTransferSyntax) i; |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2098 |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2099 std::string path = ("/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/" + |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2100 std::string(GetTransferSyntaxUid(a)) + ".dcm"); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2101 if (Orthanc::SystemToolbox::IsRegularFile(path)) |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
2102 { |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2103 printf("\n======= %s\n", GetTransferSyntaxUid(a)); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2104 |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2105 std::string source; |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2106 Orthanc::SystemToolbox::ReadFile(source, path); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2107 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2108 std::string c, k; |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2109 try |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
2110 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2111 scu.Transcode(c, k, transcoder, source.c_str(), source.size(), false, "", 0); |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
2112 } |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2113 catch (OrthancException& e) |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
2114 { |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2115 if (e.GetErrorCode() == ErrorCode_NotImplemented) |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2116 { |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2117 LOG(ERROR) << "cannot transcode " << GetTransferSyntaxUid(a); |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2118 } |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2119 else |
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2120 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2121 throw; |
3889
56ce23ba93b7
PluginDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3888
diff
changeset
|
2122 } |
3884
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
2123 } |
83061cdc7703
moving old tests to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3883
diff
changeset
|
2124 } |
3883
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2125 } |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2126 } |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2127 |
795c9ca5eb91
DANGEROUS changeset: replaced "getOriginalXfer()" by "getCurrentXfer()" throughout Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3882
diff
changeset
|
2128 |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2129 TEST(Toto, DISABLED_Transcode4) |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2130 { |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2131 std::unique_ptr<DcmFileFormat> toto; |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2132 |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2133 { |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2134 std::string source; |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2135 Orthanc::SystemToolbox::ReadFile(source, "/home/jodogne/Subversion/orthanc-tests/Database/KarstenHilbertRF.dcm"); |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2136 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
|
2137 } |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4158
diff
changeset
|
2138 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
2139 const std::string sourceUid = IDicomTranscoder::GetSopInstanceUid(*toto); |
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
2140 |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2141 DicomTransferSyntax sourceSyntax; |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2142 ASSERT_TRUE(FromDcmtkBridge::LookupOrthancTransferSyntax(sourceSyntax, *toto)); |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2143 |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2144 DcmtkTranscoder transcoder; |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2145 |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2146 for (int i = 0; i <= DicomTransferSyntax_XML; i++) |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2147 { |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2148 DicomTransferSyntax a = (DicomTransferSyntax) i; |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
2149 |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
2150 std::set<DicomTransferSyntax> s; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
2151 s.insert(a); |
3888
e46b7a997f0a
IDicomTranscoder::TranscodeToBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3887
diff
changeset
|
2152 |
e46b7a997f0a
IDicomTranscoder::TranscodeToBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3887
diff
changeset
|
2153 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
|
2154 |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
2155 IDicomTranscoder::DicomImage source, target; |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
2156 source.AcquireParsed(dynamic_cast<DcmFileFormat*>(toto->clone())); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
2157 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
2158 if (!transcoder.Transcode(target, source, s, true)) |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2159 { |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2160 printf("**************** CANNOT: [%s] => [%s]\n", |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2161 GetTransferSyntaxUid(sourceSyntax), GetTransferSyntaxUid(a)); |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2162 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2163 else |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2164 { |
3910 | 2165 DicomTransferSyntax targetSyntax; |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3929
diff
changeset
|
2166 ASSERT_TRUE(FromDcmtkBridge::LookupOrthancTransferSyntax(targetSyntax, target.GetParsed())); |
3910 | 2167 |
3909
6762a97deabc
removed useless abstraction IDicomTranscoder::TranscodeToBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
2168 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
|
2169 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
|
2170 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
|
2171 a == DicomTransferSyntax_JPEGLSLossy); |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
2172 |
4158
32ac045109a6
fix compiler warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
2173 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
|
2174 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
|
2175 { |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
2176 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
|
2177 } |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
2178 else |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3893
diff
changeset
|
2179 { |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3949
diff
changeset
|
2180 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
|
2181 } |
3886
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2182 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2183 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2184 } |
b808958dff2a
transcoding to jpeg-ls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3885
diff
changeset
|
2185 |
3882
904575738462
implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3880
diff
changeset
|
2186 #endif |