annotate UnitTestsSources/FromDcmtkTests.cpp @ 3823:897ca3103253 transcoding

new class: DicomStoreUserConnection
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 10 Apr 2020 14:39:20 +0200
parents 0d5f3a438e14
children 6762506ef4fb
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
827
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
6 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
7 * This program is free software: you can redistribute it and/or
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
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
37 #include "../Core/Compatibility.h"
3083
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
38 #include "../Core/DicomNetworking/DicomFindAnswers.h"
2382
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"
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
40 #include "../Core/DicomParsing/DicomWebJsonVisitor.h"
3083
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
41 #include "../Core/DicomParsing/FromDcmtkBridge.h"
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
42 #include "../Core/DicomParsing/Internals/DicomImageDecoder.h"
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
43 #include "../Core/DicomParsing/ToDcmtkBridge.h"
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
44 #include "../Core/Endianness.h"
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
45 #include "../Core/Images/Image.h"
1612
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
46 #include "../Core/Images/ImageBuffer.h"
3083
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
47 #include "../Core/Images/ImageProcessing.h"
1612
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
48 #include "../Core/Images/PngReader.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
49 #include "../Core/Images/PngWriter.h"
3083
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
50 #include "../Core/OrthancException.h"
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
51 #include "../Core/SystemToolbox.h"
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
52 #include "../OrthancServer/ServerToolbox.h"
683d572424b6 IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
53 #include "../Plugins/Engine/PluginsEnumerations.h"
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
54 #include "../Resources/EncodingTests.h"
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
56 #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
57 #include <dcmtk/dcmdata/dcdeftag.h>
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
58 #include <boost/algorithm/string/predicate.hpp>
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
59
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
60 #if ORTHANC_ENABLE_PUGIXML == 1
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
61 # include <pugixml.hpp>
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
62 #endif
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
63
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 using namespace Orthanc;
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 TEST(DicomFormat, Tag)
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
68 ASSERT_EQ("PatientName", FromDcmtkBridge::GetTagName(DicomTag(0x0010, 0x0010), ""));
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ASSERT_EQ(0x0008, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ASSERT_EQ(0x103E, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 t = FromDcmtkBridge::ParseTag("0020-e040");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 ASSERT_EQ(0x0020, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 ASSERT_EQ(0xe040, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 // Test ==() and !=() operators
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
84 TEST(DicomModification, Basic)
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
85 {
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
86 DicomModification m;
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
87 m.SetupAnonymization(DicomVersion_2008);
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
88 //m.SetLevel(DicomRootLevel_Study);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
89 //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
90 //m.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "coucou");
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
91
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
92 ParsedDicomFile o(true);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
93 o.SaveToFile("UnitTestsResults/anon.dcm");
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
94
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
95 for (int i = 0; i < 10; i++)
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 char b[1024];
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
98 sprintf(b, "UnitTestsResults/anon%06d.dcm", i);
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
99 std::unique_ptr<ParsedDicomFile> f(o.Clone(false));
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
100 if (i > 4)
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
101 o.ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, "coucou");
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
102 m.Apply(*f);
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
103 f->SaveToFile(b);
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
104 }
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
105 }
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
106
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
107
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
108 TEST(DicomModification, Anonymization)
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
109 {
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
110 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
111
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
112 const DicomTag privateTag(0x0045, 0x1010);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
113 const DicomTag privateTag2(FromDcmtkBridge::ParseTag("0031-1020"));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
114 ASSERT_TRUE(privateTag.IsPrivate());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
115 ASSERT_TRUE(privateTag2.IsPrivate());
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
116 ASSERT_EQ(0x0031, privateTag2.GetGroup());
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
117 ASSERT_EQ(0x1020, privateTag2.GetElement());
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 std::string s;
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
120 ParsedDicomFile o(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
121 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
122 ASSERT_FALSE(o.GetTagValue(s, privateTag));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
123 o.Insert(privateTag, "private tag", false, "OrthancCreator");
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
124 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
125 ASSERT_STREQ("private tag", s.c_str());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
126
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
127 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
128 ASSERT_THROW(o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_ThrowIfAbsent, "OrthancCreator"), OrthancException);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
129 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
130 o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_IgnoreIfAbsent, "OrthancCreator");
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
131 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
132 o.Replace(privateTag2, std::string("hello"), false, DicomReplaceMode_InsertIfAbsent, "OrthancCreator");
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
133 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
134 ASSERT_STREQ("hello", s.c_str());
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
135 o.Replace(privateTag2, std::string("hello world"), false, DicomReplaceMode_InsertIfAbsent, "OrthancCreator");
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
136 ASSERT_TRUE(o.GetTagValue(s, privateTag2));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
137 ASSERT_STREQ("hello world", s.c_str());
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
138
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
139 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
140 ASSERT_FALSE(Toolbox::IsUuid(s));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
141
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
142 DicomModification m;
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
143 m.SetupAnonymization(DicomVersion_2008);
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
144 m.Keep(privateTag);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
145
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
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
148 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
149 ASSERT_TRUE(Toolbox::IsUuid(s));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
150 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
151 ASSERT_STREQ("private tag", s.c_str());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
152
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
153 m.SetupAnonymization(DicomVersion_2008);
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
154 m.Apply(o);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
155 ASSERT_FALSE(o.GetTagValue(s, privateTag));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
156 }
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
157
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
158
802
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 800
diff changeset
159 #include <dcmtk/dcmdata/dcuid.h>
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 TEST(DicomModification, Png)
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 // 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
164 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
165
1641
4e56b5a206b7 Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
166 std::string m, cc;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1971
diff changeset
167 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
168
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
169 ASSERT_EQ("image/png", m);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
170
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
171 PngReader reader;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
172 reader.ReadFromMemory(cc);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
173
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1417
diff changeset
174 ASSERT_EQ(5u, reader.GetHeight());
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1417
diff changeset
175 ASSERT_EQ(5u, reader.GetWidth());
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
176 ASSERT_EQ(PixelFormat_RGBA32, reader.GetFormat());
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
177
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
178 ParsedDicomFile o(true);
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
179 o.EmbedContent(s);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
180 o.SaveToFile("UnitTestsResults/png1.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
181
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
182 // Red dot, without alpha channel
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
183 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
184 o.EmbedContent(s);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
185 o.SaveToFile("UnitTestsResults/png2.dcm");
800
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 // Check box in Graylevel8
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
188 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII=";
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
189 o.EmbedContent(s);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
190 //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
191 o.SaveToFile("UnitTestsResults/png3.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
192
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
193
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
194 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
195 // Gradient in Graylevel16
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
196
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
197 ImageBuffer img;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
198 img.SetWidth(256);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
199 img.SetHeight(256);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
200 img.SetFormat(PixelFormat_Grayscale16);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
201
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
202 ImageAccessor accessor;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
203 img.GetWriteableAccessor(accessor);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
204
1654
3727a09e7b53 fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1641
diff changeset
205 uint16_t v = 0;
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
206 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
207 {
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
208 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
209 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
210 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
211 *p = v;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
212 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
213 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
214
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
215 o.EmbedImage(accessor);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
216 o.SaveToFile("UnitTestsResults/png4.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
217 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
218 }
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
219
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
220
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
221 TEST(FromDcmtkBridge, Encodings1)
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 for (unsigned int i = 0; i < testEncodingsCount; i++)
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
224 {
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
225 std::string source(testEncodingsEncoded[i]);
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
226 std::string expected(testEncodingsExpected[i]);
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
227 std::string s = Toolbox::ConvertToUtf8(source, testEncodings[i], false);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
228 //std::cout << EnumerationToString(testEncodings[i]) << std::endl;
1089
5ea0b56e850d logging in test
jodogne
parents: 1088
diff changeset
229 EXPECT_EQ(expected, s);
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
230 }
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
231 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
232
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
233
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
234 TEST(FromDcmtkBridge, Enumerations)
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
235 {
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
236 // 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
237 Encoding e;
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
238
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
239 ASSERT_FALSE(GetDicomEncoding(e, ""));
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
240 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
241
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
242 // 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
255 // 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
269 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-4
3219
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
270 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 87")); ASSERT_EQ(Encoding_JapaneseKanji, e);
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
271 ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 159")); //ASSERT_EQ(Encoding_JapaneseKanjiSupplementary, e);
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
272 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 149")); ASSERT_EQ(Encoding_Korean, e);
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
273 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 58")); ASSERT_EQ(Encoding_SimplifiedChinese, e);
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
274
1908
5096681efce6 direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
275 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#table_C.12-5
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
276 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
277 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
278 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
279 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
280
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
281
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
282 TEST(FromDcmtkBridge, Encodings3)
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
283 {
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
284 for (unsigned int i = 0; i < testEncodingsCount; i++)
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
285 {
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
286 //std::cout << EnumerationToString(testEncodings[i]) << std::endl;
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
287 std::string dicom;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
288
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
289 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
290 ParsedDicomFile f(true);
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
291 f.SetEncoding(testEncodings[i]);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
292
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
293 std::string s = Toolbox::ConvertToUtf8(testEncodingsEncoded[i], testEncodings[i], false);
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
294 f.Insert(DICOM_TAG_PATIENT_NAME, s, false, "");
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
295 f.SaveToMemoryBuffer(dicom);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
296 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
297
1347
60cc0ee61edb fix issue 32
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1334
diff changeset
298 if (testEncodings[i] != Encoding_Windows1251)
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
299 {
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
300 ParsedDicomFile g(dicom);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
301
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
302 if (testEncodings[i] != Encoding_Ascii)
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
303 {
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
304 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
305 ASSERT_EQ(testEncodings[i], g.DetectEncoding(hasCodeExtensions));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
306 ASSERT_FALSE(hasCodeExtensions);
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
307 }
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
308
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
309 std::string tag;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
310 ASSERT_TRUE(g.GetTagValue(tag, DICOM_TAG_PATIENT_NAME));
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
311 ASSERT_EQ(std::string(testEncodingsExpected[i]), tag);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
312 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
313 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
314 }
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
315
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
316
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
317 TEST(FromDcmtkBridge, ValueRepresentation)
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
318 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
319 ASSERT_EQ(ValueRepresentation_PersonName,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
320 FromDcmtkBridge::LookupValueRepresentation(DICOM_TAG_PATIENT_NAME));
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
321 ASSERT_EQ(ValueRepresentation_Date,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
322 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0020) /* StudyDate */));
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
323 ASSERT_EQ(ValueRepresentation_Time,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
324 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0030) /* StudyTime */));
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
325 ASSERT_EQ(ValueRepresentation_DateTime,
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
326 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x002a) /* AcquisitionDateTime */));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
327 ASSERT_EQ(ValueRepresentation_NotSupported,
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
328 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
329 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
330
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 TEST(FromDcmtkBridge, ValueRepresentationConversions)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
333 {
3048
8b331be57606 fix build without plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
334 #if ORTHANC_ENABLE_PLUGINS == 1
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
335 ASSERT_EQ(1, ValueRepresentation_ApplicationEntity);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
336 ASSERT_EQ(1, OrthancPluginValueRepresentation_AE);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
337
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
338 for (int i = ValueRepresentation_ApplicationEntity;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
339 i <= ValueRepresentation_NotSupported; i++)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
340 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
341 ValueRepresentation vr = static_cast<ValueRepresentation>(i);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
342
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
343 if (vr == ValueRepresentation_NotSupported)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
344 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
345 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
346 ASSERT_THROW(Plugins::Convert(vr), OrthancException);
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 else if (vr == ValueRepresentation_OtherDouble ||
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
349 vr == ValueRepresentation_OtherLong ||
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
350 vr == ValueRepresentation_UniversalResource ||
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
351 vr == ValueRepresentation_UnlimitedCharacters)
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 // 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
354 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
355 ASSERT_EQ(OrthancPluginValueRepresentation_UN, Plugins::Convert(vr));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
356 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
357 else
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
358 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
359 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
360
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
361 OrthancPluginValueRepresentation plugins = Plugins::Convert(vr);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
362 ASSERT_EQ(vr, Plugins::Convert(plugins));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
363 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
364 }
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
365
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
366 for (int i = OrthancPluginValueRepresentation_AE;
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
367 i <= OrthancPluginValueRepresentation_UT; i++)
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
368 {
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
369 OrthancPluginValueRepresentation plugins = static_cast<OrthancPluginValueRepresentation>(i);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
370 ValueRepresentation orthanc = Plugins::Convert(plugins);
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
371 ASSERT_EQ(plugins, Plugins::Convert(orthanc));
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
372 }
3048
8b331be57606 fix build without plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
373 #endif
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
374 }
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
375
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
376
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
377
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
378 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
379 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
380
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
381 static void CreateSampleJson(Json::Value& a)
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
382 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
383 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
384 Json::Value b = Json::objectValue;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
385 b["PatientName"] = "Hello";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
386 b["PatientID"] = "World";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
387 b["StudyDescription"] = "Toto";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
388 a.append(b);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
389 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
390
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
391 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
392 Json::Value b = Json::objectValue;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
393 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
394 b["PatientID"] = "World2";
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
395 a.append(b);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
396 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
397 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
398
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
399
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
400 namespace Orthanc
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
401 {
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
402 // Namespace for the "FRIEND_TEST()" directive in "FromDcmtkBridge" to apply:
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
403 // 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
404 TEST(FromDcmtkBridge, FromJson)
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
405 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
406 std::unique_ptr<DcmElement> element;
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
407
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
408 {
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
409 Json::Value a;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
410 a = "Hello";
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
411 element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, false, Encoding_Utf8, ""));
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
412
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
413 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
414 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
415 ignoreTagLength.insert(DICOM_TAG_PATIENT_ID);
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
416
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
417 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
418 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength);
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
419 ASSERT_TRUE(b.isMember("0010,0010"));
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
420 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
421
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
422 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
423 DicomToJsonFlags_Default, 3, Encoding_Ascii, false, ignoreTagLength);
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
424 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
425
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
426 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Full,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
427 DicomToJsonFlags_Default, 3, Encoding_Ascii, false, ignoreTagLength);
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
428 ASSERT_TRUE(b["0010,0010"].isObject());
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
429 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
430 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
431 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
432
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
433 ignoreTagLength.insert(DICOM_TAG_PATIENT_NAME);
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
434 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
435 DicomToJsonFlags_Default, 3, Encoding_Ascii, false, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
436 ASSERT_EQ("Hello", b["0010,0010"].asString());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
437 }
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
438
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
439 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
440 Json::Value a;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
441 a = "Hello";
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
442 // Cannot assign a string to a sequence
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
443 ASSERT_THROW(element.reset(FromDcmtkBridge::FromJson(REFERENCED_STUDY_SEQUENCE, a, false, Encoding_Utf8, "")), OrthancException);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
444 }
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
445
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
446 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
447 Json::Value a = Json::arrayValue;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
448 a.append("Hello");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
449 // Cannot assign an array to a string
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
450 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
451 }
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
452
1692
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
453 {
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
454 Json::Value a;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
455 a = "data:application/octet-stream;base64,SGVsbG8="; // echo -n "Hello" | base64
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
456 element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, true, Encoding_Utf8, ""));
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
457
1692
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
458 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
459 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
460 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
461 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
462 ASSERT_EQ("Hello", b["0010,0010"].asString());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
463 }
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
464
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
465 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
466 Json::Value a = Json::arrayValue;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
467 CreateSampleJson(a);
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
468 element.reset(FromDcmtkBridge::FromJson(REFERENCED_STUDY_SEQUENCE, a, true, Encoding_Utf8, ""));
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
469
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
470 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
471 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
472 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
473 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
474 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
475 ASSERT_EQ(Json::arrayValue, b["0008,1110"].type());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
476 ASSERT_EQ(2u, b["0008,1110"].size());
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 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
479
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
480 ASSERT_EQ(3u, b["0008,1110"][i].size());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
481 ASSERT_EQ(2u, b["0008,1110"][1 - i].size());
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
482 ASSERT_EQ(b["0008,1110"][i]["0010,0010"].asString(), "Hello");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
483 ASSERT_EQ(b["0008,1110"][i]["0010,0020"].asString(), "World");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
484 ASSERT_EQ(b["0008,1110"][i]["0008,1030"].asString(), "Toto");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
485 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0010"].asString(), "Hello2");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
486 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0020"].asString(), "World2");
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
487 }
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
488
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
489 {
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
490 Json::Value b;
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
491 std::set<DicomTag> ignoreTagLength;
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2401
diff changeset
492 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Full,
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
493 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength);
2126
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
494
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
495 Json::Value c;
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
496 ServerToolbox::SimplifyTags(c, b, DicomToJsonFormat_Human);
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
497
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
498 a[1]["PatientName"] = "Hello2"; // To remove the Data URI Scheme encoding
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
499 ASSERT_EQ(0, c["ReferencedStudySequence"].compare(a));
03b065778fc3 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
500 }
1692
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
501 }
4eaf164dd574 test SimplifyTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1691
diff changeset
502 }
1690
ae09132e4237 FromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
503 }
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
504
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
505
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
506 TEST(ParsedDicomFile, InsertReplaceStrings)
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
507 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
508 ParsedDicomFile f(true);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
509
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
510 f.Insert(DICOM_TAG_PATIENT_NAME, "World", false, "");
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
511 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
512 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
513 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
514
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
515 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
516 ASSERT_FALSE(f.LookupTransferSyntax(s));
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
517
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
518 ASSERT_THROW(f.Replace(DICOM_TAG_ACCESSION_NUMBER, std::string("Accession"),
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
519 false, DicomReplaceMode_ThrowIfAbsent, ""), OrthancException);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
520 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
521 ASSERT_FALSE(f.GetTagValue(s, DICOM_TAG_ACCESSION_NUMBER));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
522 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
523 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
524 ASSERT_EQ(s, "Accession");
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
525 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
526 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
527 ASSERT_EQ(s, "Accession2");
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
528 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
529 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
530 ASSERT_EQ(s, "Accession3");
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 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
533 ASSERT_EQ(s, "World");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
534 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
535 ASSERT_EQ(s, "Toto");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
536 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
537 ASSERT_EQ(s, "Toto");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
538 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
539 ASSERT_EQ(s, "Tata");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
540 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
541 ASSERT_EQ(s, "Tata");
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
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
544
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
545
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
546
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
547 TEST(ParsedDicomFile, InsertReplaceJson)
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
548 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
549 ParsedDicomFile f(true);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
550
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
551 Json::Value a;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
552 CreateSampleJson(a);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
553
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
554 ASSERT_FALSE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
555 f.Remove(REFERENCED_STUDY_SEQUENCE); // No effect
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
556 f.Insert(REFERENCED_STUDY_SEQUENCE, a, true, "");
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
557 ASSERT_TRUE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
558 ASSERT_THROW(f.Insert(REFERENCED_STUDY_SEQUENCE, a, true, ""), OrthancException);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
559 f.Remove(REFERENCED_STUDY_SEQUENCE);
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
560 ASSERT_FALSE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
561 f.Insert(REFERENCED_STUDY_SEQUENCE, a, true, "");
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
562 ASSERT_TRUE(f.HasTag(REFERENCED_STUDY_SEQUENCE));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
563
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
564 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
565 ASSERT_THROW(f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_ThrowIfAbsent, ""), OrthancException);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
566 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
567 f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_IgnoreIfAbsent, "");
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
568 ASSERT_FALSE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
569 f.Replace(REFERENCED_PATIENT_SEQUENCE, a, false, DicomReplaceMode_InsertIfAbsent, "");
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
570 ASSERT_TRUE(f.HasTag(REFERENCED_PATIENT_SEQUENCE));
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 {
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
573 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
574 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
575
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
576 Json::Value c;
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2117
diff changeset
577 ServerToolbox::SimplifyTags(c, b, DicomToJsonFormat_Human);
1693
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
578
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
579 ASSERT_EQ(0, c["ReferencedPatientSequence"].compare(a));
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
580 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
581 }
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
582
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
583 a = "data:application/octet-stream;base64,VGF0YQ=="; // echo -n "Tata" | base64
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
584 f.Replace(DICOM_TAG_SOP_INSTANCE_UID, a, false, DicomReplaceMode_InsertIfAbsent, ""); // (*)
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
585 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
586
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
587 std::string s;
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
588 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
589 ASSERT_EQ(s, a.asString());
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
590 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
591 ASSERT_EQ(s, a.asString());
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
592 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
593 ASSERT_EQ(s, "Tata");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
594 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
595 ASSERT_EQ(s, "Tata");
558b25228a23 creation of tag hierarchy from json
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1692
diff changeset
596 }
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
597
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 TEST(ParsedDicomFile, JsonEncoding)
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
600 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
601 ParsedDicomFile f(true);
1695
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 for (unsigned int i = 0; i < testEncodingsCount; i++)
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
604 {
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
605 if (testEncodings[i] != Encoding_Windows1251)
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 //std::cout << EnumerationToString(testEncodings[i]) << std::endl;
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
608 f.SetEncoding(testEncodings[i]);
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
609
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
610 if (testEncodings[i] != Encoding_Ascii)
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
611 {
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
612 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
613 ASSERT_EQ(testEncodings[i], f.DetectEncoding(hasCodeExtensions));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
614 ASSERT_FALSE(hasCodeExtensions);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
615 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
616
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
617 Json::Value s = Toolbox::ConvertToUtf8(testEncodingsEncoded[i], testEncodings[i], false);
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
618 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
619
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
620 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
621 f.DatasetToJson(v, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0);
1695
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
622 ASSERT_EQ(v["PatientName"].asString(), std::string(testEncodingsExpected[i]));
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
623 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
624 }
18c02c6987d5 fix for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1693
diff changeset
625 }
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
626
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
627
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
628 TEST(ParsedDicomFile, ToJsonFlags1)
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
629 {
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
630 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7053, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag", 1, 1, "OrthancCreator");
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2107
diff changeset
631 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
632
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
633 ParsedDicomFile f(true);
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
634 f.Insert(DicomTag(0x7050, 0x1000), "Some public tag", false, ""); // Even group => public tag
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
635 f.Insert(DicomTag(0x7052, 0x1000), "Some unknown tag", false, ""); // Even group => public, unknown tag
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
636 f.Insert(DicomTag(0x7053, 0x1000), "Some private tag", false, "OrthancCreator"); // Odd group => private tag
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
637
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
638 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
639 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
640 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
641 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
642 ASSERT_FALSE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
643 ASSERT_FALSE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
644 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
645 ASSERT_EQ(Json::stringValue, v["7050,1000"].type());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
646 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
647
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
648 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_IncludeBinary | DicomToJsonFlags_ConvertBinaryToNull), 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
649 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
650 ASSERT_EQ(7u, v.getMemberNames().size());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
651 ASSERT_FALSE(v.isMember("7052,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
652 ASSERT_TRUE(v.isMember("7050,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
653 ASSERT_TRUE(v.isMember("7053,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
654 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
655 ASSERT_EQ(Json::nullValue, v["7053,1000"].type());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
656
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
657 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags), 0);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
658 ASSERT_EQ(Json::objectValue, v.type());
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
659 ASSERT_EQ(6u, v.getMemberNames().size());
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
660 ASSERT_FALSE(v.isMember("7052,1000"));
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
661 ASSERT_TRUE(v.isMember("7050,1000"));
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
662 ASSERT_FALSE(v.isMember("7053,1000"));
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
663
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
664 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_IncludeBinary), 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
665 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
666 ASSERT_EQ(7u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
667 ASSERT_FALSE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
668 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
669 ASSERT_TRUE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
670 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
671 std::string mime, content;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
672 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
673 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7053,1000"].asString()));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
674 ASSERT_EQ("application/octet-stream", mime);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
675 ASSERT_EQ("Some private tag", content);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
676
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
677 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludeBinary | DicomToJsonFlags_ConvertBinaryToNull), 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
678 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
679 ASSERT_EQ(7u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
680 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
681 ASSERT_TRUE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
682 ASSERT_FALSE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
683 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
684 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
685
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
686 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludeBinary), 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
687 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
688 ASSERT_EQ(7u, v.getMemberNames().size());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
689 ASSERT_TRUE(v.isMember("7050,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
690 ASSERT_TRUE(v.isMember("7052,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
691 ASSERT_FALSE(v.isMember("7053,1000"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
692 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
693 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
694 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7052,1000"].asString()));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
695 ASSERT_EQ("application/octet-stream", mime);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
696 ASSERT_EQ("Some unknown tag", content);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
697
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
698 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludePrivateTags | DicomToJsonFlags_IncludeBinary | DicomToJsonFlags_ConvertBinaryToNull), 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
699 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
700 ASSERT_EQ(8u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
701 ASSERT_TRUE(v.isMember("7050,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
702 ASSERT_TRUE(v.isMember("7052,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
703 ASSERT_TRUE(v.isMember("7053,1000"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
704 ASSERT_EQ("Some public tag", v["7050,1000"].asString());
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
705 ASSERT_EQ(Json::nullValue, v["7052,1000"].type());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
706 ASSERT_EQ(Json::nullValue, v["7053,1000"].type());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
707 }
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
708
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
709
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
710 TEST(ParsedDicomFile, ToJsonFlags2)
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
711 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
712 ParsedDicomFile f(true);
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
713 f.Insert(DICOM_TAG_PIXEL_DATA, "Pixels", false, "");
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
714
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
715 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
716 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
717 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
718 ASSERT_EQ(5u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
719 ASSERT_FALSE(v.isMember("7fe0,0010"));
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
720
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
721 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
722 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
723 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
724 ASSERT_TRUE(v.isMember("7fe0,0010"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
725 ASSERT_EQ(Json::nullValue, v["7fe0,0010"].type());
1736
b953c6eef28d ToJson: IncludePrivateTags and IncludeUnknownTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1735
diff changeset
726
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
727 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
728 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
729 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
730 ASSERT_TRUE(v.isMember("7fe0,0010"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
731 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
732 ASSERT_EQ("Pixels", v["7fe0,0010"].asString());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
733
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2126
diff changeset
734 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePixelData, 0);
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
735 ASSERT_EQ(Json::objectValue, v.type());
1971
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
736 ASSERT_EQ(6u, v.getMemberNames().size());
1739
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
737 ASSERT_TRUE(v.isMember("7fe0,0010"));
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
738 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type());
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
739 std::string mime, content;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1971
diff changeset
740 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
741 ASSERT_EQ("application/octet-stream", mime);
df331354cea2 include binary in ToJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1736
diff changeset
742 ASSERT_EQ("Pixels", content);
1735
a001f6226c7c primitives for flags in dicom-to-json conversions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
743 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
744
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
745
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
746 TEST(DicomFindAnswers, Basic)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
747 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
748 DicomFindAnswers a(false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
749
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
750 {
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
751 DicomMap m;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
752 m.SetValue(DICOM_TAG_PATIENT_ID, "hello", false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
753 a.Add(m);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
754 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
755
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
756 {
1805
f08978b1f45b c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
757 ParsedDicomFile d(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
758 d.ReplacePlainString(DICOM_TAG_PATIENT_ID, "my");
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
759 a.Add(d);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
760 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
761
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
762 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
763 DicomMap m;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
764 m.SetValue(DICOM_TAG_PATIENT_ID, "world", false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
765 a.Add(m);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
766 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
767
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
768 Json::Value j;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
769 a.ToJson(j, true);
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
770 ASSERT_EQ(3u, j.size());
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
771
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
772 //std::cout << j;
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
773 }
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
774
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
775
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
776 TEST(ParsedDicomFile, FromJson)
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
777 {
2117
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
778 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
779 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7059, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag3", 1, 1, "");
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
780 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
781
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
782 Json::Value v;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
783 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
784
2117
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
785 // Test the private creator
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
786 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
787 ASSERT_EQ("MyPrivateTag2", FromDcmtkBridge::GetTagName(DicomTag(0x7057, 0x1000), "ORTHANC"));
87b395a77c41 fix unit test
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
788
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
789 {
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
790 v["SOPClassUID"] = sopClassUid;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
791 v["SpecificCharacterSet"] = "ISO_IR 148"; // This is latin-5
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
792 v["PatientName"] = "Sébastien";
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
793 v["7050-1000"] = "Some public tag"; // Even group => public tag
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
794 v["7052-1000"] = "Some unknown tag"; // Even group => public, unknown tag
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
795 v["7057-1000"] = "Some private tag"; // Odd group => private tag
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
796 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
797
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
798 std::string s;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
799 Toolbox::EncodeDataUriScheme(s, "application/octet-stream", "Sebastien");
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
800 v["StudyDescription"] = s;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
801
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
802 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
803 v["0040,0100"] = Json::arrayValue; // ScheduledProcedureStepSequence
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
804
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
805 Json::Value vv;
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
806 vv["Modality"] = "MR";
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
807 v["0040,0100"].append(vv);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
808
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
809 vv["Modality"] = "CT";
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
810 v["0040,0100"].append(vv);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
811 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
812
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
813 const DicomToJsonFlags toJsonFlags = static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeBinary |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
814 DicomToJsonFlags_IncludePixelData |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
815 DicomToJsonFlags_IncludePrivateTags |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
816 DicomToJsonFlags_IncludeUnknownTags |
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
817 DicomToJsonFlags_ConvertBinaryToAscii);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
819
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
820 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
821 std::unique_ptr<ParsedDicomFile> dicom
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
822 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers), ""));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
823
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
824 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
825 dicom->DatasetToJson(vv, DicomToJsonFormat_Human, toJsonFlags, 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
826
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
827 ASSERT_EQ(vv["SOPClassUID"].asString(), sopClassUid);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
828 ASSERT_EQ(vv["MediaStorageSOPClassUID"].asString(), sopClassUid);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
829 ASSERT_TRUE(vv.isMember("SOPInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
830 ASSERT_TRUE(vv.isMember("SeriesInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
831 ASSERT_TRUE(vv.isMember("StudyInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
832 ASSERT_TRUE(vv.isMember("PatientID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
833 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
834
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
835
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
836 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
837 std::unique_ptr<ParsedDicomFile> dicom
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
838 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_GenerateIdentifiers), ""));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
839
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
840 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
841 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
842
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
843 std::string mime, content;
1981
4b545a8b1f95 return code in Toolbox::DecodeDataUriScheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1971
diff changeset
844 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, vv["PixelData"].asString()));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
845 ASSERT_EQ("application/octet-stream", mime);
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
846 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
847 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
848
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
849
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
850 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
851 std::unique_ptr<ParsedDicomFile> dicom
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
852 (ParsedDicomFile::CreateFromJson(v, static_cast<DicomFromJsonFlags>(DicomFromJsonFlags_DecodeDataUriScheme), ""));
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
853
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
854 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
855 dicom->DatasetToJson(vv, DicomToJsonFormat_Short, toJsonFlags, 0);
1818
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
856
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
857 ASSERT_FALSE(vv.isMember("SOPInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
858 ASSERT_FALSE(vv.isMember("SeriesInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
859 ASSERT_FALSE(vv.isMember("StudyInstanceUID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
860 ASSERT_FALSE(vv.isMember("PatientID"));
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
861 ASSERT_EQ(2u, vv["0040,0100"].size());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
862 ASSERT_EQ("MR", vv["0040,0100"][0]["0008,0060"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
863 ASSERT_EQ("CT", vv["0040,0100"][1]["0008,0060"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
864 ASSERT_EQ("Some public tag", vv["7050,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
865 ASSERT_EQ("Some unknown tag", vv["7052,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
866 ASSERT_EQ("Some private tag", vv["7057,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
867 ASSERT_EQ("Some private tag2", vv["7059,1000"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
868 ASSERT_EQ("Sébastien", vv["0010,0010"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
869 ASSERT_EQ("Sebastien", vv["0008,1030"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
870 ASSERT_EQ("ISO_IR 148", vv["0008,0005"].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
871 ASSERT_EQ("5", vv[DICOM_TAG_ROWS.Format()].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
872 ASSERT_EQ("5", vv[DICOM_TAG_COLUMNS.Format()].asString());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
873 ASSERT_TRUE(vv[DICOM_TAG_PIXEL_DATA.Format()].asString().empty());
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
874 }
1065401501fb ParsedDicomFile::CreateFromJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1805
diff changeset
875 }
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
876
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
877
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
878
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
879 TEST(TestImages, PatternGrayscale8)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
880 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
881 static const char* PATH = "UnitTestsResults/PatternGrayscale8.dcm";
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
882
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
883 Orthanc::Image image(Orthanc::PixelFormat_Grayscale8, 256, 256, false);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
884
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
885 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
886 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
887 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
888 for (int x = 0; x < 256; x++, p++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
889 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
890 *p = y;
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 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
893
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
894 Orthanc::ImageAccessor r;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
895
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
896 image.GetRegion(r, 32, 32, 64, 192);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
897 Orthanc::ImageProcessing::Set(r, 0);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
898
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
899 image.GetRegion(r, 160, 32, 64, 192);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
900 Orthanc::ImageProcessing::Set(r, 255);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
901
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
902 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
903 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
904 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
905 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
906 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
907 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
908 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
909 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale8");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
910 f.EmbedImage(image);
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 f.SaveToFile(PATH);
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 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
916 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
917 Orthanc::SystemToolbox::ReadFile(s, PATH);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
918 Orthanc::ParsedDicomFile f(s);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
919
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
920 std::unique_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
921 ASSERT_EQ(256u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
922 ASSERT_EQ(256u, decoded->GetHeight());
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
923 ASSERT_EQ(Orthanc::PixelFormat_Grayscale8, decoded->GetFormat());
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
924
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
925 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
926 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
927 const void* a = image.GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
928 const void* b = decoded->GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
929 ASSERT_EQ(0, memcmp(a, b, 256));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
930 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
931 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
932 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
933
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
934
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
935 TEST(TestImages, PatternRGB)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
936 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
937 static const char* PATH = "UnitTestsResults/PatternRGB24.dcm";
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
938
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
939 Orthanc::Image image(Orthanc::PixelFormat_RGB24, 384, 256, false);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
940
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
941 for (int y = 0; y < 256; y++)
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 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
944 for (int x = 0; x < 128; x++, p += 3)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
945 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
946 p[0] = y;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
947 p[1] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
948 p[2] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
949 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
950 for (int x = 128; x < 128 * 2; x++, p += 3)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
951 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
952 p[0] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
953 p[1] = 255 - y;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
954 p[2] = 0;
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 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
957 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
958 p[0] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
959 p[1] = 0;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
960 p[2] = y;
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 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
963
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
964 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
965 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
966 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
967 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
968 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
969 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
970 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
971 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "RGB24");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
972 f.EmbedImage(image);
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 f.SaveToFile(PATH);
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
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
977 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
978 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
979 Orthanc::SystemToolbox::ReadFile(s, PATH);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
980 Orthanc::ParsedDicomFile f(s);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
981
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
982 std::unique_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
983 ASSERT_EQ(384u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
984 ASSERT_EQ(256u, decoded->GetHeight());
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
985 ASSERT_EQ(Orthanc::PixelFormat_RGB24, decoded->GetFormat());
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
986
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
987 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
988 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
989 const void* a = image.GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
990 const void* b = decoded->GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
991 ASSERT_EQ(0, memcmp(a, b, 3 * 384));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
992 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
993 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
994 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
995
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
996
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
997 TEST(TestImages, PatternUint16)
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
998 {
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
999 static const char* PATH = "UnitTestsResults/PatternGrayscale16.dcm";
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1000
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
1001 Orthanc::Image image(Orthanc::PixelFormat_Grayscale16, 256, 256, false);
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1002
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1003 uint16_t v = 0;
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1004 for (int y = 0; y < 256; y++)
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1005 {
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1006 uint16_t *p = reinterpret_cast<uint16_t*>(image.GetRow(y));
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1007 for (int x = 0; x < 256; x++, v++, p++)
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1008 {
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1009 *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
1010 }
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1011 }
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1012
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1013 Orthanc::ImageAccessor r;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1014
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1015 image.GetRegion(r, 32, 32, 64, 192);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1016 Orthanc::ImageProcessing::Set(r, 0);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1017
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1018 image.GetRegion(r, 160, 32, 64, 192);
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1019 Orthanc::ImageProcessing::Set(r, 65535);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1020
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1021 {
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1022 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1023 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
1024 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
1025 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
1026 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
1027 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
1028 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale16");
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1029 f.EmbedImage(image);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1030
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1031 f.SaveToFile(PATH);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1032 }
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1033
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1034 {
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1035 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
1036 Orthanc::SystemToolbox::ReadFile(s, PATH);
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1037 Orthanc::ParsedDicomFile f(s);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1038
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1039 std::unique_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
1040 ASSERT_EQ(256u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
1041 ASSERT_EQ(256u, decoded->GetHeight());
1940
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1042 ASSERT_EQ(Orthanc::PixelFormat_Grayscale16, decoded->GetFormat());
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1043
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1044 for (int y = 0; y < 256; y++)
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1045 {
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1046 const void* a = image.GetConstRow(y);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1047 const void* b = decoded->GetConstRow(y);
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1048 ASSERT_EQ(0, memcmp(a, b, 512));
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1049 }
5514d37176b4 PatternUint16
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1937
diff changeset
1050 }
1937
3756bedaaa36 test pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
1051 }
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1052
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1053
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1054 TEST(TestImages, PatternInt16)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1055 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1056 static const char* PATH = "UnitTestsResults/PatternSignedGrayscale16.dcm";
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1057
2107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
1058 Orthanc::Image image(Orthanc::PixelFormat_SignedGrayscale16, 256, 256, false);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1059
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1060 int16_t v = -32768;
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1061 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1062 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1063 int16_t *p = reinterpret_cast<int16_t*>(image.GetRow(y));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1064 for (int x = 0; x < 256; x++, v++, p++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1065 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1066 *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
1067 }
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
2861
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1070 Orthanc::ImageAccessor r;
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1071 image.GetRegion(r, 32, 32, 64, 192);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1072 Orthanc::ImageProcessing::Set(r, -32768);
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1073
9b4251721f22 ImageAccessor now non-copyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
1074 image.GetRegion(r, 160, 32, 64, 192);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1075 Orthanc::ImageProcessing::Set(r, 32767);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1076
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1077 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1078 ParsedDicomFile f(true);
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1981
diff changeset
1079 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
1080 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
1081 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
1082 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
1083 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
1084 f.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, "SignedGrayscale16");
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1085 f.EmbedImage(image);
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 f.SaveToFile(PATH);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1088 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1089
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1090 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1091 std::string s;
2140
aa4b8895cd23 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
1092 Orthanc::SystemToolbox::ReadFile(s, PATH);
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1093 Orthanc::ParsedDicomFile f(s);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1094
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1095 std::unique_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
1096 ASSERT_EQ(256u, decoded->GetWidth());
869a87c08673 fix for mingw <= 4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1970
diff changeset
1097 ASSERT_EQ(256u, decoded->GetHeight());
1941
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1098 ASSERT_EQ(Orthanc::PixelFormat_SignedGrayscale16, decoded->GetFormat());
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1099
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1100 for (int y = 0; y < 256; y++)
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1101 {
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1102 const void* a = image.GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1103 const void* b = decoded->GetConstRow(y);
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1104 ASSERT_EQ(0, memcmp(a, b, 512));
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1105 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1106 }
d7b176f7dd1b test dicom patterns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1940
diff changeset
1107 }
2202
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
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1110
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1111 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
1112 Encoding expected)
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 const char* value = NULL;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1115 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
1116
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1117 Encoding encoding;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1118 ASSERT_TRUE(GetDicomEncoding(encoding, value));
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1119 ASSERT_EQ(expected, encoding);
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 TEST(ParsedDicomFile, DicomMapEncodings1)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1124 {
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2326
diff changeset
1125 SetDefaultDicomEncoding(Encoding_Ascii);
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2326
diff changeset
1126 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
1127
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 DicomMap m;
3342
63f59ad9381a Fix issue #136 (C-Find request fails when found DICOM file does not have certain tags)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3311
diff changeset
1130 ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1131 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
1132 CheckEncoding(dicom, Encoding_Ascii);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1133 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1134
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1135 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1136 DicomMap m;
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1137 ParsedDicomFile dicom(m, Encoding_Latin4, false);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1138 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
1139 CheckEncoding(dicom, Encoding_Latin4);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1140 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1141
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1142 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1143 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1144 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false);
3342
63f59ad9381a Fix issue #136 (C-Find request fails when found DICOM file does not have certain tags)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3311
diff changeset
1145 ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1146 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
1147 CheckEncoding(dicom, Encoding_Latin5);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1148 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1149
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1150 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1151 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1152 m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false);
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1153 ParsedDicomFile dicom(m, Encoding_Latin1, false);
2411
82d5e305fbd9 fix gcc warnings in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2409
diff changeset
1154 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
1155 CheckEncoding(dicom, Encoding_Latin5);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1156 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1157 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1158
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 TEST(ParsedDicomFile, DicomMapEncodings2)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1161 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1162 const char* utf8 = NULL;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1163 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
1164 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1165 if (testEncodings[i] == Encoding_Utf8)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1166 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1167 utf8 = testEncodingsEncoded[i];
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1168 break;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1169 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1170 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1171
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1172 ASSERT_TRUE(utf8 != NULL);
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 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
1175 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1176 // 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
1177 if (testEncodings[i] != Encoding_Windows1251)
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 // 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
1181 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
1182 ASSERT_STREQ(testEncodingsEncoded[i], encoded.c_str());
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1183 std::string decoded = Toolbox::ConvertToUtf8(encoded, testEncodings[i], false);
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1184 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
1185
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1186 if (testEncodings[i] != Encoding_Chinese)
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1187 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1188 // 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
1189 // 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
1190
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1191 std::string encoded = Toolbox::ConvertToUtf8(Toolbox::ConvertFromUtf8(utf8, testEncodings[i]), testEncodings[i], false);
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1192 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
1193 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1194 }
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 Json::Value v;
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 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1200 DicomMap m;
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
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1203 ParsedDicomFile dicom(m, testEncodings[i], false);
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1204
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1205 const char* encoded = NULL;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1206 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
1207 ASSERT_STREQ(testEncodingsEncoded[i], encoded);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1208
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1209 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
1210
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1211 Encoding encoding;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1212 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
1213 ASSERT_EQ(encoding, testEncodings[i]);
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1214 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
1215 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1216
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1217
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1218 {
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1219 DicomMap m;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1220 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
1221 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
1222
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1223 ParsedDicomFile dicom(m, testEncodings[i], false);
2202
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1224
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1225 Json::Value v2;
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1226 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
1227
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1228 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
1229 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
1230 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1231 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1232 }
9b373b7d6713 Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2142
diff changeset
1233 }
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1234
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1235
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1236 TEST(ParsedDicomFile, ChangeEncoding)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1237 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1238 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
1239 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1240 // 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
1241 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
1242 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1243 DicomMap m;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1244 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
1245
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1246 std::string tag;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1247
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1248 ParsedDicomFile dicom(m, Encoding_Utf8, false);
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1249 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1250 ASSERT_EQ(Encoding_Utf8, dicom.DetectEncoding(hasCodeExtensions));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1251 ASSERT_FALSE(hasCodeExtensions);
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1252 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
1253 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
1254
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1255 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1256 Json::Value v;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1257 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
1258 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
1259 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
1260 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1261
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1262 dicom.ChangeEncoding(testEncodings[i]);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1263
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1264 ASSERT_EQ(testEncodings[i], dicom.DetectEncoding(hasCodeExtensions));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1265 ASSERT_FALSE(hasCodeExtensions);
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1266
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1267 const char* c = NULL;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1268 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
1269 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
1270
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1271 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
1272 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
1273
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1274 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1275 Json::Value v;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1276 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
1277 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
1278 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
1279 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1280 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1281 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
1282 }
2326
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1283
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1284
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1285 TEST(Toolbox, CaseWithAccents)
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1286 {
423d3b692bb9 Upgrade to Boost 1.64.0, and Toolbox::ToUpperCaseWithAccents
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
1287 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
1288 }
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
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
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 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
1293 {
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 {
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 // 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
1296 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
1297 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
1298
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1299 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false);
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1300
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1301 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1302 ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1303 ASSERT_FALSE(hasCodeExtensions);
2445
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
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
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 // 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
1308 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
1309 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
1310 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
1311
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1312 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false);
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1313
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1314 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1315 ASSERT_EQ(Encoding_Japanese, d.DetectEncoding(hasCodeExtensions));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1316 ASSERT_FALSE(hasCodeExtensions);
2445
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
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
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1319 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1320 // 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
1321 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
1322 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
1323 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
1324
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1325 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false), OrthancException);
2445
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1326 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1327
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1328 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1329 // 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
1330 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
1331 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
1332 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
1333
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1334 ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false), OrthancException);
2445
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1335 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1336
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1337 {
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1338 // 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
1339 // 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
1340 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
1341 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
1342 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
1343
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3229
diff changeset
1344 ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false);
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1345
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1346 bool hasCodeExtensions;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1347 ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1348 ASSERT_FALSE(hasCodeExtensions);
2445
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1349 }
6e5bc5c6d1a4 Fix to allow creating DICOM instances with empty Specific Character Set (0008,0005)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2411
diff changeset
1350 }
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1351
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1352
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1353
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1354 TEST(Toolbox, RemoveIso2022EscapeSequences)
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1355 {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1356 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1357 // | one-byte control messages |
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1358 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1359
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1360 static const uint8_t iso2022_cstr_oneByteControl[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1361 0x0f, 0x41,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1362 0x0e, 0x42,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1363 0x8e, 0x1b, 0x4e, 0x43,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1364 0x8f, 0x1b, 0x4f, 0x44,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1365 0x8e, 0x1b, 0x4a, 0x45,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1366 0x8f, 0x1b, 0x4a, 0x46,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1367 0x50, 0x51, 0x52, 0x00
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1368 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1369
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1370 static const uint8_t iso2022_cstr_oneByteControl_ref[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1371 0x41,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1372 0x42,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1373 0x43,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1374 0x44,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1375 0x8e, 0x1b, 0x4a, 0x45,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1376 0x8f, 0x1b, 0x4a, 0x46,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1377 0x50, 0x51, 0x52, 0x00
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1378 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1379
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1380 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1381 // | two-byte control messages |
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1382 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1383
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1384 static const uint8_t iso2022_cstr_twoByteControl[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1385 0x1b, 0x6e, 0x41,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1386 0x1b, 0x6f, 0x42,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1387 0x1b, 0x4e, 0x43,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1388 0x1b, 0x4f, 0x44,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1389 0x1b, 0x7e, 0x45,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1390 0x1b, 0x7d, 0x46,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1391 0x1b, 0x7c, 0x47, 0x00
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1392 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1393
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1394 static const uint8_t iso2022_cstr_twoByteControl_ref[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1395 0x41,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1396 0x42,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1397 0x43,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1398 0x44,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1399 0x45,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1400 0x46,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1401 0x47, 0x00
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1402 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1403
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1404 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1405 // | various-length escape sequences |
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1406 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1407
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1408 static const uint8_t iso2022_cstr_escapeSequence[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1409 0x1b, 0x40, 0x41, // 1b and 40 should not be removed (invalid esc seq)
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1410 0x1b, 0x50, 0x42, // ditto
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1411 0x1b, 0x7f, 0x43, // ditto
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1412 0x1b, 0x21, 0x4a, 0x44, // this will match
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1413 0x1b, 0x20, 0x21, 0x2f, 0x40, 0x45, // this will match
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1414 0x1b, 0x20, 0x21, 0x2f, 0x2f, 0x40, 0x46, // this will match too
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1415 0x1b, 0x20, 0x21, 0x2f, 0x1f, 0x47, 0x48, 0x00 // this will NOT match!
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1416 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1417
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1418 static const uint8_t iso2022_cstr_escapeSequence_ref[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1419 0x1b, 0x40, 0x41, // 1b and 40 should not be removed (invalid esc seq)
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1420 0x1b, 0x50, 0x42, // ditto
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1421 0x1b, 0x7f, 0x43, // ditto
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1422 0x44, // this will match
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1423 0x45, // this will match
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1424 0x46, // this will match too
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1425 0x1b, 0x20, 0x21, 0x2f, 0x1f, 0x47, 0x48, 0x00 // this will NOT match!
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1426 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1427
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1428
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1429 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1430 // | a real-world japanese sample |
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1431 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1432
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1433 static const uint8_t iso2022_cstr_real_ir13[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1434 0xd4, 0xcf, 0xc0, 0xde, 0x5e, 0xc0, 0xdb, 0xb3,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1435 0x3d, 0x1b, 0x24, 0x42, 0x3b, 0x33, 0x45, 0x44,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1436 0x1b, 0x28, 0x4a, 0x5e, 0x1b, 0x24, 0x42, 0x42,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1437 0x40, 0x4f, 0x3a, 0x1b, 0x28, 0x4a, 0x3d, 0x1b,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1438 0x24, 0x42, 0x24, 0x64, 0x24, 0x5e, 0x24, 0x40,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1439 0x1b, 0x28, 0x4a, 0x5e, 0x1b, 0x24, 0x42, 0x24,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1440 0x3f, 0x24, 0x6d, 0x24, 0x26, 0x1b, 0x28, 0x4a, 0x00
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1441 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1442
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1443 static const uint8_t iso2022_cstr_real_ir13_ref[] = {
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1444 0xd4, 0xcf, 0xc0, 0xde, 0x5e, 0xc0, 0xdb, 0xb3,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1445 0x3d,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1446 0x3b, 0x33, 0x45, 0x44,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1447 0x5e,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1448 0x42,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1449 0x40, 0x4f, 0x3a,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1450 0x3d,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1451 0x24, 0x64, 0x24, 0x5e, 0x24, 0x40,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1452 0x5e,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1453 0x24,
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1454 0x3f, 0x24, 0x6d, 0x24, 0x26, 0x00
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1455 };
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1456
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1457
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1458
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1459 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1460 // | the actual test |
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1461 // +----------------------------------+
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1462
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1463 std::string iso2022_str_oneByteControl(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1464 reinterpret_cast<const char*>(iso2022_cstr_oneByteControl));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1465 std::string iso2022_str_oneByteControl_ref(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1466 reinterpret_cast<const char*>(iso2022_cstr_oneByteControl_ref));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1467 std::string iso2022_str_twoByteControl(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1468 reinterpret_cast<const char*>(iso2022_cstr_twoByteControl));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1469 std::string iso2022_str_twoByteControl_ref(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1470 reinterpret_cast<const char*>(iso2022_cstr_twoByteControl_ref));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1471 std::string iso2022_str_escapeSequence(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1472 reinterpret_cast<const char*>(iso2022_cstr_escapeSequence));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1473 std::string iso2022_str_escapeSequence_ref(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1474 reinterpret_cast<const char*>(iso2022_cstr_escapeSequence_ref));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1475 std::string iso2022_str_real_ir13(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1476 reinterpret_cast<const char*>(iso2022_cstr_real_ir13));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1477 std::string iso2022_str_real_ir13_ref(
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1478 reinterpret_cast<const char*>(iso2022_cstr_real_ir13_ref));
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1479
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1480 std::string dest;
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1481
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1482 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_oneByteControl);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1483 ASSERT_EQ(dest, iso2022_str_oneByteControl_ref);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1484
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1485 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_twoByteControl);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1486 ASSERT_EQ(dest, iso2022_str_twoByteControl_ref);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1487
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1488 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_escapeSequence);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1489 ASSERT_EQ(dest, iso2022_str_escapeSequence_ref);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1490
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1491 Toolbox::RemoveIso2022EscapeSequences(dest, iso2022_str_real_ir13);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1492 ASSERT_EQ(dest, iso2022_str_real_ir13_ref);
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3083
diff changeset
1493 }
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1494
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1495
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1496
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1497 static std::string DecodeFromSpecification(const std::string& s)
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1498 {
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1499 std::vector<std::string> tokens;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1500 Toolbox::TokenizeString(tokens, s, ' ');
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1501
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1502 std::string result;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1503 result.resize(tokens.size());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1504
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1505 for (size_t i = 0; i < tokens.size(); i++)
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1506 {
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1507 std::vector<std::string> components;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1508 Toolbox::TokenizeString(components, tokens[i], '/');
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1509
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1510 if (components.size() != 2)
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1511 {
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1512 throw;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1513 }
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1514
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1515 int a = boost::lexical_cast<int>(components[0]);
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1516 int b = boost::lexical_cast<int>(components[1]);
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1517 if (a < 0 || a > 15 ||
3228
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1518 b < 0 || b > 15 ||
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1519 (a == 0 && b == 0))
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1520 {
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1521 throw;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1522 }
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1523
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1524 result[i] = static_cast<uint8_t>(a * 16 + b);
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1525 }
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1526
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1527 return result;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1528 }
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1529
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1530
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1531
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1532 // Compatibility wrapper
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1533 static pugi::xpath_node SelectNode(const pugi::xml_document& doc,
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1534 const char* xpath)
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1535 {
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1536 #if PUGIXML_VERSION <= 140
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1537 return doc.select_single_node(xpath); // Deprecated in pugixml 1.5
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1538 #else
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1539 return doc.select_node(xpath);
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1540 #endif
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1541 }
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1542
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1543
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1544 TEST(Toolbox, EncodingsKorean)
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1545 {
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1546 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_I.2.html
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1547
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1548 std::string korean = DecodeFromSpecification(
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1549 "04/08 06/15 06/14 06/07 05/14 04/07 06/09 06/12 06/04 06/15 06/14 06/07 03/13 "
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1550 "01/11 02/04 02/09 04/03 15/11 15/03 05/14 01/11 02/04 02/09 04/03 13/01 12/14 "
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1551 "13/04 13/07 03/13 01/11 02/04 02/09 04/03 12/08 10/11 05/14 01/11 02/04 02/09 "
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1552 "04/03 11/01 14/06 11/05 11/15");
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1553
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1554 // This array can be re-generated using command-line:
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1555 // echo -n "Hong^Gildong=..." | hexdump -v -e '14/1 "0x%02x, "' -e '"\n"'
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1556 static const uint8_t utf8raw[] = {
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1557 0x48, 0x6f, 0x6e, 0x67, 0x5e, 0x47, 0x69, 0x6c, 0x64, 0x6f, 0x6e, 0x67, 0x3d, 0xe6,
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1558 0xb4, 0xaa, 0x5e, 0xe5, 0x90, 0x89, 0xe6, 0xb4, 0x9e, 0x3d, 0xed, 0x99, 0x8d, 0x5e,
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1559 0xea, 0xb8, 0xb8, 0xeb, 0x8f, 0x99
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1560 };
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1561
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1562 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw));
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1563
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1564 ParsedDicomFile dicom(false);
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1565 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 149");
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1566 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
3228
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1567 (DCM_PatientName, korean.c_str(), OFBool(true)).good());
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1568
3225
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1569 bool hasCodeExtensions;
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1570 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1571 ASSERT_EQ(Encoding_Korean, encoding);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1572 ASSERT_TRUE(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1573
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1574 std::string value;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1575 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1576 ASSERT_EQ(utf8, value);
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1577
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1578 DicomWebJsonVisitor visitor;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1579 dicom.Apply(visitor);
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1580 ASSERT_EQ(utf8.substr(0, 12), visitor.GetResult()["00100010"]["Value"][0]["Alphabetic"].asString());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1581 ASSERT_EQ(utf8.substr(13, 10), visitor.GetResult()["00100010"]["Value"][0]["Ideographic"].asString());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1582 ASSERT_EQ(utf8.substr(24), visitor.GetResult()["00100010"]["Value"][0]["Phonetic"].asString());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1583
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1584 #if ORTHANC_ENABLE_PUGIXML == 1
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1585 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.3.html#table_F.3.1-1
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1586 std::string xml;
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1587 visitor.FormatXml(xml);
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1588
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1589 pugi::xml_document doc;
3222
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3221
diff changeset
1590 doc.load_buffer(xml.c_str(), xml.size());
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1591
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1592 pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value");
3420
0a0e7eca95ae fix encoding in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3342
diff changeset
1593 ASSERT_STREQ("ISO 2022 IR 149", node.node().text().as_string());
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1594
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1595 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1596 ASSERT_STREQ("CS", node.node().attribute("vr").value());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1597
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1598 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1599 ASSERT_STREQ("PN", node.node().attribute("vr").value());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1600
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1601 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1602 ASSERT_STREQ("Hong", node.node().text().as_string());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1603
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1604 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1605 ASSERT_STREQ("Gildong", node.node().text().as_string());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1606
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1607 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1608 ASSERT_EQ(utf8.substr(13, 3), node.node().text().as_string());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1609
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1610 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1611 ASSERT_EQ(utf8.substr(17, 6), node.node().text().as_string());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1612
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1613 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1614 ASSERT_EQ(utf8.substr(24, 3), node.node().text().as_string());
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1615
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1616 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName");
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1617 ASSERT_EQ(utf8.substr(28), node.node().text().as_string());
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1618 #endif
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1619
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1620 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1621 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1622 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1623 ASSERT_EQ(2u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1624
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1625 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1626 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_SPECIFIC_CHARACTER_SET, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1627 ASSERT_EQ("ISO 2022 IR 149", s);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1628
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1629 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1630 std::vector<std::string> v;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1631 Toolbox::TokenizeString(v, s, '=');
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1632 ASSERT_EQ(3u, v.size());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1633 ASSERT_EQ("Hong^Gildong", v[0]);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1634 ASSERT_EQ(utf8, s);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1635 }
3221
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1636 }
4be505c2ac56 Separation of ideographic and phonetic characters in DICOMweb JSON and XML
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3219
diff changeset
1637
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1638
3225
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1639 TEST(Toolbox, EncodingsJapaneseKanji)
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1640 {
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1641 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_H.3.html
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1642
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1643 std::string japanese = DecodeFromSpecification(
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1644 "05/09 06/01 06/13 06/01 06/04 06/01 05/14 05/04 06/01 07/02 06/15 07/05 03/13 "
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1645 "01/11 02/04 04/02 03/11 03/03 04/05 04/04 01/11 02/08 04/02 05/14 01/11 02/04 "
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1646 "04/02 04/02 04/00 04/15 03/10 01/11 02/08 04/02 03/13 01/11 02/04 04/02 02/04 "
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1647 "06/04 02/04 05/14 02/04 04/00 01/11 02/08 04/02 05/14 01/11 02/04 04/02 02/04 "
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1648 "03/15 02/04 06/13 02/04 02/06 01/11 02/08 04/02");
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1649
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1650 // This array can be re-generated using command-line:
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1651 // echo -n "Yamada^Tarou=..." | hexdump -v -e '14/1 "0x%02x, "' -e '"\n"'
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1652 static const uint8_t utf8raw[] = {
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1653 0x59, 0x61, 0x6d, 0x61, 0x64, 0x61, 0x5e, 0x54, 0x61, 0x72, 0x6f, 0x75, 0x3d, 0xe5,
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1654 0xb1, 0xb1, 0xe7, 0x94, 0xb0, 0x5e, 0xe5, 0xa4, 0xaa, 0xe9, 0x83, 0x8e, 0x3d, 0xe3,
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1655 0x82, 0x84, 0xe3, 0x81, 0xbe, 0xe3, 0x81, 0xa0, 0x5e, 0xe3, 0x81, 0x9f, 0xe3, 0x82,
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1656 0x8d, 0xe3, 0x81, 0x86
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1657 };
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1658
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1659 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw));
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1660
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1661 ParsedDicomFile dicom(false);
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1662 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 87");
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1663 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
3228
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1664 (DCM_PatientName, japanese.c_str(), OFBool(true)).good());
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1665
3225
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1666 bool hasCodeExtensions;
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1667 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1668 ASSERT_EQ(Encoding_JapaneseKanji, encoding);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1669 ASSERT_TRUE(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1670
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1671 std::string value;
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1672 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1673 ASSERT_EQ(utf8, value);
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1674
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1675 DicomWebJsonVisitor visitor;
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1676 dicom.Apply(visitor);
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1677 ASSERT_EQ(utf8.substr(0, 12), visitor.GetResult()["00100010"]["Value"][0]["Alphabetic"].asString());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1678 ASSERT_EQ(utf8.substr(13, 13), visitor.GetResult()["00100010"]["Value"][0]["Ideographic"].asString());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1679 ASSERT_EQ(utf8.substr(27), visitor.GetResult()["00100010"]["Value"][0]["Phonetic"].asString());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1680
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1681 #if ORTHANC_ENABLE_PUGIXML == 1
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1682 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.3.html#table_F.3.1-1
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1683 std::string xml;
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1684 visitor.FormatXml(xml);
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1685
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1686 pugi::xml_document doc;
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1687 doc.load_buffer(xml.c_str(), xml.size());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1688
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1689 pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value");
3420
0a0e7eca95ae fix encoding in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3342
diff changeset
1690 ASSERT_STREQ("ISO 2022 IR 87", node.node().text().as_string());
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1691
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1692 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1693 ASSERT_STREQ("CS", node.node().attribute("vr").value());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1694
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1695 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1696 ASSERT_STREQ("PN", node.node().attribute("vr").value());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1697
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1698 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1699 ASSERT_STREQ("Yamada", node.node().text().as_string());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1700
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1701 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1702 ASSERT_STREQ("Tarou", node.node().text().as_string());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1703
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1704 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1705 ASSERT_EQ(utf8.substr(13, 6), node.node().text().as_string());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1706
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1707 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1708 ASSERT_EQ(utf8.substr(20, 6), node.node().text().as_string());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1709
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1710 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1711 ASSERT_EQ(utf8.substr(27, 9), node.node().text().as_string());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1712
3311
f2f8aa6f78aa compatibility with pugixml <= 1.4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3298
diff changeset
1713 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName");
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1714 ASSERT_EQ(utf8.substr(37), node.node().text().as_string());
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1715 #endif
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1716
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1717 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1718 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1719 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1720 ASSERT_EQ(2u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1721
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1722 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1723 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_SPECIFIC_CHARACTER_SET, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1724 ASSERT_EQ("ISO 2022 IR 87", s);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1725
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1726 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1727 std::vector<std::string> v;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1728 Toolbox::TokenizeString(v, s, '=');
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1729 ASSERT_EQ(3u, v.size());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1730 ASSERT_EQ("Yamada^Tarou", v[0]);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1731 ASSERT_EQ(utf8, s);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3420
diff changeset
1732 }
3223
c94f23198946 unit testing japanese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3222
diff changeset
1733 }
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1734
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1735
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1736
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1737 TEST(Toolbox, EncodingsChinese3)
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1738 {
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1739 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_J.3.html
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1740
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1741 static const uint8_t chinese[] = {
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1742 0x57, 0x61, 0x6e, 0x67, 0x5e, 0x58, 0x69, 0x61, 0x6f, 0x44, 0x6f,
3229
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3228
diff changeset
1743 0x6e, 0x67, 0x3d, 0xcd, 0xf5, 0x5e, 0xd0, 0xa1, 0xb6, 0xab, 0x3d, 0x00
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1744 };
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1745
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1746 ParsedDicomFile dicom(false);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1747 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030");
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1748 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
3228
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1749 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1750
3225
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1751 bool hasCodeExtensions;
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1752 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1753 ASSERT_EQ(Encoding_Chinese, encoding);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1754 ASSERT_FALSE(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1755
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1756 std::string value;
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1757 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1758
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1759 std::vector<std::string> tokens;
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1760 Orthanc::Toolbox::TokenizeString(tokens, value, '=');
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1761 ASSERT_EQ(3u, tokens.size());
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1762 ASSERT_EQ("Wang^XiaoDong", tokens[0]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1763 ASSERT_TRUE(tokens[2].empty());
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1764
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1765 std::vector<std::string> middle;
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1766 Orthanc::Toolbox::TokenizeString(middle, tokens[1], '^');
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1767 ASSERT_EQ(2u, middle.size());
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1768 ASSERT_EQ(3u, middle[0].size());
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1769 ASSERT_EQ(6u, middle[1].size());
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1770
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1771 // CDF5 in GB18030
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1772 ASSERT_EQ(static_cast<char>(0xe7), middle[0][0]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1773 ASSERT_EQ(static_cast<char>(0x8e), middle[0][1]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1774 ASSERT_EQ(static_cast<char>(0x8b), middle[0][2]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1775
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1776 // D0A1 in GB18030
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1777 ASSERT_EQ(static_cast<char>(0xe5), middle[1][0]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1778 ASSERT_EQ(static_cast<char>(0xb0), middle[1][1]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1779 ASSERT_EQ(static_cast<char>(0x8f), middle[1][2]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1780
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1781 // B6AB in GB18030
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1782 ASSERT_EQ(static_cast<char>(0xe4), middle[1][3]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1783 ASSERT_EQ(static_cast<char>(0xb8), middle[1][4]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1784 ASSERT_EQ(static_cast<char>(0x9c), middle[1][5]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1785 }
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1786
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1787
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1788 TEST(Toolbox, EncodingsChinese4)
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1789 {
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1790 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_J.4.html
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1791
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1792 static const uint8_t chinese[] = {
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1793 0x54, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x6c, 0x69, 0x6e,
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1794 0x65, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x73, 0xd6, 0xd0, 0xce,
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1795 0xc4, 0x2e, 0x0d, 0x0a, 0x54, 0x68, 0x65, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e,
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1796 0x64, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64,
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1797 0x65, 0x73, 0xd6, 0xd0, 0xce, 0xc4, 0x2c, 0x20, 0x74, 0x6f, 0x6f, 0x2e, 0x0d,
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1798 0x0a, 0x54, 0x68, 0x65, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x20, 0x6c, 0x69,
3229
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3228
diff changeset
1799 0x6e, 0x65, 0x2e, 0x0d, 0x0a, 0x00
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1800 };
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1801
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1802 static const uint8_t patternRaw[] = {
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1803 0xe4, 0xb8, 0xad, 0xe6, 0x96, 0x87
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1804 };
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1805
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1806 const std::string pattern(reinterpret_cast<const char*>(patternRaw), sizeof(patternRaw));
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1807
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1808 ParsedDicomFile dicom(false);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1809 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030");
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1810 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
3228
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1811 (DCM_PatientComments, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1812
3225
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1813 bool hasCodeExtensions;
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1814 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1815 ASSERT_EQ(Encoding_Chinese, encoding);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1816 ASSERT_FALSE(hasCodeExtensions);
c85510b5f21d unit testing ParsedDicomFile::DetectEncoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3224
diff changeset
1817
3224
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1818 std::string value;
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1819 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_COMMENTS));
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1820
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1821 std::vector<std::string> lines;
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1822 Orthanc::Toolbox::TokenizeString(lines, value, '\n');
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1823 ASSERT_EQ(4u, lines.size());
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1824 ASSERT_TRUE(boost::starts_with(lines[0], "The first line includes"));
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1825 ASSERT_TRUE(boost::ends_with(lines[0], ".\r"));
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1826 ASSERT_TRUE(lines[0].find(pattern) != std::string::npos);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1827 ASSERT_TRUE(boost::starts_with(lines[1], "The second line includes"));
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1828 ASSERT_TRUE(boost::ends_with(lines[1], ", too.\r"));
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1829 ASSERT_TRUE(lines[1].find(pattern) != std::string::npos);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1830 ASSERT_EQ("The third line.\r", lines[2]);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1831 ASSERT_FALSE(lines[1].find(pattern) == std::string::npos);
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1832 ASSERT_TRUE(lines[3].empty());
6399f5f25498 unit testing simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3223
diff changeset
1833 }
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1834
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1835
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1836 TEST(Toolbox, EncodingsSimplifiedChinese2)
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1837 {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1838 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_K.2.html
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1839
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1840 static const uint8_t chinese[] = {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1841 0x5a, 0x68, 0x61, 0x6e, 0x67, 0x5e, 0x58, 0x69, 0x61, 0x6f, 0x44, 0x6f,
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1842 0x6e, 0x67, 0x3d, 0x1b, 0x24, 0x29, 0x41, 0xd5, 0xc5, 0x5e, 0x1b, 0x24,
3229
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3228
diff changeset
1843 0x29, 0x41, 0xd0, 0xa1, 0xb6, 0xab, 0x3d, 0x20, 0x00
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1844 };
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1845
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1846 // echo -n "Zhang^XiaoDong=..." | hexdump -v -e '14/1 "0x%02x, "' -e '"\n"'
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1847 static const uint8_t utf8[] = {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1848 0x5a, 0x68, 0x61, 0x6e, 0x67, 0x5e, 0x58, 0x69, 0x61, 0x6f, 0x44, 0x6f, 0x6e, 0x67,
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1849 0x3d, 0xe5, 0xbc, 0xa0, 0x5e, 0xe5, 0xb0, 0x8f, 0xe4, 0xb8, 0x9c, 0x3d
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1850 };
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1851
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1852 ParsedDicomFile dicom(false);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1853 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58");
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1854 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
3228
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1855 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1856
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1857 bool hasCodeExtensions;
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1858 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1859 ASSERT_EQ(Encoding_SimplifiedChinese, encoding);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1860 ASSERT_TRUE(hasCodeExtensions);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1861
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1862 std::string value;
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1863 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1864 ASSERT_EQ(value, std::string(reinterpret_cast<const char*>(utf8), sizeof(utf8)));
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1865 }
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1866
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1867
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1868 TEST(Toolbox, EncodingsSimplifiedChinese3)
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1869 {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1870 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_K.2.html
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1871
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1872 static const uint8_t chinese[] = {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1873 0x31, 0x2e, 0x1b, 0x24, 0x29, 0x41, 0xb5, 0xda, 0xd2, 0xbb, 0xd0, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xa1, 0xa3, 0x0d, 0x0a,
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1874 0x32, 0x2e, 0x1b, 0x24, 0x29, 0x41, 0xb5, 0xda, 0xb6, 0xfe, 0xd0, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xa1, 0xa3, 0x0d, 0x0a,
3229
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3228
diff changeset
1875 0x33, 0x2e, 0x1b, 0x24, 0x29, 0x41, 0xb5, 0xda, 0xc8, 0xfd, 0xd0, 0xd0, 0xce, 0xc4, 0xd7, 0xd6, 0xa1, 0xa3, 0x0d, 0x0a, 0x00
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1876 };
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1877
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1878 static const uint8_t line1[] = {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1879 0x31, 0x2e, 0xe7, 0xac, 0xac, 0xe4, 0xb8, 0x80, 0xe8, 0xa1, 0x8c, 0xe6, 0x96, 0x87,
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1880 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r'
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1881 };
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1882
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1883 static const uint8_t line2[] = {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1884 0x32, 0x2e, 0xe7, 0xac, 0xac, 0xe4, 0xba, 0x8c, 0xe8, 0xa1, 0x8c, 0xe6, 0x96, 0x87,
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1885 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r'
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1886 };
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1887
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1888 static const uint8_t line3[] = {
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1889 0x33, 0x2e, 0xe7, 0xac, 0xac, 0xe4, 0xb8, 0x89, 0xe8, 0xa1, 0x8c, 0xe6, 0x96, 0x87,
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1890 0xe5, 0xad, 0x97, 0xe3, 0x80, 0x82, '\r'
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1891 };
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1892
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1893 ParsedDicomFile dicom(false);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1894 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58");
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1895 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
3228
4b9cfd92d1ae preparing for libicu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3226
diff changeset
1896 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
3226
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1897
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1898 bool hasCodeExtensions;
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1899 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1900 ASSERT_EQ(Encoding_SimplifiedChinese, encoding);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1901 ASSERT_TRUE(hasCodeExtensions);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1902
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1903 std::string value;
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1904 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1905
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1906 std::vector<std::string> lines;
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1907 Toolbox::TokenizeString(lines, value, '\n');
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1908 ASSERT_EQ(4u, lines.size());
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1909 ASSERT_EQ(std::string(reinterpret_cast<const char*>(line1), sizeof(line1)), lines[0]);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1910 ASSERT_EQ(std::string(reinterpret_cast<const char*>(line2), sizeof(line2)), lines[1]);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1911 ASSERT_EQ(std::string(reinterpret_cast<const char*>(line3), sizeof(line3)), lines[2]);
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1912 ASSERT_TRUE(lines[3].empty());
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1913 }
45e1631febbb support of simplified chinese
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3225
diff changeset
1914
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
1915
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
1916
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
1917
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
1918 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
1919
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
1920 #include "../Core/DicomParsing/Internals/DicomFrameIndex.h"
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1921
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
1922 #include <dcmtk/dcmdata/dcostrmb.h>
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
1923 #include <dcmtk/dcmdata/dcpixel.h>
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
1924 #include <dcmtk/dcmdata/dcpxitem.h>
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
1925 #include <dcmtk/dcmjpeg/djrploss.h> // for DJ_RPLossy
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
1926 #include <dcmtk/dcmjpeg/djrplol.h> // for DJ_RPLossless
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
1927
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
1928
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1929 namespace Orthanc
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1930 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1931 class IDicomTranscoder : public boost::noncopyable
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1932 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1933 public:
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1934 virtual ~IDicomTranscoder()
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1935 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1936 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1937
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1938 virtual DcmFileFormat& GetDicom() = 0;
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1939
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1940 virtual DicomTransferSyntax GetTransferSyntax() = 0;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1941
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1942 virtual std::string GetSopClassUid() = 0;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1943
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1944 virtual std::string GetSopInstanceUid() = 0;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1945
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1946 virtual unsigned int GetFramesCount() = 0;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1947
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1948 virtual ImageAccessor* DecodeFrame(unsigned int frame) = 0;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1949
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1950 virtual void GetCompressedFrame(std::string& target,
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1951 unsigned int frame) = 0;
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
1952
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1953 // NB: Transcoding can change the value of "GetSopInstanceUid()"
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1954 // and "GetTransferSyntax()" if lossy compression is applied
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
1955 virtual bool Transcode(std::string& target,
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
1956 std::set<DicomTransferSyntax> syntaxes,
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
1957 bool allowNewSopInstanceUid) = 0;
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
1958
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
1959 virtual void WriteToMemoryBuffer(std::string& target) = 0;
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1960 };
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1961
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1962
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1963 class DcmtkTranscoder : public IDicomTranscoder
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1964 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1965 private:
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
1966 std::unique_ptr<DcmFileFormat> dicom_;
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
1967 std::unique_ptr<DicomFrameIndex> index_;
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
1968 DicomTransferSyntax transferSyntax_;
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
1969 std::string sopClassUid_;
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
1970 std::string sopInstanceUid_;
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
1971 uint16_t bitsStored_;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
1972 unsigned int lossyQuality_;
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1973
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1974 static std::string GetStringTag(DcmDataset& dataset,
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1975 const DcmTagKey& tag)
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1976 {
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1977 const char* value = NULL;
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1978
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1979 if (!dataset.findAndGetString(tag, value).good() ||
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1980 value == NULL)
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1981 {
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1982 throw OrthancException(ErrorCode_BadFileFormat,
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1983 "Missing SOP class/instance UID in DICOM instance");
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1984 }
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1985 else
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1986 {
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1987 return std::string(value);
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1988 }
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1989 }
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
1990
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1991 void Setup(DcmFileFormat* dicom)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1992 {
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
1993 lossyQuality_ = 90;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
1994
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1995 dicom_.reset(dicom);
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1996
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1997 if (dicom == NULL ||
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1998 dicom_->getDataset() == NULL)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
1999 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2000 throw OrthancException(ErrorCode_NullPointer);
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2001 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2002
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2003 DcmDataset& dataset = *dicom_->getDataset();
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2004 index_.reset(new DicomFrameIndex(dataset));
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2005
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2006 E_TransferSyntax xfer = dataset.getOriginalXfer();
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2007 if (xfer == EXS_Unknown)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2008 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2009 dataset.updateOriginalXfer();
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2010 xfer = dataset.getOriginalXfer();
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2011 if (xfer == EXS_Unknown)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2012 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2013 throw OrthancException(ErrorCode_BadFileFormat,
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2014 "Cannot determine the transfer syntax of the DICOM instance");
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2015 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2016 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2017
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2018 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transferSyntax_, xfer))
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2019 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2020 throw OrthancException(
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2021 ErrorCode_BadFileFormat,
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2022 "Unsupported transfer syntax: " + boost::lexical_cast<std::string>(xfer));
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2023 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2024
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2025 if (!dataset.findAndGetUint16(DCM_BitsStored, bitsStored_).good())
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2026 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2027 throw OrthancException(ErrorCode_BadFileFormat,
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2028 "Missing \"Bits Stored\" tag in DICOM instance");
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2029 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2030
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2031 sopClassUid_ = GetStringTag(dataset, DCM_SOPClassUID);
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2032 sopInstanceUid_ = GetStringTag(dataset, DCM_SOPInstanceUID);
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2033 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2034
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2035 public:
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2036 DcmtkTranscoder(DcmFileFormat* dicom) // Takes ownership
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2037 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2038 Setup(dicom);
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2039 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2040
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2041 DcmtkTranscoder(const void* dicom,
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2042 size_t size)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2043 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2044 Setup(FromDcmtkBridge::LoadFromMemoryBuffer(dicom, size));
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2045 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2046
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2047 void SetLossyQuality(unsigned int quality)
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2048 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2049 if (quality <= 0 ||
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2050 quality > 100)
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2051 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2052 throw OrthancException(ErrorCode_ParameterOutOfRange);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2053 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2054 else
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2055 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2056 lossyQuality_ = quality;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2057 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2058 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2059
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2060 unsigned int GetLossyQuality() const
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2061 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2062 return lossyQuality_;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2063 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2064
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2065 unsigned int GetBitsStored() const
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2066 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2067 return bitsStored_;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2068 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2069
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2070 virtual DcmFileFormat& GetDicom()
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2071 {
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2072 assert(dicom_ != NULL);
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2073 return *dicom_;
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2074 }
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2075
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2076 virtual DicomTransferSyntax GetTransferSyntax() ORTHANC_OVERRIDE
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2077 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2078 return transferSyntax_;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2079 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2080
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2081 virtual std::string GetSopClassUid() ORTHANC_OVERRIDE
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2082 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2083 return sopClassUid_;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2084 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2085
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2086 virtual std::string GetSopInstanceUid() ORTHANC_OVERRIDE
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2087 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2088 return sopInstanceUid_;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2089 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2090
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2091 virtual unsigned int GetFramesCount() ORTHANC_OVERRIDE
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2092 {
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2093 return index_->GetFramesCount();
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2094 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2095
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2096 virtual void WriteToMemoryBuffer(std::string& target) ORTHANC_OVERRIDE
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2097 {
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2098 if (!FromDcmtkBridge::SaveToMemoryBuffer(target, *dicom_))
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2099 {
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2100 throw OrthancException(ErrorCode_InternalError,
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2101 "Cannot write the DICOM instance to a memory buffer");
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2102 }
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2103 }
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2104
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2105 virtual ImageAccessor* DecodeFrame(unsigned int frame) ORTHANC_OVERRIDE
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2106 {
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2107 assert(dicom_->getDataset() != NULL);
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2108 return DicomImageDecoder::Decode(*dicom_->getDataset(), frame);
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2109 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2110
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2111 virtual void GetCompressedFrame(std::string& target,
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2112 unsigned int frame) ORTHANC_OVERRIDE
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2113 {
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2114 index_->GetRawFrame(target, frame);
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2115 }
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2116
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2117 virtual bool Transcode(std::string& target,
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2118 std::set<DicomTransferSyntax> syntaxes,
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2119 bool allowNewSopInstanceUid) ORTHANC_OVERRIDE
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2120 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2121 assert(dicom_ != NULL &&
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2122 dicom_->getDataset() != NULL);
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2123
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2124 if (syntaxes.find(GetTransferSyntax()) != syntaxes.end())
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2125 {
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2126 printf("NO TRANSCODING\n");
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2127
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2128 // No change in the transfer syntax => simply serialize the current dataset
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2129 WriteToMemoryBuffer(target);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2130 return true;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2131 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2132
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2133 printf(">> %d\n", bitsStored_);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2134
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2135 DJ_RPLossy rpLossy(lossyQuality_);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2136
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2137 if (syntaxes.find(DicomTransferSyntax_LittleEndianImplicit) != syntaxes.end() &&
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2138 FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_LittleEndianImplicit, NULL))
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2139 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2140 transferSyntax_ = DicomTransferSyntax_LittleEndianImplicit;
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2141 return true;
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2142 }
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2143 else if (syntaxes.find(DicomTransferSyntax_LittleEndianExplicit) != syntaxes.end() &&
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2144 FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_LittleEndianExplicit, NULL))
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2145 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2146 transferSyntax_ = DicomTransferSyntax_LittleEndianExplicit;
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2147 return true;
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2148 }
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2149 else if (syntaxes.find(DicomTransferSyntax_BigEndianExplicit) != syntaxes.end() &&
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2150 FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_BigEndianExplicit, NULL))
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2151 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2152 transferSyntax_ = DicomTransferSyntax_BigEndianExplicit;
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2153 return true;
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2154 }
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2155 else if (syntaxes.find(DicomTransferSyntax_JPEGProcess1) != syntaxes.end() &&
3766
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3765
diff changeset
2156 allowNewSopInstanceUid &&
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2157 GetBitsStored() == 8 &&
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2158 FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_JPEGProcess1, &rpLossy))
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2159 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2160 transferSyntax_ = DicomTransferSyntax_JPEGProcess1;
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2161 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2162 return true;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2163 }
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2164 else if (syntaxes.find(DicomTransferSyntax_JPEGProcess2_4) != syntaxes.end() &&
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2165 allowNewSopInstanceUid &&
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2166 GetBitsStored() <= 12 &&
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2167 FromDcmtkBridge::Transcode(target, *dicom_, DicomTransferSyntax_JPEGProcess2_4, &rpLossy))
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2168 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2169 transferSyntax_ = DicomTransferSyntax_JPEGProcess2_4;
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2170 sopInstanceUid_ = GetStringTag(*dicom_->getDataset(), DCM_SOPInstanceUID);
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2171 return true;
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2172 }
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2173 else
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2174 {
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2175 return false;
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2176 }
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2177 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2178 };
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2179 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2180
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2181
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2182
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2183
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2184 static bool Transcode(std::string& buffer,
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2185 DcmDataset& dataSet,
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2186 E_TransferSyntax xfer)
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2187 {
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2188 // Determine the transfer syntax which shall be used to write the
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2189 // information to the file. We always switch to the Little Endian
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2190 // syntax, with explicit length.
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2191
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2192 // http://support.dcmtk.org/docs/dcxfer_8h-source.html
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2193
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2194
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2195 /**
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2196 * Note that up to Orthanc 0.7.1 (inclusive), the
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2197 * "EXS_LittleEndianExplicit" was always used to save the DICOM
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2198 * dataset into memory. We now keep the original transfer syntax
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2199 * (if available).
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2200 **/
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2201 //E_TransferSyntax xfer = dataSet.getOriginalXfer();
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2202 if (xfer == EXS_Unknown)
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2203 {
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2204 // No information about the original transfer syntax: This is
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2205 // most probably a DICOM dataset that was read from memory.
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2206 xfer = EXS_LittleEndianExplicit;
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2207 }
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2208
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2209 E_EncodingType encodingType = /*opt_sequenceType*/ EET_ExplicitLength;
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2210
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2211 // Create the meta-header information
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2212 DcmFileFormat ff(&dataSet);
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2213 ff.validateMetaInfo(xfer);
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2214 ff.removeInvalidGroups();
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2215
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2216 // Create a memory buffer with the proper size
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2217 {
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2218 const uint32_t estimatedSize = ff.calcElementLength(xfer, encodingType); // (*)
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2219 buffer.resize(estimatedSize);
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2220 }
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2221
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2222 DcmOutputBufferStream ob(&buffer[0], buffer.size());
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2223
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2224 // Fill the memory buffer with the meta-header and the dataset
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2225 ff.transferInit();
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2226 OFCondition c = ff.write(ob, xfer, encodingType, NULL,
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2227 /*opt_groupLength*/ EGL_recalcGL,
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2228 /*opt_paddingType*/ EPD_withoutPadding);
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2229 ff.transferEnd();
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2230
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2231 if (c.good())
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2232 {
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2233 // The DICOM file is successfully written, truncate the target
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2234 // buffer if its size was overestimated by (*)
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2235 ob.flush();
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2236
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2237 size_t effectiveSize = static_cast<size_t>(ob.tell());
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2238 if (effectiveSize < buffer.size())
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2239 {
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2240 buffer.resize(effectiveSize);
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2241 }
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2242
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2243 return true;
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2244 }
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2245 else
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2246 {
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2247 // Error
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2248 buffer.clear();
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2249 return false;
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2250 }
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2251 }
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2252
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2253
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2254 #include <boost/filesystem.hpp>
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2255
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2256
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2257 static void TestFile(const std::string& path)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2258 {
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2259 static unsigned int count = 0;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2260 count++;
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2261
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2262
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2263 printf("** %s\n", path.c_str());
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2264
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2265 std::string s;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2266 SystemToolbox::ReadFile(s, path);
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2267
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2268 Orthanc::DcmtkTranscoder transcoder(s.c_str(), s.size());
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2269
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2270 /*if (transcoder.GetBitsStored() != 8) // TODO
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2271 return; */
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2272
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2273 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2274 char buf[1024];
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2275 sprintf(buf, "/tmp/source-%06d.dcm", count);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2276 printf(">> %s\n", buf);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2277 Orthanc::SystemToolbox::WriteFile(s, buf);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2278 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2279
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2280 printf("[%s] [%s] [%s] %d %d\n", GetTransferSyntaxUid(transcoder.GetTransferSyntax()),
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2281 transcoder.GetSopClassUid().c_str(), transcoder.GetSopInstanceUid().c_str(),
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2282 transcoder.GetFramesCount(), transcoder.GetTransferSyntax());
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2283
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2284 for (size_t i = 0; i < transcoder.GetFramesCount(); i++)
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2285 {
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2286 std::string f;
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2287 transcoder.GetCompressedFrame(f, i);
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2288
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2289 if (i == 0)
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2290 {
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2291 char buf[1024];
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2292 sprintf(buf, "/tmp/frame-%06d.raw", count);
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2293 printf(">> %s\n", buf);
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2294 Orthanc::SystemToolbox::WriteFile(f, buf);
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2295 }
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2296 }
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2297
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2298 {
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2299 std::string t;
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2300 transcoder.WriteToMemoryBuffer(t);
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2301
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2302 Orthanc::DcmtkTranscoder transcoder2(t.c_str(), t.size());
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2303 printf(">> %d %d ; %lu bytes\n", transcoder.GetTransferSyntax(), transcoder2.GetTransferSyntax(), t.size());
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2304 }
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2305
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2306 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2307 std::string a = transcoder.GetSopInstanceUid();
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2308 DicomTransferSyntax b = transcoder.GetTransferSyntax();
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2309
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2310 std::set<DicomTransferSyntax> syntaxes;
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2311 syntaxes.insert(DicomTransferSyntax_JPEGProcess2_4);
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2312 //syntaxes.insert(DicomTransferSyntax_LittleEndianExplicit);
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2313
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2314 std::string t;
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2315 bool ok = transcoder.Transcode(t, syntaxes, true);
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2316 printf("Transcoding: %d\n", ok);
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2317
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2318 if (ok)
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2319 {
3819
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2320 printf("[%s] => [%s]\n", a.c_str(), transcoder.GetSopInstanceUid().c_str());
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2321 printf("[%s] => [%s]\n", GetTransferSyntaxUid(b),
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2322 GetTransferSyntaxUid(transcoder.GetTransferSyntax()));
1237bd0bbdb2 update sop class/instance uid if transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3812
diff changeset
2323
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2324 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2325 char buf[1024];
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2326 sprintf(buf, "/tmp/transcoded-%06d.dcm", count);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2327 printf(">> %s\n", buf);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2328 Orthanc::SystemToolbox::WriteFile(t, buf);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2329 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2330
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2331 Orthanc::DcmtkTranscoder transcoder2(t.c_str(), t.size());
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2332 printf(" => transcoded transfer syntax %d ; %lu bytes\n", transcoder2.GetTransferSyntax(), t.size());
3748
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2333 }
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2334 }
ca36e3f1112c transcoding to uncompressed transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2335
3744
accf1b60b108 accessing raw pixel data
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3743
diff changeset
2336 printf("\n");
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2337 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2338
3764
d55768319f8e fix static build of dcmtk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3748
diff changeset
2339 TEST(Toto, DISABLED_Transcode)
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2340 {
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2341 //OFLog::configure(OFLogger::DEBUG_LOG_LEVEL);
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2342
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2343 if (0)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2344 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2345 std::string s;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2346 //SystemToolbox::ReadFile(s, "/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm");
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2347 //SystemToolbox::ReadFile(s, "/home/jodogne/DICOM/Alain.dcm");
3766
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3765
diff changeset
2348 //SystemToolbox::ReadFile(s, "/home/jodogne/Subversion/orthanc-tests/Database/Brainix/Epi/IM-0001-0002.dcm");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3765
diff changeset
2349 SystemToolbox::ReadFile(s, "/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/1.2.840.10008.1.2.1.dcm");
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2350
3767
c6658187e4b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3745
diff changeset
2351 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(s.c_str(), s.size()));
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2352
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2353 // less /home/jodogne/Downloads/dcmtk-3.6.4/dcmdata/include/dcmtk/dcmdata/dcxfer.h
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2354 printf(">> %d\n", dicom->getDataset()->getOriginalXfer()); // => 4 == EXS_JPEGProcess1
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2355
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2356 const DcmRepresentationParameter *p;
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2357
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2358 #if 0
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2359 E_TransferSyntax target = EXS_LittleEndianExplicit;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2360 p = NULL;
3766
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3765
diff changeset
2361 #elif 0
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2362 E_TransferSyntax target = EXS_JPEGProcess14SV1;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2363 DJ_RPLossless rp_lossless(6, 0);
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2364 p = &rp_lossless;
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2365 #else
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2366 E_TransferSyntax target = EXS_JPEGProcess1;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2367 DJ_RPLossy rp_lossy(90); // quality
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2368 p = &rp_lossy;
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2369 #endif
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2370
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2371 ASSERT_TRUE(dicom->getDataset()->chooseRepresentation(target, p).good());
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2372 ASSERT_TRUE(dicom->getDataset()->canWriteXfer(target));
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2373
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2374 std::string t;
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2375 ASSERT_TRUE(Transcode(t, *dicom->getDataset(), target));
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2376
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2377 SystemToolbox::WriteFile(s, "source.dcm");
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2378 SystemToolbox::WriteFile(t, "target.dcm");
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2379 }
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2380
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2381 if (1)
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2382 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2383 const char* const PATH = "/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes";
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2384
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2385 for (boost::filesystem::directory_iterator it(PATH);
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2386 it != boost::filesystem::directory_iterator(); ++it)
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2387 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2388 if (boost::filesystem::is_regular_file(it->status()))
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2389 {
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2390 TestFile(it->path().string());
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2391 }
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2392 }
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2393 }
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2394
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2395 if (0)
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2396 {
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2397 TestFile("/home/jodogne/Subversion/orthanc-tests/Database/Multiframe.dcm");
3745
113a7b994a12 extracting the raw frame in the transcoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3744
diff changeset
2398 TestFile("/home/jodogne/Subversion/orthanc-tests/Database/Issue44/Monochrome1-Jpeg.dcm");
3743
33c19a6643e1 creating IDicomTranscoder abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3727
diff changeset
2399 }
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2400
3812
abd3a1d114c0 transcoding to 1.2.840.10008.1.2.4.51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3770
diff changeset
2401 if (0)
3765
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2402 {
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2403 TestFile("/home/jodogne/Subversion/orthanc-tests/Database/TransferSyntaxes/1.2.840.10008.1.2.1.dcm");
4a25727401cd first transcoding to jpeg 8bpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3764
diff changeset
2404 }
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2405 }
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2406
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2407
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2408
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2409 #ifdef _WIN32
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2410 /**
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2411 * "The maximum length, in bytes, of the string returned in the buffer
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2412 * pointed to by the name parameter is dependent on the namespace provider,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2413 * but this string must be 256 bytes or less.
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2414 * http://msdn.microsoft.com/en-us/library/windows/desktop/ms738527(v=vs.85).aspx
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2415 **/
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2416 # define HOST_NAME_MAX 256
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2417 # include <winsock.h>
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2418 #endif
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2419
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2420
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2421 #if !defined(HOST_NAME_MAX) && defined(_POSIX_HOST_NAME_MAX)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2422 /**
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2423 * TO IMPROVE: "_POSIX_HOST_NAME_MAX is only the minimum value that
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2424 * HOST_NAME_MAX can ever have [...] Therefore you cannot allocate an
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2425 * array of size _POSIX_HOST_NAME_MAX, invoke gethostname() and expect
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2426 * that the result will fit."
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2427 * http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00128.html
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2428 **/
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2429 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
3727
090022f1b5e1 auto-generation of primitives to handle transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
2430 #endif
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2431
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2432
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2433 #include "../Core/DicomNetworking/RemoteModalityParameters.h"
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2434
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2435
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2436 #include <dcmtk/dcmnet/diutil.h> // For dcmConnectionTimeout()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2437
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2438
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2439
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2440 namespace Orthanc
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2441 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2442 // By default, the timeout for client DICOM connections is set to 10 seconds
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2443 static boost::mutex defaultTimeoutMutex_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2444 static uint32_t defaultTimeout_ = 10;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2445
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2446
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2447 class DicomAssociationParameters
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2448 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2449 private:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2450 std::string localAet_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2451 std::string remoteAet_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2452 std::string remoteHost_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2453 uint16_t remotePort_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2454 ModalityManufacturer manufacturer_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2455 uint32_t timeout_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2456
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2457 void ReadDefaultTimeout()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2458 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2459 boost::mutex::scoped_lock lock(defaultTimeoutMutex_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2460 timeout_ = defaultTimeout_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2461 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2462
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2463 public:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2464 DicomAssociationParameters() :
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2465 localAet_("STORESCU"),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2466 remoteAet_("ANY-SCP"),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2467 remoteHost_("127.0.0.1"),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2468 remotePort_(104),
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2469 manufacturer_(ModalityManufacturer_Generic)
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2470 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2471 ReadDefaultTimeout();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2472 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2473
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2474 DicomAssociationParameters(const std::string& localAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2475 const RemoteModalityParameters& remote) :
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2476 localAet_(localAet),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2477 remoteAet_(remote.GetApplicationEntityTitle()),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2478 remoteHost_(remote.GetHost()),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2479 remotePort_(remote.GetPortNumber()),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2480 manufacturer_(remote.GetManufacturer()),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2481 timeout_(defaultTimeout_)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2482 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2483 ReadDefaultTimeout();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2484 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2485
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2486 const std::string& GetLocalApplicationEntityTitle() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2487 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2488 return localAet_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2489 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2490
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2491 const std::string& GetRemoteApplicationEntityTitle() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2492 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2493 return remoteAet_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2494 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2495
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2496 const std::string& GetRemoteHost() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2497 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2498 return remoteHost_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2499 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2500
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2501 uint16_t GetRemotePort() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2502 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2503 return remotePort_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2504 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2505
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2506 ModalityManufacturer GetRemoteManufacturer() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2507 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2508 return manufacturer_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2509 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2510
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2511 void SetLocalApplicationEntityTitle(const std::string& aet)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2512 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2513 localAet_ = aet;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2514 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2515
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2516 void SetRemoteApplicationEntityTitle(const std::string& aet)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2517 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2518 remoteAet_ = aet;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2519 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2520
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2521 void SetRemoteHost(const std::string& host)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2522 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2523 if (host.size() > HOST_NAME_MAX - 10)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2524 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2525 throw OrthancException(ErrorCode_ParameterOutOfRange,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2526 "Invalid host name (too long): " + host);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2527 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2528
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2529 remoteHost_ = host;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2530 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2531
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2532 void SetRemotePort(uint16_t port)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2533 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2534 remotePort_ = port;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2535 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2536
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2537 void SetRemoteManufacturer(ModalityManufacturer manufacturer)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2538 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2539 manufacturer_ = manufacturer;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2540 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2541
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2542 void SetRemoteModality(const RemoteModalityParameters& parameters)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2543 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2544 SetRemoteApplicationEntityTitle(parameters.GetApplicationEntityTitle());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2545 SetRemoteHost(parameters.GetHost());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2546 SetRemotePort(parameters.GetPortNumber());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2547 SetRemoteManufacturer(parameters.GetManufacturer());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2548 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2549
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2550 bool IsEqual(const DicomAssociationParameters& other) const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2551 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2552 return (localAet_ == other.localAet_ &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2553 remoteAet_ == other.remoteAet_ &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2554 remoteHost_ == other.remoteHost_ &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2555 remotePort_ == other.remotePort_ &&
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2556 manufacturer_ == other.manufacturer_);
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2557 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2558
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2559 void SetTimeout(uint32_t seconds)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2560 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2561 timeout_ = seconds;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2562 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2563
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2564 uint32_t GetTimeout() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2565 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2566 return timeout_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2567 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2568
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2569 bool HasTimeout() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2570 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2571 return timeout_ != 0;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2572 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2573
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2574 static void SetDefaultTimeout(uint32_t seconds)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2575 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2576 LOG(INFO) << "Default timeout for DICOM connections if Orthanc acts as SCU (client): "
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2577 << seconds << " seconds (0 = no timeout)";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2578
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2579 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2580 boost::mutex::scoped_lock lock(defaultTimeoutMutex_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2581 defaultTimeout_ = seconds;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2582 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2583 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2584
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2585 void CheckCondition(const OFCondition& cond,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2586 const std::string& command) const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2587 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2588 if (cond.bad())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2589 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2590 // Reformat the error message from DCMTK by turning multiline
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2591 // errors into a single line
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2592
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2593 std::string s(cond.text());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2594 std::string info;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2595 info.reserve(s.size());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2596
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2597 bool isMultiline = false;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2598 for (size_t i = 0; i < s.size(); i++)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2599 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2600 if (s[i] == '\r')
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2601 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2602 // Ignore
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2603 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2604 else if (s[i] == '\n')
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2605 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2606 if (isMultiline)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2607 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2608 info += "; ";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2609 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2610 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2611 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2612 info += " (";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2613 isMultiline = true;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2614 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2615 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2616 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2617 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2618 info.push_back(s[i]);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2619 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2620 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2621
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2622 if (isMultiline)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2623 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2624 info += ")";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2625 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2626
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2627 throw OrthancException(ErrorCode_NetworkProtocol,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2628 "DicomUserConnection - " + command + " to AET \"" +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2629 GetRemoteApplicationEntityTitle() + "\": " + info);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2630 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2631 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2632 };
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2633
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2634
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2635 static void FillSopSequence(DcmDataset& dataset,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2636 const DcmTagKey& tag,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2637 const std::vector<std::string>& sopClassUids,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2638 const std::vector<std::string>& sopInstanceUids,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2639 const std::vector<StorageCommitmentFailureReason>& failureReasons,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2640 bool hasFailureReasons)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2641 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2642 assert(sopClassUids.size() == sopInstanceUids.size() &&
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2643 (hasFailureReasons ?
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2644 failureReasons.size() == sopClassUids.size() :
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2645 failureReasons.empty()));
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2646
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2647 if (sopInstanceUids.empty())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2648 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2649 // Add an empty sequence
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2650 if (!dataset.insertEmptyElement(tag).good())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2651 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2652 throw OrthancException(ErrorCode_InternalError);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2653 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2654 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2655 else
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2656 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2657 for (size_t i = 0; i < sopClassUids.size(); i++)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2658 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2659 std::unique_ptr<DcmItem> item(new DcmItem);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2660 if (!item->putAndInsertString(DCM_ReferencedSOPClassUID, sopClassUids[i].c_str()).good() ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2661 !item->putAndInsertString(DCM_ReferencedSOPInstanceUID, sopInstanceUids[i].c_str()).good() ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2662 (hasFailureReasons &&
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2663 !item->putAndInsertUint16(DCM_FailureReason, failureReasons[i]).good()) ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2664 !dataset.insertSequenceItem(tag, item.release()).good())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2665 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2666 throw OrthancException(ErrorCode_InternalError);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2667 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2668 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2669 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2670 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2671
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2672
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2673 class DicomAssociation : public boost::noncopyable
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2674 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2675 private:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2676 // This is the maximum number of presentation context IDs (the
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2677 // number of odd integers between 1 and 255)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2678 // http://dicom.nema.org/medical/dicom/2019e/output/chtml/part08/sect_9.3.2.2.html
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2679 static const size_t MAX_PROPOSED_PRESENTATIONS = 128;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2680
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2681 struct ProposedPresentationContext
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2682 {
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2683 std::string abstractSyntax_;
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2684 std::set<DicomTransferSyntax> transferSyntaxes_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2685 };
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2686
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2687 typedef std::map<std::string, std::map<DicomTransferSyntax, uint8_t> > AcceptedPresentationContexts;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2688
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2689 DicomAssociationRole role_;
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2690 bool isOpen_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2691 std::vector<ProposedPresentationContext> proposed_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2692 AcceptedPresentationContexts accepted_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2693 T_ASC_Network* net_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2694 T_ASC_Parameters* params_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2695 T_ASC_Association* assoc_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2696
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2697 void Initialize()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2698 {
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2699 role_ = DicomAssociationRole_Default;
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2700 isOpen_ = false;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2701 net_ = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2702 params_ = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2703 assoc_ = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2704
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2705 // Must be after "isOpen_ = false"
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2706 ClearPresentationContexts();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2707 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2708
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2709 void CheckConnecting(const DicomAssociationParameters& parameters,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2710 const OFCondition& cond)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2711 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2712 try
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2713 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2714 parameters.CheckCondition(cond, "connecting");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2715 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2716 catch (OrthancException&)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2717 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2718 CloseInternal();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2719 throw;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2720 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2721 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2722
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2723 void CloseInternal()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2724 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2725 if (assoc_ != NULL)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2726 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2727 ASC_releaseAssociation(assoc_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2728 ASC_destroyAssociation(&assoc_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2729 assoc_ = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2730 params_ = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2731 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2732 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2733 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2734 if (params_ != NULL)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2735 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2736 ASC_destroyAssociationParameters(&params_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2737 params_ = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2738 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2739 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2740
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2741 if (net_ != NULL)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2742 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2743 ASC_dropNetwork(&net_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2744 net_ = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2745 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2746
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2747 accepted_.clear();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2748 isOpen_ = false;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2749 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2750
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2751 void AddAccepted(const std::string& abstractSyntax,
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2752 DicomTransferSyntax syntax,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2753 uint8_t presentationContextId)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2754 {
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2755 AcceptedPresentationContexts::iterator found = accepted_.find(abstractSyntax);
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2756
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2757 if (found == accepted_.end())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2758 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2759 std::map<DicomTransferSyntax, uint8_t> syntaxes;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2760 syntaxes[syntax] = presentationContextId;
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2761 accepted_[abstractSyntax] = syntaxes;
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2762 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2763 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2764 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2765 if (found->second.find(syntax) != found->second.end())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2766 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2767 LOG(WARNING) << "The same transfer syntax ("
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2768 << GetTransferSyntaxUid(syntax)
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2769 << ") was accepted twice for the same abstract syntax UID ("
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2770 << abstractSyntax << ")";
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2771 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2772 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2773 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2774 found->second[syntax] = presentationContextId;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2775 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2776 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2777 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2778
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2779 public:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2780 DicomAssociation()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2781 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2782 Initialize();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2783 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2784
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2785 ~DicomAssociation()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2786 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2787 try
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2788 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2789 Close();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2790 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2791 catch (OrthancException&)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2792 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2793 // Don't throw exception in destructors
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2794 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2795 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2796
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2797 bool IsOpen() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2798 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2799 return isOpen_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2800 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2801
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2802 void SetRole(DicomAssociationRole role)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2803 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2804 if (role_ != role)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2805 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2806 Close();
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2807 role_ = role;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2808 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2809 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2810
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2811 void ClearPresentationContexts()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2812 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2813 Close();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2814 proposed_.clear();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2815 proposed_.reserve(MAX_PROPOSED_PRESENTATIONS);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2816 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2817
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2818 void Open(const DicomAssociationParameters& parameters)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2819 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2820 if (isOpen_)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2821 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2822 return; // Already open
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2823 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2824
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2825 // Timeout used during association negociation and ASC_releaseAssociation()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2826 uint32_t acseTimeout = parameters.GetTimeout();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2827 if (acseTimeout == 0)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2828 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2829 /**
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2830 * Timeout is disabled. Global timeout (seconds) for
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2831 * connecting to remote hosts. Default value is -1 which
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2832 * selects infinite timeout, i.e. blocking connect().
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2833 **/
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2834 dcmConnectionTimeout.set(-1);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2835 acseTimeout = 10;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2836 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2837 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2838 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2839 dcmConnectionTimeout.set(acseTimeout);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2840 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2841
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2842 T_ASC_SC_ROLE dcmtkRole;
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
2843 switch (role_)
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2844 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2845 case DicomAssociationRole_Default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2846 dcmtkRole = ASC_SC_ROLE_DEFAULT;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2847 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2848
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2849 case DicomAssociationRole_Scu:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2850 dcmtkRole = ASC_SC_ROLE_SCU;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2851 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2852
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2853 case DicomAssociationRole_Scp:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2854 dcmtkRole = ASC_SC_ROLE_SCP;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2855 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2856
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2857 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2858 throw OrthancException(ErrorCode_ParameterOutOfRange);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2859 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2860
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2861 assert(net_ == NULL &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2862 params_ == NULL &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2863 assoc_ == NULL);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2864
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2865 if (proposed_.empty())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2866 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2867 throw OrthancException(ErrorCode_BadSequenceOfCalls,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2868 "No presentation context was proposed");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2869 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2870
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2871 LOG(INFO) << "Opening a DICOM SCU connection from AET \""
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2872 << parameters.GetLocalApplicationEntityTitle()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2873 << "\" to AET \"" << parameters.GetRemoteApplicationEntityTitle()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2874 << "\" on host " << parameters.GetRemoteHost()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2875 << ":" << parameters.GetRemotePort()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2876 << " (manufacturer: " << EnumerationToString(parameters.GetRemoteManufacturer()) << ")";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2877
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2878 CheckConnecting(parameters, ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ acseTimeout, &net_));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2879 CheckConnecting(parameters, ASC_createAssociationParameters(&params_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2880
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2881 // Set this application's title and the called application's title in the params
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2882 CheckConnecting(parameters, ASC_setAPTitles(
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2883 params_, parameters.GetLocalApplicationEntityTitle().c_str(),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2884 parameters.GetRemoteApplicationEntityTitle().c_str(), NULL));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2885
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2886 // Set the network addresses of the local and remote entities
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2887 char localHost[HOST_NAME_MAX];
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2888 gethostname(localHost, HOST_NAME_MAX - 1);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2889
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2890 char remoteHostAndPort[HOST_NAME_MAX];
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2891
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2892 #ifdef _MSC_VER
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2893 _snprintf
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2894 #else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2895 snprintf
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2896 #endif
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2897 (remoteHostAndPort, HOST_NAME_MAX - 1, "%s:%d",
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2898 parameters.GetRemoteHost().c_str(), parameters.GetRemotePort());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2899
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2900 CheckConnecting(parameters, ASC_setPresentationAddresses(params_, localHost, remoteHostAndPort));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2901
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2902 // Set various options
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2903 CheckConnecting(parameters, ASC_setTransportLayerType(params_, /*opt_secureConnection*/ false));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2904
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2905 // Setup the list of proposed presentation contexts
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2906 unsigned int presentationContextId = 1;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2907 for (size_t i = 0; i < proposed_.size(); i++)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2908 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2909 assert(presentationContextId <= 255);
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2910 const char* abstractSyntax = proposed_[i].abstractSyntax_.c_str();
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2911
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2912 const std::set<DicomTransferSyntax>& source = proposed_[i].transferSyntaxes_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2913
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2914 std::vector<const char*> transferSyntaxes;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2915 transferSyntaxes.reserve(source.size());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2916
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2917 for (std::set<DicomTransferSyntax>::const_iterator
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2918 it = source.begin(); it != source.end(); ++it)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2919 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2920 transferSyntaxes.push_back(GetTransferSyntaxUid(*it));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2921 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2922
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2923 assert(!transferSyntaxes.empty());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2924 CheckConnecting(parameters, ASC_addPresentationContext(
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2925 params_, presentationContextId, abstractSyntax,
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2926 &transferSyntaxes[0], transferSyntaxes.size(), dcmtkRole));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2927
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2928 presentationContextId += 2;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2929 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2930
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2931 // Do the association
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2932 CheckConnecting(parameters, ASC_requestAssociation(net_, params_, &assoc_));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2933 isOpen_ = true;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2934
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2935 // Inspect the accepted transfer syntaxes
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2936 LST_HEAD **l = &params_->DULparams.acceptedPresentationContext;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2937 if (*l != NULL)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2938 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2939 DUL_PRESENTATIONCONTEXT* pc = (DUL_PRESENTATIONCONTEXT*) LST_Head(l);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2940 LST_Position(l, (LST_NODE*)pc);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2941 while (pc)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2942 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2943 if (pc->result == ASC_P_ACCEPTANCE)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2944 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2945 DicomTransferSyntax transferSyntax;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2946 if (LookupTransferSyntax(transferSyntax, pc->acceptedTransferSyntax))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2947 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2948 AddAccepted(pc->abstractSyntax, transferSyntax, pc->presentationContextID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2949 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2950 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2951 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2952 LOG(WARNING) << "Unknown transfer syntax received from AET \""
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2953 << parameters.GetRemoteApplicationEntityTitle()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2954 << "\": " << pc->acceptedTransferSyntax;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2955 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2956 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2957
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2958 pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2959 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2960 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2961
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2962 if (accepted_.empty())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2963 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2964 throw OrthancException(ErrorCode_NoPresentationContext,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2965 "Unable to negotiate a presentation context with AET \"" +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2966 parameters.GetRemoteApplicationEntityTitle() + "\"");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2967 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2968 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2969
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2970 void Close()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2971 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2972 if (isOpen_)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2973 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2974 CloseInternal();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2975 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2976 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2977
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2978 bool LookupAcceptedPresentationContext(std::map<DicomTransferSyntax, uint8_t>& target,
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2979 const std::string& abstractSyntax) const
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2980 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2981 if (!IsOpen())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2982 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2983 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Connection not opened");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2984 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2985
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2986 AcceptedPresentationContexts::const_iterator found = accepted_.find(abstractSyntax);
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2987
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2988 if (found == accepted_.end())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2989 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2990 return false;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2991 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2992 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2993 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2994 target = found->second;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2995 return true;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2996 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2997 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
2998
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
2999 void ProposeGenericPresentationContext(const std::string& abstractSyntax)
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3000 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3001 std::set<DicomTransferSyntax> ts;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3002 ts.insert(DicomTransferSyntax_LittleEndianImplicit);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3003 ts.insert(DicomTransferSyntax_LittleEndianExplicit);
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
3004 ts.insert(DicomTransferSyntax_BigEndianExplicit); // Retired
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
3005 ProposePresentationContext(abstractSyntax, ts);
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3006 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3007
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
3008 void ProposePresentationContext(const std::string& abstractSyntax,
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3009 DicomTransferSyntax transferSyntax)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3010 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3011 std::set<DicomTransferSyntax> ts;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3012 ts.insert(transferSyntax);
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
3013 ProposePresentationContext(abstractSyntax, ts);
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3014 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3015
3822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
3016 size_t GetRemainingPropositions() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
3017 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
3018 assert(proposed_.size() <= MAX_PROPOSED_PRESENTATIONS);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
3019 return MAX_PROPOSED_PRESENTATIONS - proposed_.size();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
3020 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
3021
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
3022 void ProposePresentationContext(const std::string& abstractSyntax,
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3023 const std::set<DicomTransferSyntax>& transferSyntaxes)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3024 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3025 if (transferSyntaxes.empty())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3026 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3027 throw OrthancException(ErrorCode_ParameterOutOfRange,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3028 "No transfer syntax provided");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3029 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3030
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3031 if (proposed_.size() >= MAX_PROPOSED_PRESENTATIONS)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3032 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3033 throw OrthancException(ErrorCode_ParameterOutOfRange,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3034 "Too many proposed presentation contexts");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3035 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3036
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3037 if (IsOpen())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3038 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3039 Close();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3040 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3041
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3042 ProposedPresentationContext context;
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
3043 context.abstractSyntax_ = abstractSyntax;
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3044 context.transferSyntaxes_ = transferSyntaxes;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3045
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3046 proposed_.push_back(context);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3047 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3048
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3049 T_ASC_Association& GetDcmtkAssociation() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3050 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3051 if (isOpen_)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3052 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3053 assert(assoc_ != NULL);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3054 return *assoc_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3055 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3056 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3057 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3058 throw OrthancException(ErrorCode_BadSequenceOfCalls,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3059 "The connection is not open");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3060 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3061 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3062
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3063 T_ASC_Network& GetDcmtkNetwork() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3064 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3065 if (isOpen_)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3066 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3067 assert(net_ != NULL);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3068 return *net_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3069 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3070 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3071 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3072 throw OrthancException(ErrorCode_BadSequenceOfCalls,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3073 "The connection is not open");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3074 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3075 }
3821
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3076
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3077
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3078 static void ReportStorageCommitment(const DicomAssociationParameters& parameters,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3079 const std::string& transactionUid,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3080 const std::vector<std::string>& sopClassUids,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3081 const std::vector<std::string>& sopInstanceUids,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3082 const std::vector<StorageCommitmentFailureReason>& failureReasons)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3083 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3084 if (sopClassUids.size() != sopInstanceUids.size() ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3085 sopClassUids.size() != failureReasons.size())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3086 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3087 throw OrthancException(ErrorCode_ParameterOutOfRange);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3088 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3089
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3090
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3091 std::vector<std::string> successSopClassUids, successSopInstanceUids, failedSopClassUids, failedSopInstanceUids;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3092 std::vector<StorageCommitmentFailureReason> failedReasons;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3093
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3094 successSopClassUids.reserve(sopClassUids.size());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3095 successSopInstanceUids.reserve(sopClassUids.size());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3096 failedSopClassUids.reserve(sopClassUids.size());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3097 failedSopInstanceUids.reserve(sopClassUids.size());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3098 failedReasons.reserve(sopClassUids.size());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3099
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3100 for (size_t i = 0; i < sopClassUids.size(); i++)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3101 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3102 switch (failureReasons[i])
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3103 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3104 case StorageCommitmentFailureReason_Success:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3105 successSopClassUids.push_back(sopClassUids[i]);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3106 successSopInstanceUids.push_back(sopInstanceUids[i]);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3107 break;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3108
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3109 case StorageCommitmentFailureReason_ProcessingFailure:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3110 case StorageCommitmentFailureReason_NoSuchObjectInstance:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3111 case StorageCommitmentFailureReason_ResourceLimitation:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3112 case StorageCommitmentFailureReason_ReferencedSOPClassNotSupported:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3113 case StorageCommitmentFailureReason_ClassInstanceConflict:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3114 case StorageCommitmentFailureReason_DuplicateTransactionUID:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3115 failedSopClassUids.push_back(sopClassUids[i]);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3116 failedSopInstanceUids.push_back(sopInstanceUids[i]);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3117 failedReasons.push_back(failureReasons[i]);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3118 break;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3119
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3120 default:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3121 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3122 char buf[16];
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3123 sprintf(buf, "%04xH", failureReasons[i]);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3124 throw OrthancException(ErrorCode_ParameterOutOfRange,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3125 "Unsupported failure reason for storage commitment: " + std::string(buf));
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3126 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3127 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3128 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3129
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3130 DicomAssociation association;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3131
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3132 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3133 std::set<DicomTransferSyntax> transferSyntaxes;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3134 transferSyntaxes.insert(DicomTransferSyntax_LittleEndianExplicit);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3135 transferSyntaxes.insert(DicomTransferSyntax_LittleEndianImplicit);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3136
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3137 association.SetRole(DicomAssociationRole_Scp);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3138 association.ProposePresentationContext(UID_StorageCommitmentPushModelSOPClass,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3139 transferSyntaxes);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3140 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3141
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3142 association.Open(parameters);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3143
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3144 /**
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3145 * N-EVENT-REPORT
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3146 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part04/sect_J.3.3.html
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3147 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#table_10.1-1
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3148 *
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3149 * Status code:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3150 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#sect_10.1.1.1.8
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3151 **/
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3152
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3153 /**
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3154 * Send the "EVENT_REPORT_RQ" request
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3155 **/
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3156
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3157 LOG(INFO) << "Reporting modality \""
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3158 << parameters.GetRemoteApplicationEntityTitle()
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3159 << "\" about storage commitment transaction: " << transactionUid
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3160 << " (" << successSopClassUids.size() << " successes, "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3161 << failedSopClassUids.size() << " failures)";
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3162 const DIC_US messageId = association.GetDcmtkAssociation().nextMsgID++;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3163
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3164 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3165 T_DIMSE_Message message;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3166 memset(&message, 0, sizeof(message));
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3167 message.CommandField = DIMSE_N_EVENT_REPORT_RQ;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3168
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3169 T_DIMSE_N_EventReportRQ& content = message.msg.NEventReportRQ;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3170 content.MessageID = messageId;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3171 strncpy(content.AffectedSOPClassUID, UID_StorageCommitmentPushModelSOPClass, DIC_UI_LEN);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3172 strncpy(content.AffectedSOPInstanceUID, UID_StorageCommitmentPushModelSOPInstance, DIC_UI_LEN);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3173 content.DataSetType = DIMSE_DATASET_PRESENT;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3174
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3175 DcmDataset dataset;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3176 if (!dataset.putAndInsertString(DCM_TransactionUID, transactionUid.c_str()).good())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3177 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3178 throw OrthancException(ErrorCode_InternalError);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3179 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3180
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3181 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3182 std::vector<StorageCommitmentFailureReason> empty;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3183 FillSopSequence(dataset, DCM_ReferencedSOPSequence, successSopClassUids,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3184 successSopInstanceUids, empty, false);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3185 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3186
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3187 // http://dicom.nema.org/medical/dicom/2019a/output/chtml/part04/sect_J.3.3.html
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3188 if (failedSopClassUids.empty())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3189 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3190 content.EventTypeID = 1; // "Storage Commitment Request Successful"
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3191 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3192 else
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3193 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3194 content.EventTypeID = 2; // "Storage Commitment Request Complete - Failures Exist"
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3195
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3196 // Failure reason
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3197 // http://dicom.nema.org/medical/dicom/2019a/output/chtml/part03/sect_C.14.html#sect_C.14.1.1
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3198 FillSopSequence(dataset, DCM_FailedSOPSequence, failedSopClassUids,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3199 failedSopInstanceUids, failedReasons, true);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3200 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3201
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3202 int presID = ASC_findAcceptedPresentationContextID(
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3203 &association.GetDcmtkAssociation(), UID_StorageCommitmentPushModelSOPClass);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3204 if (presID == 0)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3205 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3206 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3207 "Unable to send N-EVENT-REPORT request to AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3208 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3209 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3210
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3211 if (!DIMSE_sendMessageUsingMemoryData(
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3212 &association.GetDcmtkAssociation(), presID, &message, NULL /* status detail */,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3213 &dataset, NULL /* callback */, NULL /* callback context */,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3214 NULL /* commandSet */).good())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3215 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3216 throw OrthancException(ErrorCode_NetworkProtocol);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3217 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3218 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3219
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3220 /**
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3221 * Read the "EVENT_REPORT_RSP" response
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3222 **/
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3223
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3224 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3225 T_ASC_PresentationContextID presID = 0;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3226 T_DIMSE_Message message;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3227
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3228 if (!DIMSE_receiveCommand(&association.GetDcmtkAssociation(),
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3229 (parameters.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3230 parameters.GetTimeout(), &presID, &message,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3231 NULL /* no statusDetail */).good() ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3232 message.CommandField != DIMSE_N_EVENT_REPORT_RSP)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3233 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3234 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3235 "Unable to read N-EVENT-REPORT response from AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3236 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3237 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3238
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3239 const T_DIMSE_N_EventReportRSP& content = message.msg.NEventReportRSP;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3240 if (content.MessageIDBeingRespondedTo != messageId ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3241 !(content.opts & O_NEVENTREPORT_AFFECTEDSOPCLASSUID) ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3242 !(content.opts & O_NEVENTREPORT_AFFECTEDSOPINSTANCEUID) ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3243 //(content.opts & O_NEVENTREPORT_EVENTTYPEID) || // Pedantic test - The "content.EventTypeID" is not used by Orthanc
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3244 std::string(content.AffectedSOPClassUID) != UID_StorageCommitmentPushModelSOPClass ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3245 std::string(content.AffectedSOPInstanceUID) != UID_StorageCommitmentPushModelSOPInstance ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3246 content.DataSetType != DIMSE_DATASET_NULL)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3247 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3248 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3249 "Badly formatted N-EVENT-REPORT response from AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3250 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3251 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3252
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3253 if (content.DimseStatus != 0 /* success */)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3254 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3255 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3256 "The request cannot be handled by remote AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3257 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3258 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3259 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3260
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3261 association.Close();
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3262 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3263
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3264 static void RequestStorageCommitment(const DicomAssociationParameters& parameters,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3265 const std::string& transactionUid,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3266 const std::vector<std::string>& sopClassUids,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3267 const std::vector<std::string>& sopInstanceUids)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3268 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3269 if (sopClassUids.size() != sopInstanceUids.size())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3270 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3271 throw OrthancException(ErrorCode_ParameterOutOfRange);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3272 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3273
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3274 for (size_t i = 0; i < sopClassUids.size(); i++)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3275 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3276 if (sopClassUids[i].empty() ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3277 sopInstanceUids[i].empty())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3278 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3279 throw OrthancException(ErrorCode_ParameterOutOfRange,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3280 "The SOP class/instance UIDs cannot be empty, found: \"" +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3281 sopClassUids[i] + "\" / \"" + sopInstanceUids[i] + "\"");
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3282 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3283 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3284
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3285 if (transactionUid.size() < 5 ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3286 transactionUid.substr(0, 5) != "2.25.")
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3287 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3288 throw OrthancException(ErrorCode_ParameterOutOfRange);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3289 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3290
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3291 DicomAssociation association;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3292
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3293 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3294 std::set<DicomTransferSyntax> transferSyntaxes;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3295 transferSyntaxes.insert(DicomTransferSyntax_LittleEndianExplicit);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3296 transferSyntaxes.insert(DicomTransferSyntax_LittleEndianImplicit);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3297
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3298 association.SetRole(DicomAssociationRole_Default);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3299 association.ProposePresentationContext(UID_StorageCommitmentPushModelSOPClass,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3300 transferSyntaxes);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3301 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3302
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3303 association.Open(parameters);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3304
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3305 /**
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3306 * N-ACTION
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3307 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part04/sect_J.3.2.html
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3308 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#table_10.1-4
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3309 *
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3310 * Status code:
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3311 * http://dicom.nema.org/medical/dicom/2019a/output/chtml/part07/chapter_10.html#sect_10.1.1.1.8
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3312 **/
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3313
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3314 /**
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3315 * Send the "N_ACTION_RQ" request
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3316 **/
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3317
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3318 LOG(INFO) << "Request to modality \""
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3319 << parameters.GetRemoteApplicationEntityTitle()
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3320 << "\" about storage commitment for " << sopClassUids.size()
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3321 << " instances, with transaction UID: " << transactionUid;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3322 const DIC_US messageId = association.GetDcmtkAssociation().nextMsgID++;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3323
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3324 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3325 T_DIMSE_Message message;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3326 memset(&message, 0, sizeof(message));
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3327 message.CommandField = DIMSE_N_ACTION_RQ;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3328
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3329 T_DIMSE_N_ActionRQ& content = message.msg.NActionRQ;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3330 content.MessageID = messageId;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3331 strncpy(content.RequestedSOPClassUID, UID_StorageCommitmentPushModelSOPClass, DIC_UI_LEN);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3332 strncpy(content.RequestedSOPInstanceUID, UID_StorageCommitmentPushModelSOPInstance, DIC_UI_LEN);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3333 content.ActionTypeID = 1; // "Request Storage Commitment"
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3334 content.DataSetType = DIMSE_DATASET_PRESENT;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3335
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3336 DcmDataset dataset;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3337 if (!dataset.putAndInsertString(DCM_TransactionUID, transactionUid.c_str()).good())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3338 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3339 throw OrthancException(ErrorCode_InternalError);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3340 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3341
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3342 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3343 std::vector<StorageCommitmentFailureReason> empty;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3344 FillSopSequence(dataset, DCM_ReferencedSOPSequence, sopClassUids, sopInstanceUids, empty, false);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3345 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3346
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3347 int presID = ASC_findAcceptedPresentationContextID(
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3348 &association.GetDcmtkAssociation(), UID_StorageCommitmentPushModelSOPClass);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3349 if (presID == 0)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3350 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3351 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3352 "Unable to send N-ACTION request to AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3353 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3354 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3355
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3356 if (!DIMSE_sendMessageUsingMemoryData(
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3357 &association.GetDcmtkAssociation(), presID, &message, NULL /* status detail */,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3358 &dataset, NULL /* callback */, NULL /* callback context */,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3359 NULL /* commandSet */).good())
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3360 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3361 throw OrthancException(ErrorCode_NetworkProtocol);
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3362 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3363 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3364
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3365 /**
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3366 * Read the "N_ACTION_RSP" response
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3367 **/
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3368
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3369 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3370 T_ASC_PresentationContextID presID = 0;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3371 T_DIMSE_Message message;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3372
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3373 if (!DIMSE_receiveCommand(&association.GetDcmtkAssociation(),
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3374 (parameters.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3375 parameters.GetTimeout(), &presID, &message,
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3376 NULL /* no statusDetail */).good() ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3377 message.CommandField != DIMSE_N_ACTION_RSP)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3378 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3379 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3380 "Unable to read N-ACTION response from AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3381 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3382 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3383
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3384 const T_DIMSE_N_ActionRSP& content = message.msg.NActionRSP;
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3385 if (content.MessageIDBeingRespondedTo != messageId ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3386 !(content.opts & O_NACTION_AFFECTEDSOPCLASSUID) ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3387 !(content.opts & O_NACTION_AFFECTEDSOPINSTANCEUID) ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3388 //(content.opts & O_NACTION_ACTIONTYPEID) || // Pedantic test - The "content.ActionTypeID" is not used by Orthanc
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3389 std::string(content.AffectedSOPClassUID) != UID_StorageCommitmentPushModelSOPClass ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3390 std::string(content.AffectedSOPInstanceUID) != UID_StorageCommitmentPushModelSOPInstance ||
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3391 content.DataSetType != DIMSE_DATASET_NULL)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3392 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3393 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3394 "Badly formatted N-ACTION response from AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3395 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3396 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3397
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3398 if (content.DimseStatus != 0 /* success */)
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3399 {
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3400 throw OrthancException(ErrorCode_NetworkProtocol, "Storage commitment - "
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3401 "The request cannot be handled by remote AET: " +
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3402 parameters.GetRemoteApplicationEntityTitle());
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3403 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3404 }
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3405
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3406 association.Close();
f2488b645f5f adding storage commitment to DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3820
diff changeset
3407 }
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3408 };
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3409
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3410
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3411
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3412 static void TestAndCopyTag(DicomMap& result,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3413 const DicomMap& source,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3414 const DicomTag& tag)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3415 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3416 if (!source.HasTag(tag))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3417 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3418 throw OrthancException(ErrorCode_BadRequest);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3419 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3420 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3421 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3422 result.SetValue(tag, source.GetValue(tag));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3423 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3424 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3425
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3426
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3427 namespace
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3428 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3429 struct FindPayload
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3430 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3431 DicomFindAnswers* answers;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3432 const char* level;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3433 bool isWorklist;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3434 };
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3435 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3436
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3437
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3438 static void FindCallback(
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3439 /* in */
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3440 void *callbackData,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3441 T_DIMSE_C_FindRQ *request, /* original find request */
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3442 int responseCount,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3443 T_DIMSE_C_FindRSP *response, /* pending response received */
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3444 DcmDataset *responseIdentifiers /* pending response identifiers */
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3445 )
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3446 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3447 FindPayload& payload = *reinterpret_cast<FindPayload*>(callbackData);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3448
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3449 if (responseIdentifiers != NULL)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3450 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3451 if (payload.isWorklist)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3452 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3453 ParsedDicomFile answer(*responseIdentifiers);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3454 payload.answers->Add(answer);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3455 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3456 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3457 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3458 DicomMap m;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3459 FromDcmtkBridge::ExtractDicomSummary(m, *responseIdentifiers);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3460
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3461 if (!m.HasTag(DICOM_TAG_QUERY_RETRIEVE_LEVEL))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3462 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3463 m.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, payload.level, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3464 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3465
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3466 payload.answers->Add(m);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3467 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3468 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3469 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3470
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3471
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3472 static void NormalizeFindQuery(DicomMap& fixedQuery,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3473 ResourceType level,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3474 const DicomMap& fields)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3475 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3476 std::set<DicomTag> allowedTags;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3477
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3478 // WARNING: Do not add "break" or reorder items in this switch-case!
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3479 switch (level)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3480 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3481 case ResourceType_Instance:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3482 DicomTag::AddTagsForModule(allowedTags, DicomModule_Instance);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3483
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3484 case ResourceType_Series:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3485 DicomTag::AddTagsForModule(allowedTags, DicomModule_Series);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3486
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3487 case ResourceType_Study:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3488 DicomTag::AddTagsForModule(allowedTags, DicomModule_Study);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3489
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3490 case ResourceType_Patient:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3491 DicomTag::AddTagsForModule(allowedTags, DicomModule_Patient);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3492 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3493
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3494 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3495 throw OrthancException(ErrorCode_InternalError);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3496 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3497
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3498 switch (level)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3499 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3500 case ResourceType_Patient:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3501 allowedTags.insert(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3502 allowedTags.insert(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3503 allowedTags.insert(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3504 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3505
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3506 case ResourceType_Study:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3507 allowedTags.insert(DICOM_TAG_MODALITIES_IN_STUDY);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3508 allowedTags.insert(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3509 allowedTags.insert(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3510 allowedTags.insert(DICOM_TAG_SOP_CLASSES_IN_STUDY);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3511 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3512
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3513 case ResourceType_Series:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3514 allowedTags.insert(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3515 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3516
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3517 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3518 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3519 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3520
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3521 allowedTags.insert(DICOM_TAG_SPECIFIC_CHARACTER_SET);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3522
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3523 DicomArray query(fields);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3524 for (size_t i = 0; i < query.GetSize(); i++)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3525 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3526 const DicomTag& tag = query.GetElement(i).GetTag();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3527 if (allowedTags.find(tag) == allowedTags.end())
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3528 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3529 LOG(WARNING) << "Tag not allowed for this C-Find level, will be ignored: " << tag;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3530 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3531 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3532 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3533 fixedQuery.SetValue(tag, query.GetElement(i).GetValue());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3534 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3535 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3536 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3537
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3538
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3539
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3540 static ParsedDicomFile* ConvertQueryFields(const DicomMap& fields,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3541 ModalityManufacturer manufacturer)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3542 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3543 // Fix outgoing C-Find requests issue for Syngo.Via and its
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3544 // solution was reported by Emsy Chan by private mail on
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3545 // 2015-06-17. According to Robert van Ommen (2015-11-30), the
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3546 // same fix is required for Agfa Impax. This was generalized for
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3547 // generic manufacturer since it seems to affect PhilipsADW,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3548 // GEWAServer as well:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3549 // https://bitbucket.org/sjodogne/orthanc/issues/31/
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3550
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3551 switch (manufacturer)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3552 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3553 case ModalityManufacturer_GenericNoWildcardInDates:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3554 case ModalityManufacturer_GenericNoUniversalWildcard:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3555 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3556 std::unique_ptr<DicomMap> fix(fields.Clone());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3557
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3558 std::set<DicomTag> tags;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3559 fix->GetTags(tags);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3560
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3561 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3562 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3563 // Replace a "*" wildcard query by an empty query ("") for
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3564 // "date" or "all" value representations depending on the
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3565 // type of manufacturer.
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3566 if (manufacturer == ModalityManufacturer_GenericNoUniversalWildcard ||
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3567 (manufacturer == ModalityManufacturer_GenericNoWildcardInDates &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3568 FromDcmtkBridge::LookupValueRepresentation(*it) == ValueRepresentation_Date))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3569 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3570 const DicomValue* value = fix->TestAndGetValue(*it);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3571
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3572 if (value != NULL &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3573 !value->IsNull() &&
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3574 value->GetContent() == "*")
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3575 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3576 fix->SetValue(*it, "", false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3577 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3578 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3579 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3580
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3581 return new ParsedDicomFile(*fix, GetDefaultDicomEncoding(), false /* be strict */);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3582 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3583
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3584 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3585 return new ParsedDicomFile(fields, GetDefaultDicomEncoding(), false /* be strict */);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3586 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3587 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3588
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3589
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3590
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3591 class DicomControlUserConnection : public boost::noncopyable
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3592 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3593 private:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3594 DicomAssociationParameters parameters_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3595 DicomAssociation association_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3596
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3597 void SetupPresentationContexts()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3598 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3599 association_.ProposeGenericPresentationContext(UID_VerificationSOPClass);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3600 association_.ProposeGenericPresentationContext(UID_FINDPatientRootQueryRetrieveInformationModel);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3601 association_.ProposeGenericPresentationContext(UID_FINDStudyRootQueryRetrieveInformationModel);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3602 association_.ProposeGenericPresentationContext(UID_MOVEStudyRootQueryRetrieveInformationModel);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3603 association_.ProposeGenericPresentationContext(UID_FINDModalityWorklistInformationModel);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3604 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3605
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3606 void FindInternal(DicomFindAnswers& answers,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3607 DcmDataset* dataset,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3608 const char* sopClass,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3609 bool isWorklist,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3610 const char* level)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3611 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3612 assert(isWorklist ^ (level != NULL));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3613
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3614 association_.Open(parameters_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3615
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3616 FindPayload payload;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3617 payload.answers = &answers;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3618 payload.level = level;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3619 payload.isWorklist = isWorklist;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3620
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3621 // Figure out which of the accepted presentation contexts should be used
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3622 int presID = ASC_findAcceptedPresentationContextID(
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3623 &association_.GetDcmtkAssociation(), sopClass);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3624 if (presID == 0)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3625 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3626 throw OrthancException(ErrorCode_DicomFindUnavailable,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3627 "Remote AET is " + parameters_.GetRemoteApplicationEntityTitle());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3628 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3629
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3630 T_DIMSE_C_FindRQ request;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3631 memset(&request, 0, sizeof(request));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3632 request.MessageID = association_.GetDcmtkAssociation().nextMsgID++;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3633 strncpy(request.AffectedSOPClassUID, sopClass, DIC_UI_LEN);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3634 request.Priority = DIMSE_PRIORITY_MEDIUM;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3635 request.DataSetType = DIMSE_DATASET_PRESENT;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3636
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3637 T_DIMSE_C_FindRSP response;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3638 DcmDataset* statusDetail = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3639
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3640 #if DCMTK_VERSION_NUMBER >= 364
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3641 int responseCount;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3642 #endif
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3643
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3644 OFCondition cond = DIMSE_findUser(
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3645 &association_.GetDcmtkAssociation(), presID, &request, dataset,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3646 #if DCMTK_VERSION_NUMBER >= 364
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3647 responseCount,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3648 #endif
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3649 FindCallback, &payload,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3650 /*opt_blockMode*/ (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3651 /*opt_dimse_timeout*/ parameters_.GetTimeout(),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3652 &response, &statusDetail);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3653
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3654 if (statusDetail)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3655 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3656 delete statusDetail;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3657 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3658
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3659 parameters_.CheckCondition(cond, "C-FIND");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3660
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3661
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3662 /**
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3663 * New in Orthanc 1.6.0: Deal with failures during C-FIND.
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3664 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#table_C.4-1
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3665 **/
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3666
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3667 if (response.DimseStatus != 0x0000 && // Success
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3668 response.DimseStatus != 0xFF00 && // Pending - Matches are continuing
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3669 response.DimseStatus != 0xFF01) // Pending - Matches are continuing
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3670 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3671 char buf[16];
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3672 sprintf(buf, "%04X", response.DimseStatus);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3673
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3674 if (response.DimseStatus == STATUS_FIND_Failed_UnableToProcess)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3675 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3676 throw OrthancException(ErrorCode_NetworkProtocol,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3677 HttpStatus_422_UnprocessableEntity,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3678 "C-FIND SCU to AET \"" +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3679 parameters_.GetRemoteApplicationEntityTitle() +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3680 "\" has failed with DIMSE status 0x" + buf +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3681 " (unable to process - invalid query ?)");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3682 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3683 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3684 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3685 throw OrthancException(ErrorCode_NetworkProtocol, "C-FIND SCU to AET \"" +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3686 parameters_.GetRemoteApplicationEntityTitle() +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3687 "\" has failed with DIMSE status 0x" + buf);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3688 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3689 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3690 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3691
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3692 void MoveInternal(const std::string& targetAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3693 ResourceType level,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3694 const DicomMap& fields)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3695 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3696 association_.Open(parameters_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3697
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3698 std::unique_ptr<ParsedDicomFile> query(
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3699 ConvertQueryFields(fields, parameters_.GetRemoteManufacturer()));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3700 DcmDataset* dataset = query->GetDcmtkObject().getDataset();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3701
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3702 const char* sopClass = UID_MOVEStudyRootQueryRetrieveInformationModel;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3703 switch (level)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3704 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3705 case ResourceType_Patient:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3706 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "PATIENT");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3707 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3708
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3709 case ResourceType_Study:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3710 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "STUDY");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3711 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3712
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3713 case ResourceType_Series:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3714 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "SERIES");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3715 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3716
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3717 case ResourceType_Instance:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3718 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "IMAGE");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3719 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3720
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3721 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3722 throw OrthancException(ErrorCode_ParameterOutOfRange);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3723 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3724
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3725 // Figure out which of the accepted presentation contexts should be used
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3726 int presID = ASC_findAcceptedPresentationContextID(&association_.GetDcmtkAssociation(), sopClass);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3727 if (presID == 0)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3728 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3729 throw OrthancException(ErrorCode_DicomMoveUnavailable,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3730 "Remote AET is " + parameters_.GetRemoteApplicationEntityTitle());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3731 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3732
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3733 T_DIMSE_C_MoveRQ request;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3734 memset(&request, 0, sizeof(request));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3735 request.MessageID = association_.GetDcmtkAssociation().nextMsgID++;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3736 strncpy(request.AffectedSOPClassUID, sopClass, DIC_UI_LEN);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3737 request.Priority = DIMSE_PRIORITY_MEDIUM;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3738 request.DataSetType = DIMSE_DATASET_PRESENT;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3739 strncpy(request.MoveDestination, targetAet.c_str(), DIC_AE_LEN);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3740
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3741 T_DIMSE_C_MoveRSP response;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3742 DcmDataset* statusDetail = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3743 DcmDataset* responseIdentifiers = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3744 OFCondition cond = DIMSE_moveUser(
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3745 &association_.GetDcmtkAssociation(), presID, &request, dataset, NULL, NULL,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3746 /*opt_blockMode*/ (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3747 /*opt_dimse_timeout*/ parameters_.GetTimeout(),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3748 &association_.GetDcmtkNetwork(), NULL, NULL,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3749 &response, &statusDetail, &responseIdentifiers);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3750
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3751 if (statusDetail)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3752 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3753 delete statusDetail;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3754 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3755
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3756 if (responseIdentifiers)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3757 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3758 delete responseIdentifiers;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3759 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3760
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3761 parameters_.CheckCondition(cond, "C-MOVE");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3762
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3763
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3764 /**
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3765 * New in Orthanc 1.6.0: Deal with failures during C-MOVE.
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3766 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.2.html#table_C.4-2
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3767 **/
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3768
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3769 if (response.DimseStatus != 0x0000 && // Success
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3770 response.DimseStatus != 0xFF00) // Pending - Sub-operations are continuing
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3771 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3772 char buf[16];
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3773 sprintf(buf, "%04X", response.DimseStatus);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3774
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3775 if (response.DimseStatus == STATUS_MOVE_Failed_UnableToProcess)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3776 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3777 throw OrthancException(ErrorCode_NetworkProtocol,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3778 HttpStatus_422_UnprocessableEntity,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3779 "C-MOVE SCU to AET \"" +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3780 parameters_.GetRemoteApplicationEntityTitle() +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3781 "\" has failed with DIMSE status 0x" + buf +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3782 " (unable to process - resource not found ?)");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3783 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3784 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3785 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3786 throw OrthancException(ErrorCode_NetworkProtocol, "C-MOVE SCU to AET \"" +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3787 parameters_.GetRemoteApplicationEntityTitle() +
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3788 "\" has failed with DIMSE status 0x" + buf);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3789 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3790 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3791 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3792
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3793 public:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3794 DicomControlUserConnection(const DicomAssociationParameters& params) :
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3795 parameters_(params)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3796 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3797 SetupPresentationContexts();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3798 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3799
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3800 const DicomAssociationParameters& GetParameters() const
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3801 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3802 return parameters_;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3803 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3804
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3805 bool Echo()
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3806 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3807 association_.Open(parameters_);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3808
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3809 DIC_US status;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3810 parameters_.CheckCondition(
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3811 DIMSE_echoUser(&association_.GetDcmtkAssociation(),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3812 association_.GetDcmtkAssociation().nextMsgID++,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3813 /*opt_blockMode*/ (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3814 /*opt_dimse_timeout*/ parameters_.GetTimeout(),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3815 &status, NULL),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3816 "C-ECHO");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3817
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3818 return status == STATUS_Success;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3819 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3821
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3822 void Find(DicomFindAnswers& result,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3823 ResourceType level,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3824 const DicomMap& originalFields,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3825 bool normalize)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3826 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3827 std::unique_ptr<ParsedDicomFile> query;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3828
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3829 if (normalize)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3830 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3831 DicomMap fields;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3832 NormalizeFindQuery(fields, level, originalFields);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3833 query.reset(ConvertQueryFields(fields, parameters_.GetRemoteManufacturer()));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3834 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3835 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3836 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3837 query.reset(new ParsedDicomFile(originalFields,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3838 GetDefaultDicomEncoding(),
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3839 false /* be strict */));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3840 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3841
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3842 DcmDataset* dataset = query->GetDcmtkObject().getDataset();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3843
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3844 const char* clevel = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3845 const char* sopClass = NULL;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3846
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3847 switch (level)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3848 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3849 case ResourceType_Patient:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3850 clevel = "PATIENT";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3851 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "PATIENT");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3852 sopClass = UID_FINDPatientRootQueryRetrieveInformationModel;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3853 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3854
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3855 case ResourceType_Study:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3856 clevel = "STUDY";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3857 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "STUDY");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3858 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3859 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3860
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3861 case ResourceType_Series:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3862 clevel = "SERIES";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3863 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "SERIES");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3864 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3865 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3866
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3867 case ResourceType_Instance:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3868 clevel = "IMAGE";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3869 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "IMAGE");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3870 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3871 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3872
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3873 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3874 throw OrthancException(ErrorCode_ParameterOutOfRange);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3875 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3876
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3877
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3878 const char* universal;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3879 if (parameters_.GetRemoteManufacturer() == ModalityManufacturer_GE)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3880 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3881 universal = "*";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3882 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3883 else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3884 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3885 universal = "";
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3886 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3887
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3888
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3889 // Add the expected tags for this query level.
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3890 // WARNING: Do not reorder or add "break" in this switch-case!
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3891 switch (level)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3892 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3893 case ResourceType_Instance:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3894 if (!dataset->tagExists(DCM_SOPInstanceUID))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3895 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3896 DU_putStringDOElement(dataset, DCM_SOPInstanceUID, universal);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3897 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3898
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3899 case ResourceType_Series:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3900 if (!dataset->tagExists(DCM_SeriesInstanceUID))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3901 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3902 DU_putStringDOElement(dataset, DCM_SeriesInstanceUID, universal);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3903 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3904
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3905 case ResourceType_Study:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3906 if (!dataset->tagExists(DCM_AccessionNumber))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3907 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3908 DU_putStringDOElement(dataset, DCM_AccessionNumber, universal);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3909 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3910
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3911 if (!dataset->tagExists(DCM_StudyInstanceUID))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3912 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3913 DU_putStringDOElement(dataset, DCM_StudyInstanceUID, universal);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3914 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3915
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3916 case ResourceType_Patient:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3917 if (!dataset->tagExists(DCM_PatientID))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3918 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3919 DU_putStringDOElement(dataset, DCM_PatientID, universal);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3920 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3921
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3922 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3923
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3924 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3925 throw OrthancException(ErrorCode_ParameterOutOfRange);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3926 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3927
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3928 assert(clevel != NULL && sopClass != NULL);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3929 FindInternal(result, dataset, sopClass, false, clevel);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3930 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3931
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3932
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3933 void Move(const std::string& targetAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3934 ResourceType level,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3935 const DicomMap& findResult)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3936 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3937 DicomMap move;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3938 switch (level)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3939 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3940 case ResourceType_Patient:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3941 TestAndCopyTag(move, findResult, DICOM_TAG_PATIENT_ID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3942 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3943
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3944 case ResourceType_Study:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3945 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3946 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3947
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3948 case ResourceType_Series:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3949 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3950 TestAndCopyTag(move, findResult, DICOM_TAG_SERIES_INSTANCE_UID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3951 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3952
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3953 case ResourceType_Instance:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3954 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3955 TestAndCopyTag(move, findResult, DICOM_TAG_SERIES_INSTANCE_UID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3956 TestAndCopyTag(move, findResult, DICOM_TAG_SOP_INSTANCE_UID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3957 break;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3958
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3959 default:
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3960 throw OrthancException(ErrorCode_InternalError);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3961 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3962
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3963 MoveInternal(targetAet, level, move);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3964 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3965
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3966
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3967 void Move(const std::string& targetAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3968 const DicomMap& findResult)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3969 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3970 if (!findResult.HasTag(DICOM_TAG_QUERY_RETRIEVE_LEVEL))
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3971 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3972 throw OrthancException(ErrorCode_InternalError);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3973 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3974
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3975 const std::string tmp = findResult.GetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL).GetContent();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3976 ResourceType level = StringToResourceType(tmp.c_str());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3977
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3978 Move(targetAet, level, findResult);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3979 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3980
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3981
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3982 void MovePatient(const std::string& targetAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3983 const std::string& patientId)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3984 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3985 DicomMap query;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3986 query.SetValue(DICOM_TAG_PATIENT_ID, patientId, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3987 MoveInternal(targetAet, ResourceType_Patient, query);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3988 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3989
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3990 void MoveStudy(const std::string& targetAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3991 const std::string& studyUid)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3992 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3993 DicomMap query;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3994 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3995 MoveInternal(targetAet, ResourceType_Study, query);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3996 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3997
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3998 void MoveSeries(const std::string& targetAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
3999 const std::string& studyUid,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4000 const std::string& seriesUid)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4001 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4002 DicomMap query;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4003 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4004 query.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4005 MoveInternal(targetAet, ResourceType_Series, query);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4006 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4007
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4008 void MoveInstance(const std::string& targetAet,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4009 const std::string& studyUid,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4010 const std::string& seriesUid,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4011 const std::string& instanceUid)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4012 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4013 DicomMap query;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4014 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4015 query.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4016 query.SetValue(DICOM_TAG_SOP_INSTANCE_UID, instanceUid, false);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4017 MoveInternal(targetAet, ResourceType_Instance, query);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4018 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4019
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4020
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4021 void FindWorklist(DicomFindAnswers& result,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4022 ParsedDicomFile& query)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4023 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4024 DcmDataset* dataset = query.GetDcmtkObject().getDataset();
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4025 const char* sopClass = UID_FINDModalityWorklistInformationModel;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4026
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4027 FindInternal(result, dataset, sopClass, true, NULL);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4028 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4029 };
3822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
4030
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
4031
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4032 class DicomStoreUserConnection : public boost::noncopyable
3822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
4033 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
4034 private:
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4035 typedef std::map<std::string, std::set<DicomTransferSyntax> > StorageClasses;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4036
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4037 DicomAssociationParameters parameters_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4038 DicomAssociation association_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4039 StorageClasses storageClasses_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4040 bool proposeCommonClasses_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4041 bool proposeUncompressedSyntaxes_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4042 bool proposeRetiredBigEndian_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4043
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4044
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4045 /**
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4046
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4047 Orthanc < 1.7.0:
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4048
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4049 Input | Output
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4050 -------------+---------------------------------------------
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4051 Compressed | Same transfer syntax
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4052 Uncompressed | Same transfer syntax, or other uncompressed
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4053
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4054 Orthanc >= 1.7.0:
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4055
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4056 Input | Output
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4057 -------------+---------------------------------------------
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4058 Compressed | Same transfer syntax, or uncompressed
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4059 Uncompressed | Same transfer syntax, or other uncompressed
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4060
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4061 **/
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4062
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4063
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4064 // Return "false" if there is not enough room remaining in the association
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4065 bool ProposeStorageClass(const std::string& sopClassUid,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4066 const std::set<DicomTransferSyntax>& syntaxes)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4067 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4068 size_t requiredCount = syntaxes.size();
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4069 if (proposeUncompressedSyntaxes_)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4070 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4071 requiredCount += 1;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4072 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4073
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4074 if (association_.GetRemainingPropositions() <= requiredCount)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4075 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4076 return false; // Not enough room
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4077 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4078
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4079 for (std::set<DicomTransferSyntax>::const_iterator
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4080 it = syntaxes.begin(); it != syntaxes.end(); ++it)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4081 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4082 association_.ProposePresentationContext(sopClassUid, *it);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4083 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4084
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4085 if (proposeUncompressedSyntaxes_)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4086 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4087 std::set<DicomTransferSyntax> uncompressed;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4088
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4089 if (syntaxes.find(DicomTransferSyntax_LittleEndianImplicit) == syntaxes.end())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4090 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4091 uncompressed.insert(DicomTransferSyntax_LittleEndianImplicit);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4092 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4093
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4094 if (syntaxes.find(DicomTransferSyntax_LittleEndianExplicit) == syntaxes.end())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4095 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4096 uncompressed.insert(DicomTransferSyntax_LittleEndianExplicit);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4097 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4098
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4099 if (proposeRetiredBigEndian_ &&
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4100 syntaxes.find(DicomTransferSyntax_BigEndianExplicit) == syntaxes.end())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4101 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4102 uncompressed.insert(DicomTransferSyntax_BigEndianExplicit);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4103 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4104
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4105 if (!uncompressed.empty())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4106 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4107 association_.ProposePresentationContext(sopClassUid, uncompressed);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4108 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4109 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4110
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4111 return true;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4112 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4113
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4114
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4115 bool LookupPresentationContext(uint8_t& presentationContextId,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4116 const std::string& sopClassUid,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4117 DicomTransferSyntax transferSyntax)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4118 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4119 typedef std::map<DicomTransferSyntax, uint8_t> PresentationContexts;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4120
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4121 PresentationContexts pc;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4122 if (association_.IsOpen() &&
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4123 association_.LookupAcceptedPresentationContext(pc, sopClassUid))
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4124 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4125 PresentationContexts::const_iterator found = pc.find(transferSyntax);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4126 if (found != pc.end())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4127 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4128 presentationContextId = found->second;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4129 return true;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4130 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4131 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4132
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4133 return false;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4134 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4135
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4136
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4137 bool NegotiatePresentationContext(uint8_t& presentationContextId,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4138 const std::string& sopClassUid,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4139 DicomTransferSyntax transferSyntax)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4140 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4141 /**
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4142 * Step 1: Check whether this presentation context is already
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4143 * available in the previously negociated assocation.
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4144 **/
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4145
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4146 if (LookupPresentationContext(presentationContextId, sopClassUid, transferSyntax))
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4147 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4148 return true;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4149 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4150
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4151 // The association must be re-negotiated
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4152 association_.ClearPresentationContexts();
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4153 PrepareStorageClass(sopClassUid, transferSyntax);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4154
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4155
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4156 /**
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4157 * Step 2: Propose at least the mandatory SOP class.
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4158 **/
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4159
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4160 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4161 StorageClasses::const_iterator mandatory = storageClasses_.find(sopClassUid);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4162
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4163 if (mandatory == storageClasses_.end() ||
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4164 mandatory->second.find(transferSyntax) == mandatory->second.end())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4165 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4166 throw OrthancException(ErrorCode_InternalError);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4167 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4168
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4169 if (!ProposeStorageClass(sopClassUid, mandatory->second))
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4170 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4171 // Should never happen in real life: There are no more than
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4172 // 128 transfer syntaxes in DICOM!
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4173 throw OrthancException(ErrorCode_InternalError,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4174 "Too many transfer syntaxes for SOP class UID: " + sopClassUid);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4175 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4176 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4177
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4178
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4179 /**
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4180 * Step 3: Propose all the previously spotted SOP classes, as
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4181 * registered through the "PrepareStorageClass()" method.
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4182 **/
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4183
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4184 for (StorageClasses::const_iterator it = storageClasses_.begin();
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4185 it != storageClasses_.end(); ++it)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4186 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4187 if (it->first != sopClassUid)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4188 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4189 ProposeStorageClass(it->first, it->second);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4190 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4191 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4192
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4193
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4194 /**
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4195 * Step 4: As long as there is room left in the proposed
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4196 * presentation contexts, propose the uncompressed transfer syntaxes
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4197 * for the most common SOP classes, as can be found in the
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4198 * "dcmShortSCUStorageSOPClassUIDs" array from DCMTK. The
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4199 * preferred transfer syntax is "LittleEndianImplicit".
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4200 **/
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4201
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4202 if (proposeCommonClasses_)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4203 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4204 std::set<DicomTransferSyntax> ts;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4205 ts.insert(DicomTransferSyntax_LittleEndianImplicit);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4206
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4207 for (int i = 0; i < numberOfDcmShortSCUStorageSOPClassUIDs; i++)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4208 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4209 std::string c(dcmShortSCUStorageSOPClassUIDs[i]);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4210
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4211 if (c != sopClassUid &&
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4212 storageClasses_.find(c) == storageClasses_.end())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4213 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4214 ProposeStorageClass(c, ts);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4215 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4216 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4217 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4218
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4219
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4220 /**
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4221 * Step 5: Open the association, and check whether the pair (SOP
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4222 * class UID, transfer syntax) was accepted by the remote host.
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4223 **/
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4224
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4225 association_.Open(parameters_);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4226 return LookupPresentationContext(presentationContextId, sopClassUid, transferSyntax);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4227 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4228
3822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
4229 public:
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4230 DicomStoreUserConnection(const DicomAssociationParameters& params) :
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4231 parameters_(params),
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4232 proposeCommonClasses_(true),
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4233 proposeUncompressedSyntaxes_(true),
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4234 proposeRetiredBigEndian_(false)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4235 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4236 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4237
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4238 const DicomAssociationParameters& GetParameters() const
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4239 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4240 return parameters_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4241 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4242
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4243 void SetCommonClassesProposed(bool proposed)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4244 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4245 proposeCommonClasses_ = proposed;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4246 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4247
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4248 bool IsCommonClassesProposed() const
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4249 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4250 return proposeCommonClasses_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4251 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4252
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4253 void SetUncompressedSyntaxesProposed(bool proposed)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4254 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4255 proposeUncompressedSyntaxes_ = proposed;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4256 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4257
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4258 bool IsUncompressedSyntaxesProposed() const
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4259 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4260 return proposeUncompressedSyntaxes_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4261 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4262
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4263 void SetRetiredBigEndianProposed(bool propose)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4264 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4265 proposeRetiredBigEndian_ = propose;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4266 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4267
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4268 bool IsRetiredBigEndianProposed() const
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4269 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4270 return proposeRetiredBigEndian_;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4271 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4272
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4273 void PrepareStorageClass(const std::string& sopClassUid,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4274 DicomTransferSyntax syntax)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4275 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4276 StorageClasses::iterator found = storageClasses_.find(sopClassUid);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4277
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4278 if (found == storageClasses_.end())
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4279 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4280 std::set<DicomTransferSyntax> ts;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4281 ts.insert(syntax);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4282 storageClasses_[sopClassUid] = ts;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4283 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4284 else
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4285 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4286 found->second.insert(syntax);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4287 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4288 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4289
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4290
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4291 void Toto(const std::string& sopClassUid,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4292 DicomTransferSyntax transferSyntax)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4293 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4294 uint8_t id;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4295
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4296 if (NegotiatePresentationContext(id, sopClassUid, transferSyntax))
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4297 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4298 printf("**** OK, without transcoding !! %d\n", id);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4299 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4300 else
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4301 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4302 // Transcoding - only in Orthanc >= 1.7.0
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4303
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4304 const DicomTransferSyntax uncompressed[] = {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4305 DicomTransferSyntax_LittleEndianImplicit, // Default transfer syntax
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4306 DicomTransferSyntax_LittleEndianExplicit,
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4307 DicomTransferSyntax_BigEndianExplicit
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4308 };
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4309
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4310 bool found = false;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4311 for (size_t i = 0; i < 3; i++)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4312 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4313 if (LookupPresentationContext(id, sopClassUid, uncompressed[i]))
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4314 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4315 printf("**** TRANSCODING to %s => %d\n",
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4316 GetTransferSyntaxUid(uncompressed[i]), id);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4317 found = true;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4318 break;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4319 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4320 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4321
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4322 if (!found)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4323 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4324 printf("**** KO KO KO\n");
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4325 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4326 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4327 }
3822
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3821
diff changeset
4328 };
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4329 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4330
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4331
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4332 TEST(Toto, DISABLED_DicomAssociation)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4333 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4334 DicomAssociationParameters params;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4335 params.SetLocalApplicationEntityTitle("ORTHANC");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4336 params.SetRemoteApplicationEntityTitle("PACS");
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4337 params.SetRemotePort(2001);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4338
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4339 #if 0
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4340 DicomAssociation assoc;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4341 assoc.ProposeGenericPresentationContext(UID_StorageCommitmentPushModelSOPClass);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4342 assoc.ProposeGenericPresentationContext(UID_VerificationSOPClass);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4343 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4344 DicomTransferSyntax_JPEGProcess1);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4345 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4346 DicomTransferSyntax_JPEGProcess2_4);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4347 assoc.ProposePresentationContext(UID_ComputedRadiographyImageStorage,
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4348 DicomTransferSyntax_JPEG2000);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4349
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4350 assoc.Open(params);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4351
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4352 int presID = ASC_findAcceptedPresentationContextID(&assoc.GetDcmtkAssociation(), UID_ComputedRadiographyImageStorage);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4353 printf(">> %d\n", presID);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4354
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4355 std::map<DicomTransferSyntax, uint8_t> pc;
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4356 printf(">> %d\n", assoc.LookupAcceptedPresentationContext(pc, UID_ComputedRadiographyImageStorage));
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4357
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4358 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4359 it = pc.begin(); it != pc.end(); ++it)
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4360 {
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4361 printf("[%s] => %d\n", GetTransferSyntaxUid(it->first), it->second);
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4362 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4363 #else
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4364 {
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4365 DicomControlUserConnection assoc(params);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4366
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4367 try
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4368 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4369 printf(">> %d\n", assoc.Echo());
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4370 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4371 catch (OrthancException&)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4372 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4373 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4374 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4375
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4376 params.SetRemoteApplicationEntityTitle("PACS");
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4377 params.SetRemotePort(2000);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4378
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4379 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4380 DicomControlUserConnection assoc(params);
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4381 printf(">> %d\n", assoc.Echo());
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4382 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4383
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4384 #endif
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4385 }
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4386
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4387
3823
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4388 TEST(Toto, DISABLED_Store)
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4389 {
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4390 DicomAssociationParameters params;
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4391 params.SetLocalApplicationEntityTitle("ORTHANC");
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4392 params.SetRemoteApplicationEntityTitle("PACS");
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4393 params.SetRemotePort(2000);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4394
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4395 DicomStoreUserConnection assoc(params);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4396 assoc.PrepareStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess1);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4397 assoc.PrepareStorageClass(UID_MRImageStorage, DicomTransferSyntax_JPEGProcess2_4);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4398 //assoc.PrepareStorageClass(UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4399
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4400 //assoc.SetUncompressedSyntaxesProposed(false);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4401 //assoc.SetCommonClassesProposed(false);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4402 assoc.Toto(UID_MRImageStorage, DicomTransferSyntax_JPEG2000);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4403 //assoc.Toto(UID_MRImageStorage, DicomTransferSyntax_LittleEndianExplicit);
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4404 }
897ca3103253 new class: DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3822
diff changeset
4405
3820
f89eac983c9b refactoring DicomUserConnection as DicomAssociation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3819
diff changeset
4406 #endif