annotate UnitTestsSources/FromDcmtkTests.cpp @ 3048:8b331be57606

fix build without plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Dec 2018 16:18:20 +0100
parents 9b4251721f22
children 4e43e67f8ecf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
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
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2445
diff changeset
5 * Copyright (C) 2017-2018 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
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
8 * modify it under the terms of the GNU General Public License as
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
10 * License, or (at your option) any later version.
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 * In addition, as a special exception, the copyright holders of this
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
13 * program give permission to link the code of its release with the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
16 * the linked executables. You must obey the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
20 * you do not wish to do so, delete this exception statement from your
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
21 * version. If you delete this exception statement from all source files
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
22 * in the program, then also delete it here.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
23 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
24 * 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
25 * 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
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
27 * General Public License for more details.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
28 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
29 * You should have received a copy of the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
31 **/
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
32
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 827
diff changeset
34 #include "PrecompiledHeadersUnitTests.h"
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "gtest/gtest.h"
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
37 #include "../Core/DicomParsing/FromDcmtkBridge.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
38 #include "../Core/DicomParsing/ToDcmtkBridge.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
39 #include "../Core/DicomParsing/DicomModification.h"
1692
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
40 #include "../OrthancServer/ServerToolbox.h"
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
41 #include "../Core/OrthancException.h"
1612
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
42 #include "../Core/Images/ImageBuffer.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
43 #include "../Core/Images/PngReader.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
44 #include "../Core/Images/PngWriter.h"
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
45 #include "../Core/Images/Image.h"
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
46 #include "../Core/Images/ImageProcessing.h"
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
47 #include "../Core/Endianness.h"
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
48 #include "../Resources/EncodingTests.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
49 #include "../Core/DicomNetworking/DicomFindAnswers.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
50 #include "../Core/DicomParsing/Internals/DicomImageDecoder.h"
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
51 #include "../Plugins/Engine/PluginsEnumerations.h"
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
53 #include <dcmtk/dcmdata/dcelem.h>
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
54 #include <dcmtk/dcmdata/dcdeftag.h>
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
55
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 using namespace Orthanc;
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 TEST(DicomFormat, Tag)
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
60 ASSERT_EQ("PatientName", FromDcmtkBridge::GetTagName(DicomTag(0x0010, 0x0010), ""));
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 ASSERT_EQ(0x0008, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 ASSERT_EQ(0x103E, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 t = FromDcmtkBridge::ParseTag("0020-e040");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 ASSERT_EQ(0x0020, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 ASSERT_EQ(0xe040, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 // Test ==() and !=() operators
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
76 TEST(DicomModification, Basic)
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
77 {
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
78 DicomModification m;
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
79 m.SetupAnonymization(DicomVersion_2008);
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
80 //m.SetLevel(DicomRootLevel_Study);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
81 //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
82 //m.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "coucou");
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
83
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
84 ParsedDicomFile o(true);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
85 o.SaveToFile("UnitTestsResults/anon.dcm");
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
86
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
87 for (int i = 0; i < 10; i++)
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 char b[1024];
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
90 sprintf(b, "UnitTestsResults/anon%06d.dcm", i);
2521
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
91 std::auto_ptr<ParsedDicomFile> f(o.Clone(false));
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
92 if (i > 4)
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
93 o.ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, "coucou");
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
94 m.Apply(*f);
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
95 f->SaveToFile(b);
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
96 }
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
97 }
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
98
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
99
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
100 TEST(DicomModification, Anonymization)
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
101 {
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
102 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
103
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
104 const DicomTag privateTag(0x0045, 0x0010);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
105 const DicomTag privateTag2(FromDcmtkBridge::ParseTag("0031-1020"));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
106 ASSERT_TRUE(privateTag.IsPrivate());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
107 ASSERT_TRUE(privateTag2.IsPrivate());
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
108 ASSERT_EQ(0x0031, privateTag2.GetGroup());
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
109 ASSERT_EQ(0x1020, privateTag2.GetElement());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
110
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
111 std::string s;
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
112 ParsedDicomFile o(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
113 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
114 ASSERT_FALSE(o.GetTagValue(s, privateTag));
1699
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
115 o.Insert(privateTag, "private tag", false);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
116 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
117 ASSERT_STREQ("private tag", s.c_str());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
118
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
119 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
120 ASSERT_THROW(o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_ThrowIfAbsent), OrthancException);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
121 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
122 o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_IgnoreIfAbsent);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
123 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
124 o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_InsertIfAbsent);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
125 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
126 ASSERT_STREQ("hello", s.c_str());
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
127 o.ReplacePlainString(privateTag2, "hello world");
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
128 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
129 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
130
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
131 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
132 ASSERT_FALSE(Toolbox::IsUuid(s));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
133
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
134 DicomModification m;
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
135 m.SetupAnonymization(DicomVersion_2008);
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
136 m.Keep(privateTag);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
137
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
138 m.Apply(o);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
139
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
140 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
141 ASSERT_TRUE(Toolbox::IsUuid(s));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
142 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
143 ASSERT_STREQ("private tag", s.c_str());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
144
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
145 m.SetupAnonymization(DicomVersion_2008);
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
146 m.Apply(o);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
147 ASSERT_FALSE(o.GetTagValue(s, 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
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
150
802
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 800
diff changeset
151 #include <dcmtk/dcmdata/dcuid.h>
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
152
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
153 TEST(DicomModification, Png)
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
154 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
155 // 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
156 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
157
1641
4e56b5a206b7 Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
158 std::string m, cc;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1971
diff changeset
159 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
160
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
161 ASSERT_EQ("image/png", m);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
162
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
163 PngReader reader;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
164 reader.ReadFromMemory(cc);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
165
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1417
diff changeset
166 ASSERT_EQ(5u, reader.GetHeight());
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1417
diff changeset
167 ASSERT_EQ(5u, reader.GetWidth());
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
168 ASSERT_EQ(PixelFormat_RGBA32, reader.GetFormat());
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
169
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
170 ParsedDicomFile o(true);
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
171 o.EmbedContent(s);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
172 o.SaveToFile("UnitTestsResults/png1.dcm");
800
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 // Red dot, without alpha channel
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
175 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDTcIn2+8BgAAACJJREFUCNdj/P//PwMjIwME/P/P+J8BBTAxEOL/R9Lx/z8AynoKAXOeiV8AAAAASUVORK5CYII=";
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
176 o.EmbedContent(s);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
177 o.SaveToFile("UnitTestsResults/png2.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
178
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
179 // Check box in Graylevel8
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
180 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII=";
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
181 o.EmbedContent(s);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
182 //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
183 o.SaveToFile("UnitTestsResults/png3.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
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
186 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
187 // Gradient in Graylevel16
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
188
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
189 ImageBuffer img;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
190 img.SetWidth(256);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
191 img.SetHeight(256);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
192 img.SetFormat(PixelFormat_Grayscale16);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
193
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
194 ImageAccessor accessor;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
195 img.GetWriteableAccessor(accessor);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
196
1654
3727a09e7b53 fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1641
diff changeset
197 uint16_t v = 0;
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
198 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
199 {
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
200 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
201 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
202 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
203 *p = v;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
204 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
205 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
206
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
207 o.EmbedImage(accessor);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
208 o.SaveToFile("UnitTestsResults/png4.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
209 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
210 }
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
211
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
212
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
213 TEST(FromDcmtkBridge, Encodings1)
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
214 {
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
215 for (unsigned int i = 0; i < testEncodingsCount; i++)
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
216 {
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
217 std::string source(testEncodingsEncoded[i]);
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
218 std::string expected(testEncodingsExpected[i]);
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
219 std::string s = Toolbox::ConvertToUtf8(source, testEncodings[i]);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
220 //std::cout << EnumerationToString(testEncodings[i]) << std::endl;
1089
5ea0b56e850d logging in test
jodogne
parents: 1088
diff changeset
221 EXPECT_EQ(expected, s);
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
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
225
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
226 TEST(FromDcmtkBridge, Enumerations)
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
227 {
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
228 // 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
229 Encoding e;
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
230
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
231 ASSERT_FALSE(GetDicomEncoding(e, ""));
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
232 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
233
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
234 // 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
247 // 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
261 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-4
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
262 ASSERT_FALSE(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
263 ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 159")); //ASSERT_EQ(Encoding_JapaneseKanjiSupplementary, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
264 ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 149")); //ASSERT_EQ(Encoding_Korean, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
265
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
266 // 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
267 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
268 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
269 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
270 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
271
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
272
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
273 TEST(FromDcmtkBridge, Encodings3)
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
274 {
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
275 for (unsigned int i = 0; i < testEncodingsCount; i++)
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
276 {
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
277 //std::cout << EnumerationToString(testEncodings[i]) << std::endl;
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
278 std::string dicom;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
279
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
280 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
281 ParsedDicomFile f(true);
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
282 f.SetEncoding(testEncodings[i]);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
283
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
284 std::string s = Toolbox::ConvertToUtf8(testEncodingsEncoded[i], testEncodings[i]);
1699
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
285 f.Insert(DICOM_TAG_PATIENT_NAME, s, false);
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
286 f.SaveToMemoryBuffer(dicom);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
287 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
288
1347
60cc0ee61edb fix issue 32
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1334
diff changeset
289 if (testEncodings[i] != Encoding_Windows1251)
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
290 {
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
291 ParsedDicomFile g(dicom);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
292
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
293 if (testEncodings[i] != Encoding_Ascii)
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
294 {
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
295 ASSERT_EQ(testEncodings[i], g.GetEncoding());
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
296 }
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
297
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
298 std::string tag;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
299 ASSERT_TRUE(g.GetTagValue(tag, DICOM_TAG_PATIENT_NAME));
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
300 ASSERT_EQ(std::string(testEncodingsExpected[i]), tag);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
301 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
302 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
303 }
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
304
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
305
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
306 TEST(FromDcmtkBridge, ValueRepresentation)
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
307 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
308 ASSERT_EQ(ValueRepresentation_PersonName,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
309 FromDcmtkBridge::LookupValueRepresentation(DICOM_TAG_PATIENT_NAME));
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
310 ASSERT_EQ(ValueRepresentation_Date,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
311 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0020) /* StudyDate */));
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
312 ASSERT_EQ(ValueRepresentation_Time,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
313 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0030) /* StudyTime */));
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
314 ASSERT_EQ(ValueRepresentation_DateTime,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
315 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x002a) /* AcquisitionDateTime */));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
316 ASSERT_EQ(ValueRepresentation_NotSupported,
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
317 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
318 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
319
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
320
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
321 TEST(FromDcmtkBridge, ValueRepresentationConversions)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
322 {
3048
8b331be57606 fix build without plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
323 #if ORTHANC_ENABLE_PLUGINS == 1
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
324 ASSERT_EQ(1, ValueRepresentation_ApplicationEntity);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
325 ASSERT_EQ(1, OrthancPluginValueRepresentation_AE);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
326
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
327 for (int i = ValueRepresentation_ApplicationEntity;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
328 i <= ValueRepresentation_NotSupported; i++)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
329 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
330 ValueRepresentation vr = static_cast<ValueRepresentation>(i);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
331
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
332 if (vr == ValueRepresentation_NotSupported)
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 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
335 ASSERT_THROW(Plugins::Convert(vr), OrthancException);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
336 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
337 else if (vr == ValueRepresentation_OtherDouble ||
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
338 vr == ValueRepresentation_OtherLong ||
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
339 vr == ValueRepresentation_UniversalResource ||
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
340 vr == ValueRepresentation_UnlimitedCharacters)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
341 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
342 // These VR are not supported as of DCMTK 3.6.0
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
343 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
344 ASSERT_EQ(OrthancPluginValueRepresentation_UN, Plugins::Convert(vr));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
345 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
346 else
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
347 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
348 ASSERT_EQ(vr, FromDcmtkBridge::Convert(ToDcmtkBridge::Convert(vr)));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
349
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
350 OrthancPluginValueRepresentation plugins = Plugins::Convert(vr);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
351 ASSERT_EQ(vr, Plugins::Convert(plugins));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
352 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
353 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
354
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
355 for (int i = OrthancPluginValueRepresentation_AE;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
356 i <= OrthancPluginValueRepresentation_UT; i++)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
357 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
358 OrthancPluginValueRepresentation plugins = static_cast<OrthancPluginValueRepresentation>(i);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
359 ValueRepresentation orthanc = Plugins::Convert(plugins);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
360 ASSERT_EQ(plugins, Plugins::Convert(orthanc));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
361 }
3048
8b331be57606 fix build without plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
362 #endif
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
363 }
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
364
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
365
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
366
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
367 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
368 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
369
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
370 static void CreateSampleJson(Json::Value& a)
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
371 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
372 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
373 Json::Value b = Json::objectValue;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
374 b["PatientName"] = "Hello";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
375 b["PatientID"] = "World";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
376 b["StudyDescription"] = "Toto";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
377 a.append(b);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
378 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
379
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
380 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
381 Json::Value b = Json::objectValue;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
382 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
383 b["PatientID"] = "World2";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
384 a.append(b);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
385 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
386 }
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
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
389 namespace Orthanc
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
390 {
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
391 // Namespace for the "FRIEND_TEST()" directive in "FromDcmtkBridge" to apply:
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
392 // https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#private-class-members
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
393 TEST(FromDcmtkBridge, FromJson)
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
394 {
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
395 std::auto_ptr<DcmElement> element;
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
396
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
397 {
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
398 Json::Value a;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
399 a = "Hello";
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
400 element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, false, Encoding_Utf8));
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
401
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
402 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
403 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
404 ignoreTagLength.insert(DICOM_TAG_PATIENT_ID);
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
405
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
406 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
407 DicomToJsonFlags_Default, 0, Encoding_Ascii, ignoreTagLength);
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
408 ASSERT_TRUE(b.isMember("0010,0010"));
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
409 ASSERT_EQ("Hello", b["0010,0010"].asString());
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
410
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
411 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
412 DicomToJsonFlags_Default, 3, Encoding_Ascii, ignoreTagLength);
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
413 ASSERT_TRUE(b["0010,0010"].isNull()); // "Hello" has more than 3 characters
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
414
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
415 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Full,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
416 DicomToJsonFlags_Default, 3, Encoding_Ascii, ignoreTagLength);
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
417 ASSERT_TRUE(b["0010,0010"].isObject());
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
418 ASSERT_EQ("PatientName", b["0010,0010"]["Name"].asString());
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
419 ASSERT_EQ("TooLong", b["0010,0010"]["Type"].asString());
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
420 ASSERT_TRUE(b["0010,0010"]["Value"].isNull());
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
421
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
422 ignoreTagLength.insert(DICOM_TAG_PATIENT_NAME);
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
423 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
424 DicomToJsonFlags_Default, 3, Encoding_Ascii, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
425 ASSERT_EQ("Hello", b["0010,0010"].asString());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
426 }
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
427
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
428 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
429 Json::Value a;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
430 a = "Hello";
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
431 // Cannot assign a string to a sequence
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
432 ASSERT_THROW(element.reset(FromDcmtkBridge::FromJson(REFERENCED_STUDY_SEQUENCE, a, false, Encoding_Utf8)), OrthancException);
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
433 }
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
434
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
435 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
436 Json::Value a = Json::arrayValue;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
437 a.append("Hello");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
438 // Cannot assign an array to a string
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
439 ASSERT_THROW(element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, false, Encoding_Utf8)), OrthancException);
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
440 }
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
441
1692
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
442 {
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
443 Json::Value a;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
444 a = "data:application/octet-stream;base64,SGVsbG8="; // echo -n "Hello" | base64
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
445 element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, true, Encoding_Utf8));
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
446
1692
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
447 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
448 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
449 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
450 DicomToJsonFlags_Default, 0, Encoding_Ascii, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
451 ASSERT_EQ("Hello", b["0010,0010"].asString());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
452 }
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
453
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
454 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
455 Json::Value a = Json::arrayValue;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
456 CreateSampleJson(a);
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
457 element.reset(FromDcmtkBridge::FromJson(REFERENCED_STUDY_SEQUENCE, a, true, Encoding_Utf8));
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
458
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
459 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
460 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
461 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
462 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
463 DicomToJsonFlags_Default, 0, Encoding_Ascii, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
464 ASSERT_EQ(Json::arrayValue, b["0008,1110"].type());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
465 ASSERT_EQ(2u, b["0008,1110"].size());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
466
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
467 Json::Value::ArrayIndex i = (b["0008,1110"][0]["0010,0010"].asString() == "Hello") ? 0 : 1;
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
468
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
469 ASSERT_EQ(3u, b["0008,1110"][i].size());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
470 ASSERT_EQ(2u, b["0008,1110"][1 - i].size());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
471 ASSERT_EQ(b["0008,1110"][i]["0010,0010"].asString(), "Hello");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
472 ASSERT_EQ(b["0008,1110"][i]["0010,0020"].asString(), "World");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
473 ASSERT_EQ(b["0008,1110"][i]["0008,1030"].asString(), "Toto");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
474 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0010"].asString(), "Hello2");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
475 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0020"].asString(), "World2");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
476 }
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
477
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
478 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
479 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
480 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
481 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Full,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
482 DicomToJsonFlags_Default, 0, Encoding_Ascii, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
483
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
484 Json::Value c;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
485 ServerToolbox::SimplifyTags(c, b, DicomToJsonFormat_Human);
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
486
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
487 a[1]["PatientName"] = "Hello2"; // To remove the Data URI Scheme encoding
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
488 ASSERT_EQ(0, c["ReferencedStudySequence"].compare(a));
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
489 }
1692
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
490 }
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
491 }
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
492 }
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
493
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
494
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
495 TEST(ParsedDicomFile, InsertReplaceStrings)
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
496 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
497 ParsedDicomFile f(true);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
498
1699
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
499 f.Insert(DICOM_TAG_PATIENT_NAME, "World", false);
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
500 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
501 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
502 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
503
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
504 std::string s;
2209
e3fd5bc429a2 URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2207
diff changeset
505 ASSERT_FALSE(f.LookupTransferSyntax(s));
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
506
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
507 ASSERT_THROW(f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession"),
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
508 false, DicomReplaceMode_ThrowIfAbsent), OrthancException);
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
509 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
510 ASSERT_FALSE(f.GetTagValue(s, DICOM_TAG_ACCESSION_NUMBER));
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
511 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
512 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
513 ASSERT_EQ(s, "Accession");
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
514 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
515 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
516 ASSERT_EQ(s, "Accession2");
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
517 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
518 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
519 ASSERT_EQ(s, "Accession3");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
520
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
521 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
522 ASSERT_EQ(s, "World");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
523 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
524 ASSERT_EQ(s, "Toto");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
525 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
526 ASSERT_EQ(s, "Toto");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
527 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
528 ASSERT_EQ(s, "Tata");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
529 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
530 ASSERT_EQ(s, "Tata");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
531 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
532
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
533
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
534
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
535
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
536 TEST(ParsedDicomFile, InsertReplaceJson)
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
537 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
538 ParsedDicomFile f(true);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
539
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
540 Json::Value a;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
541 CreateSampleJson(a);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
542
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
543 ASSERT_FALSE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
544 f.Remove(REFERENCED_STUDY_SEQUENCE); // No effect
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
545 f.Insert(REFERENCED_STUDY_SEQUENCE, a, true);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
546 ASSERT_TRUE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
547 ASSERT_THROW(f.Insert(REFERENCED_STUDY_SEQUENCE, a, true), OrthancException);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
548 f.Remove(REFERENCED_STUDY_SEQUENCE);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
549 ASSERT_FALSE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
550 f.Insert(REFERENCED_STUDY_SEQUENCE, a, true);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
551 ASSERT_TRUE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
552
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
553 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
554 ASSERT_THROW(f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_ThrowIfAbsent), OrthancException);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
555 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
556 f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_IgnoreIfAbsent);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
557 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
558 f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_InsertIfAbsent);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
559 ASSERT_TRUE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
560
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
561 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
562 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
563 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
564
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
565 Json::Value c;
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2117
diff changeset
566 ServerToolbox::SimplifyTags(c, b, DicomToJsonFormat_Human);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
567
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
568 ASSERT_EQ(0, c["ReferencedPatientSequence"].compare(a));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
569 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
570 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
571
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
572 a = "data:application/octet-stream;base64,VGF0YQ=="; // echo -n "Tata" | base64
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
573 f.Replace(DICOM_TAG_SOP_INSTANCE_UID, a, false, DicomReplaceMode_InsertIfAbsent); // (*)
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
574 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
575
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
576 std::string s;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
577 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
578 ASSERT_EQ(s, a.asString());
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
579 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
580 ASSERT_EQ(s, a.asString());
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
581 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
582 ASSERT_EQ(s, "Tata");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
583 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
584 ASSERT_EQ(s, "Tata");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
585 }
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
586
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
587
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
588 TEST(ParsedDicomFile, JsonEncoding)
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
589 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
590 ParsedDicomFile f(true);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
591
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
592 for (unsigned int i = 0; i < testEncodingsCount; i++)
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
593 {
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
594 if (testEncodings[i] != Encoding_Windows1251)
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
595 {
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
596 //std::cout << EnumerationToString(testEncodings[i]) << std::endl;
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
597 f.SetEncoding(testEncodings[i]);
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
598
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
599 if (testEncodings[i] != Encoding_Ascii)
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
600 {
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
601 ASSERT_EQ(testEncodings[i], f.GetEncoding());
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
602 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
603
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
604 Json::Value s = Toolbox::ConvertToUtf8(testEncodingsEncoded[i], testEncodings[i]);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
605 f.Replace(DICOM_TAG_PATIENT_NAME, s, false, DicomReplaceMode_InsertIfAbsent);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
606
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
607 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
608 f.DatasetToJson(v, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
609 ASSERT_EQ(v["PatientName"].asString(), std::string(testEncodingsExpected[i]));
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
610 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
611 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
612 }
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
613
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
614
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
615 TEST(ParsedDicomFile, ToJsonFlags1)
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
616 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
617 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7053, 0x1000), ValueRepresentation_PersonName, "MyPrivateTag", 1, 1, "");
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
618 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
619
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
620 ParsedDicomFile f(true);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
621 f.Insert(DicomTag(0x7050, 0x1000), "Some public tag", false); // Even group => public tag
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
622 f.Insert(DicomTag(0x7052, 0x1000), "Some unknown tag", false); // Even group => public, unknown tag
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
623 f.Insert(DicomTag(0x7053, 0x1000), "Some private tag", false); // Odd group => private tag
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
624
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
625 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
626 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
627 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
628 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
629 ASSERT_FALSE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
630 ASSERT_FALSE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
631 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
632 ASSERT_EQ(Json::stringValue, v["7050,1000"].type());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
633 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
634
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
635 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_ConvertBinaryToNull), 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
636 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
637 ASSERT_EQ(7u, v.getMemberNames().size());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
638 ASSERT_FALSE(v.isMember("7052,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
639 ASSERT_TRUE(v.isMember("7050,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
640 ASSERT_TRUE(v.isMember("7053,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
641 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
642 ASSERT_EQ(Json::nullValue, v["7053,1000"].type());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
643
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
644 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePrivateTags, 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
645 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
646 ASSERT_EQ(7u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
647 ASSERT_FALSE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
648 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
649 ASSERT_TRUE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
650 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
651 std::string mime, content;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
652 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
653 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7053,1000"].asString()));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
654 ASSERT_EQ("application/octet-stream", mime);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
655 ASSERT_EQ("Some private tag", content);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
656
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
657 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_ConvertBinaryToNull), 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
658 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
659 ASSERT_EQ(7u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
660 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
661 ASSERT_TRUE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
662 ASSERT_FALSE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
663 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
664 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
665
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
666 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags), 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
667 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
668 ASSERT_EQ(7u, v.getMemberNames().size());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
669 ASSERT_TRUE(v.isMember("7050,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
670 ASSERT_TRUE(v.isMember("7052,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
671 ASSERT_FALSE(v.isMember("7053,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
672 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
673 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
674 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7052,1000"].asString()));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
675 ASSERT_EQ("application/octet-stream", mime);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
676 ASSERT_EQ("Some unknown tag", content);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
677
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
678 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_ConvertBinaryToNull), 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
679 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
680 ASSERT_EQ(8u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
681 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
682 ASSERT_TRUE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
683 ASSERT_TRUE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
684 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
685 ASSERT_EQ(Json::nullValue, v["7052,1000"].type());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
686 ASSERT_EQ(Json::nullValue, v["7053,1000"].type());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
687 }
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
688
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
689
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
690 TEST(ParsedDicomFile, ToJsonFlags2)
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
691 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
692 ParsedDicomFile f(true);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
693 f.Insert(DICOM_TAG_PIXEL_DATA, "Pixels", false);
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
694
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
695 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
696 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
697 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
698 ASSERT_EQ(5u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
699 ASSERT_FALSE(v.isMember("7fe0,0010"));
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
700
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
701 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
702 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
703 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
704 ASSERT_TRUE(v.isMember("7fe0,0010"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
705 ASSERT_EQ(Json::nullValue, v["7fe0,0010"].type());
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
706
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
707 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
708 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
709 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
710 ASSERT_TRUE(v.isMember("7fe0,0010"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
711 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
712 ASSERT_EQ("Pixels", v["7fe0,0010"].asString());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
713
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
714 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePixelData, 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
715 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
716 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
717 ASSERT_TRUE(v.isMember("7fe0,0010"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
718 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
719 std::string mime, content;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1971
diff changeset
720 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
721 ASSERT_EQ("application/octet-stream", mime);
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
722 ASSERT_EQ("Pixels", content);
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
723 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
724
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
725
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
726 TEST(DicomFindAnswers, Basic)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
727 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
728 DicomFindAnswers a(false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
729
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
730 {
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
731 DicomMap m;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
732 m.SetValue(DICOM_TAG_PATIENT_ID, "hello", false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
733 a.Add(m);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
734 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
735
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
736 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
737 ParsedDicomFile d(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
738 d.ReplacePlainString(DICOM_TAG_PATIENT_ID, "my");
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
739 a.Add(d);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
740 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
741
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
742 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
743 DicomMap m;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
744 m.SetValue(DICOM_TAG_PATIENT_ID, "world", false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
745 a.Add(m);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
746 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
747
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
748 Json::Value j;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
749 a.ToJson(j, true);
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
750 ASSERT_EQ(3u, j.size());
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
751
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
752 //std::cout << j;
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
753 }
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
754
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
755
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
756 TEST(ParsedDicomFile, FromJson)
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
757 {
2117
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
758 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7057, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag2", 1, 1, "ORTHANC");
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
759 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7059, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag3", 1, 1, "");
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
760 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
761
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
762 Json::Value v;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
763 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
764
2117
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
765 // Test the private creator
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
766 ASSERT_EQ(DcmTag_ERROR_TagName, FromDcmtkBridge::GetTagName(DicomTag(0x7057, 0x1000), "NOPE"));
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
767 ASSERT_EQ("MyPrivateTag2", FromDcmtkBridge::GetTagName(DicomTag(0x7057, 0x1000), "ORTHANC"));
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
768
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
769 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
770 v["SOPClassUID"] = sopClassUid;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
771 v["SpecificCharacterSet"] = "ISO_IR 148"; // This is latin-5
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
772 v["PatientName"] = "Sébastien";
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
773 v["7050-1000"] = "Some public tag"; // Even group => public tag
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
774 v["7052-1000"] = "Some unknown tag"; // Even group => public, unknown tag
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
775 v["7057-1000"] = "Some private tag"; // Odd group => private tag
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
776 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
777
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
778 std::string s;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
779 Toolbox::EncodeDataUriScheme(s, "application/octet-stream", "Sebastien");
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
780 v["StudyDescription"] = s;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
781
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
782 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
783 v["0040,0100"] = Json::arrayValue; // ScheduledProcedureStepSequence
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
784
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
785 Json::Value vv;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
786 vv["Modality"] = "MR";
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
787 v["0040,0100"].append(vv);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
788
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
789 vv["Modality"] = "CT";
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
790 v["0040,0100"].append(vv);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
791 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
792
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
793 const DicomToJsonFlags toJsonFlags = static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeBinary |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
794 DicomToJsonFlags_IncludePixelData |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
795 DicomToJsonFlags_IncludePrivateTags |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
796 DicomToJsonFlags_IncludeUnknownTags |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
797 DicomToJsonFlags_ConvertBinaryToAscii);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
798
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
799
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
800 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
801 std::auto_ptr<ParsedDicomFile> dicom
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
802 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers)));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
803
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
804 Json::Value vv;
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
805 dicom->DatasetToJson(vv, DicomToJsonFormat_Human, toJsonFlags, 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
806
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
807 ASSERT_EQ(vv["SOPClassUID"].asString(), sopClassUid);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
808 ASSERT_EQ(vv["MediaStorageSOPClassUID"].asString(), sopClassUid);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
809 ASSERT_TRUE(vv.isMember("SOPInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
810 ASSERT_TRUE(vv.isMember("SeriesInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
811 ASSERT_TRUE(vv.isMember("StudyInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
812 ASSERT_TRUE(vv.isMember("PatientID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
813 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
814
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
815
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
816 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
817 std::auto_ptr<ParsedDicomFile> dicom
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
818 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers)));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
819
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
820 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
821 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
822
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
823 std::string mime, content;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1971
diff changeset
824 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, vv["PixelData"].asString()));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
825 ASSERT_EQ("application/octet-stream", mime);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
826 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
827 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
828
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
829
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
830 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
831 std::auto_ptr<ParsedDicomFile> dicom
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
832 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_DecodeDataUriScheme)));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
833
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
834 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
835 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, toJsonFlags, 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
836
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
837 ASSERT_FALSE(vv.isMember("SOPInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
838 ASSERT_FALSE(vv.isMember("SeriesInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
839 ASSERT_FALSE(vv.isMember("StudyInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
840 ASSERT_FALSE(vv.isMember("PatientID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
841 ASSERT_EQ(2u, vv["0040,0100"].size());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
842 ASSERT_EQ("MR", vv["0040,0100"][0]["0008,0060"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
843 ASSERT_EQ("CT", vv["0040,0100"][1]["0008,0060"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
844 ASSERT_EQ("Some public tag", vv["7050,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
845 ASSERT_EQ("Some unknown tag", vv["7052,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
846 ASSERT_EQ("Some private tag", vv["7057,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
847 ASSERT_EQ("Some private tag2", vv["7059,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
848 ASSERT_EQ("Sébastien", vv["0010,0010"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
849 ASSERT_EQ("Sebastien", vv["0008,1030"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
850 ASSERT_EQ("ISO_IR 148", vv["0008,0005"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
851 ASSERT_EQ("5", vv[DICOM_TAG_ROWS.Format()].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
852 ASSERT_EQ("5", vv[DICOM_TAG_COLUMNS.Format()].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
853 ASSERT_TRUE(vv[DICOM_TAG_PIXEL_DATA.Format()].asString().empty());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
854 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
855 }
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
856
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
857
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
858
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
859 TEST(TestImages, PatternGrayscale8)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
860 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
861 static const char* PATH = "UnitTestsResults/PatternGrayscale8.dcm";
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
862
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
863 Orthanc::Image image(Orthanc::PixelFormat_Grayscale8, 256, 256, false);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
864
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
865 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
866 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
867 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
868 for (int x = 0; x < 256; x++, p++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
869 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
870 *p = y;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
871 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
872 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
873
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
874 Orthanc::ImageAccessor r;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
875
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
876 image.GetRegion(r, 32, 32, 64, 192);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
877 Orthanc::ImageProcessing::Set(r, 0);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
878
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
879 image.GetRegion(r, 160, 32, 64, 192);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
880 Orthanc::ImageProcessing::Set(r, 255);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
881
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
882 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
883 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
884 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
885 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
886 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
887 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
888 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
889 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale8");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
890 f.EmbedImage(image);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
891
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
892 f.SaveToFile(PATH);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
893 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
894
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
895 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
896 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
897 Orthanc::SystemToolbox::ReadFile(s, PATH);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
898 Orthanc::ParsedDicomFile f(s);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
899
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
900 std::auto_ptr<Orthanc::ImageAccessor> decoded(Orthanc::DicomImageDecoder::Decode(f, 0));
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
901 ASSERT_EQ(256u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
902 ASSERT_EQ(256u, decoded->GetHeight());
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
903 ASSERT_EQ(Orthanc::PixelFormat_Grayscale8, decoded->GetFormat());
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
904
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
905 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
906 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
907 const void* a = image.GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
908 const void* b = decoded->GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
909 ASSERT_EQ(0, memcmp(a, b, 256));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
910 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
911 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
912 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
913
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
914
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
915 TEST(TestImages, PatternRGB)
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 static const char* PATH = "UnitTestsResults/PatternRGB24.dcm";
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
918
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
919 Orthanc::Image image(Orthanc::PixelFormat_RGB24, 384, 256, false);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
920
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
921 for (int y = 0; y < 256; y++)
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 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
924 for (int x = 0; x < 128; x++, p += 3)
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 p[0] = y;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
927 p[1] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
928 p[2] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
929 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
930 for (int x = 128; x < 128 * 2; x++, p += 3)
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 p[0] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
933 p[1] = 255 - y;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
934 p[2] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
935 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
936 for (int x = 128 * 2; x < 128 * 3; x++, p += 3)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
937 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
938 p[0] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
939 p[1] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
940 p[2] = y;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
941 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
942 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
943
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
944 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
945 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
946 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
947 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
948 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
949 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
950 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
951 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "RGB24");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
952 f.EmbedImage(image);
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 f.SaveToFile(PATH);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
955 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
956
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
957 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
958 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
959 Orthanc::SystemToolbox::ReadFile(s, PATH);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
960 Orthanc::ParsedDicomFile f(s);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
961
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
962 std::auto_ptr<Orthanc::ImageAccessor> decoded(Orthanc::DicomImageDecoder::Decode(f, 0));
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
963 ASSERT_EQ(384u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
964 ASSERT_EQ(256u, decoded->GetHeight());
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
965 ASSERT_EQ(Orthanc::PixelFormat_RGB24, decoded->GetFormat());
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
966
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
967 for (int y = 0; y < 256; y++)
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 const void* a = image.GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
970 const void* b = decoded->GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
971 ASSERT_EQ(0, memcmp(a, b, 3 * 384));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
972 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
973 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
974 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
975
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
976
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
977 TEST(TestImages, PatternUint16)
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
978 {
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
979 static const char* PATH = "UnitTestsResults/PatternGrayscale16.dcm";
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
980
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
981 Orthanc::Image image(Orthanc::PixelFormat_Grayscale16, 256, 256, false);
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
982
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
983 uint16_t v = 0;
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
984 for (int y = 0; y < 256; y++)
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
985 {
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
986 uint16_t *p = reinterpret_cast<uint16_t*>(image.GetRow(y));
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
987 for (int x = 0; x < 256; x++, v++, p++)
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
988 {
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
989 *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
990 }
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
991 }
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
992
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
993 Orthanc::ImageAccessor r;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
994
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
995 image.GetRegion(r, 32, 32, 64, 192);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
996 Orthanc::ImageProcessing::Set(r, 0);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
997
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
998 image.GetRegion(r, 160, 32, 64, 192);
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
999 Orthanc::ImageProcessing::Set(r, 65535);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1000
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1001 {
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1002 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1003 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
1004 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
1005 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
1006 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
1007 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
1008 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale16");
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1009 f.EmbedImage(image);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1010
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1011 f.SaveToFile(PATH);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1012 }
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1013
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1014 {
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1015 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
1016 Orthanc::SystemToolbox::ReadFile(s, PATH);
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1017 Orthanc::ParsedDicomFile f(s);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1018
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1019 std::auto_ptr<Orthanc::ImageAccessor> decoded(Orthanc::DicomImageDecoder::Decode(f, 0));
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
1020 ASSERT_EQ(256u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
1021 ASSERT_EQ(256u, decoded->GetHeight());
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1022 ASSERT_EQ(Orthanc::PixelFormat_Grayscale16, decoded->GetFormat());
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1023
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1024 for (int y = 0; y < 256; y++)
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1025 {
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1026 const void* a = image.GetConstRow(y);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1027 const void* b = decoded->GetConstRow(y);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1028 ASSERT_EQ(0, memcmp(a, b, 512));
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1029 }
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1030 }
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1031 }
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1032
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1033
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1034 TEST(TestImages, PatternInt16)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1035 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1036 static const char* PATH = "UnitTestsResults/PatternSignedGrayscale16.dcm";
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1037
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
1038 Orthanc::Image image(Orthanc::PixelFormat_SignedGrayscale16, 256, 256, false);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1039
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1040 int16_t v = -32768;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1041 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1042 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1043 int16_t *p = reinterpret_cast<int16_t*>(image.GetRow(y));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1044 for (int x = 0; x < 256; x++, v++, p++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1045 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1046 *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
1047 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1048 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1049
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1050 Orthanc::ImageAccessor r;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1051 image.GetRegion(r, 32, 32, 64, 192);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1052 Orthanc::ImageProcessing::Set(r, -32768);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1053
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1054 image.GetRegion(r, 160, 32, 64, 192);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1055 Orthanc::ImageProcessing::Set(r, 32767);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1056
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1057 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1058 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1059 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
1060 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
1061 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
1062 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
1063 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
1064 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "SignedGrayscale16");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1065 f.EmbedImage(image);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1066
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1067 f.SaveToFile(PATH);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1068 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1069
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1070 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1071 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
1072 Orthanc::SystemToolbox::ReadFile(s, PATH);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1073 Orthanc::ParsedDicomFile f(s);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1074
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1075 std::auto_ptr<Orthanc::ImageAccessor> decoded(Orthanc::DicomImageDecoder::Decode(f, 0));
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
1076 ASSERT_EQ(256u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
1077 ASSERT_EQ(256u, decoded->GetHeight());
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1078 ASSERT_EQ(Orthanc::PixelFormat_SignedGrayscale16, decoded->GetFormat());
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1079
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1080 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1081 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1082 const void* a = image.GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1083 const void* b = decoded->GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1084 ASSERT_EQ(0, memcmp(a, b, 512));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1085 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1086 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1087 }
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
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1090
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1091 static void CheckEncoding(const ParsedDicomFile& dicom,
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1092 Encoding expected)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1093 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1094 const char* value = NULL;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1095 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
1096
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1097 Encoding encoding;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1098 ASSERT_TRUE(GetDicomEncoding(encoding, value));
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1099 ASSERT_EQ(expected, encoding);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1100 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1101
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1102
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1103 TEST(ParsedDicomFile, DicomMapEncodings1)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1104 {
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2326
diff changeset
1105 SetDefaultDicomEncoding(Encoding_Ascii);
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2326
diff changeset
1106 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
1107
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1108 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1109 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1110 ParsedDicomFile dicom(m);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1111 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
1112 CheckEncoding(dicom, Encoding_Ascii);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1113 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1114
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1115 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1116 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1117 ParsedDicomFile dicom(m, Encoding_Latin4);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1118 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
1119 CheckEncoding(dicom, Encoding_Latin4);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1120 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1121
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1122 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1123 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1124 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1125 ParsedDicomFile dicom(m);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1126 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
1127 CheckEncoding(dicom, Encoding_Latin5);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1128 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1129
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1130 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1131 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1132 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1133 ParsedDicomFile dicom(m, Encoding_Latin1);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1134 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
1135 CheckEncoding(dicom, Encoding_Latin5);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1136 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1137 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1138
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1139
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1140 TEST(ParsedDicomFile, DicomMapEncodings2)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1141 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1142 const char* utf8 = NULL;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1143 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
1144 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1145 if (testEncodings[i] == Encoding_Utf8)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1146 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1147 utf8 = testEncodingsEncoded[i];
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1148 break;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1149 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1150 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1151
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1152 ASSERT_TRUE(utf8 != NULL);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1153
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1154 for (unsigned int i = 0; i < testEncodingsCount; i++)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1155 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1156 // 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
1157 if (testEncodings[i] != Encoding_Windows1251)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1158 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1159 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1160 // 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
1161 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
1162 ASSERT_STREQ(testEncodingsEncoded[i], encoded.c_str());
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1163 std::string decoded = Toolbox::ConvertToUtf8(encoded, testEncodings[i]);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1164 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
1165
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1166 if (testEncodings[i] != Encoding_Chinese)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1167 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1168 // 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
1169 // 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
1170
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1171 std::string encoded = Toolbox::ConvertToUtf8(Toolbox::ConvertFromUtf8(utf8, testEncodings[i]), testEncodings[i]);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1172 ASSERT_STREQ(testEncodingsExpected[i], encoded.c_str());
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1173 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1174 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1175
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1176
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1177 Json::Value v;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1178
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1179 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1180 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1181 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
1182
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1183 ParsedDicomFile dicom(m, testEncodings[i]);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1184
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1185 const char* encoded = NULL;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1186 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
1187 ASSERT_STREQ(testEncodingsEncoded[i], encoded);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1188
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1189 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
1190
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1191 Encoding encoding;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1192 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
1193 ASSERT_EQ(encoding, testEncodings[i]);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1194 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
1195 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1196
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1197
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1198 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1199 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1200 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
1201 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
1202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1203 ParsedDicomFile dicom(m, testEncodings[i]);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1204
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1205 Json::Value v2;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1206 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
1207
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1208 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
1209 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
1210 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1211 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1212 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1213 }
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1214
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1215
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1216 TEST(ParsedDicomFile, ChangeEncoding)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1217 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1218 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
1219 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1220 // 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
1221 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
1222 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1223 DicomMap m;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1224 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
1225
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1226 std::string tag;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1227
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1228 ParsedDicomFile dicom(m, Encoding_Utf8);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1229 ASSERT_EQ(Encoding_Utf8, dicom.GetEncoding());
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1230 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
1231 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
1232
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1233 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1234 Json::Value v;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1235 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
1236 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
1237 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
1238 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1239
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1240 dicom.ChangeEncoding(testEncodings[i]);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1241
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1242 ASSERT_EQ(testEncodings[i], dicom.GetEncoding());
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1243
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1244 const char* c = NULL;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1245 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
1246 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
1247
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1248 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
1249 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
1250
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1251 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1252 Json::Value v;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1253 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
1254 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
1255 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
1256 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1257 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1258 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1259 }
2326
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1260
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1261
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1262 TEST(Toolbox, CaseWithAccents)
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1263 {
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1264 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
1265 }
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
1266
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1267
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1268
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1269 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
1270 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1271 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1272 // 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
1273 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
1274 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
1275
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1276 ParsedDicomFile d(m, Encoding_Latin3 /* 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
1277 ASSERT_EQ(Encoding_Latin3, d.GetEncoding());
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1278 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1279
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1280 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1281 // 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
1282 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
1283 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
1284 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
1285
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1286 ParsedDicomFile d(m, Encoding_Latin3 /* 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
1287 ASSERT_EQ(Encoding_Japanese, d.GetEncoding());
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1288 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1289
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1290 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1291 // 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
1292 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
1293 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
1294 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
1295
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1296 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3), OrthancException);
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1297 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1298
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1299 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1300 // 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
1301 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
1302 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
1303 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
1304
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1305 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3), OrthancException);
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1306 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1307
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1308 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1309 // 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
1310 // 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
1311 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
1312 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
1313 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
1314
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1315 ParsedDicomFile d(m, Encoding_Latin3 /* 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
1316 ASSERT_EQ(Encoding_Latin3, d.GetEncoding());
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1317 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1318 }