annotate OrthancStone/UnitTestsSources/Graveyard/TestStructureSet_BGO.cpp @ 1986:e29783c92419

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 31 Oct 2022 15:20:18 +0100
parents a2955abe4c2e
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
1 /**
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
2 * Stone of Orthanc
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
4 * Department, University Hospital of Liege, Belgium
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
7 *
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
8 * This program is free software: you can redistribute it and/or
1877
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
11 * the License, or (at your option) any later version.
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
12 *
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
13 * This program is distributed in the hope that it will be useful, but
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
1877
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
16 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1589
diff changeset
17 *
1877
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
19 * License along with this program. If not, see
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
20 * <http://www.gnu.org/licenses/>.
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
21 **/
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
22
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
23
1541
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 /*
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 these tests are single-threaded... no worries for old buggy compilers
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 (I'm talking to YOU, cl.exe v100! And to your ancestors!)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 */
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 static std::string& GetTestJson()
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 static const char* resultRaw = NULL;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 static std::string result;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 if (resultRaw == NULL)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 std::stringstream sst;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 sst << k_rtStruct_json00
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 << k_rtStruct_json01
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 << k_rtStruct_json02
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 << k_rtStruct_json03
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 << k_rtStruct_json04
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 << k_rtStruct_json05
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 << k_rtStruct_json06
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 << k_rtStruct_json07
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 << k_rtStruct_json08;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 std::string wholeBody = sst.str();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 result.swap(wholeBody);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 resultRaw = result.c_str();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 return result;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 namespace
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 void Initialize(const char* orthancApiUrl, OrthancStone::ILoadersContext& loadersContext)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 Orthanc::WebServiceParameters p;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 OrthancStone::GenericLoadersContext& typedLoadersContext =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 dynamic_cast<OrthancStone::GenericLoadersContext&>(loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 // Default is http://localhost:8042
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 // Here's how you may change it
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 p.SetUrl(orthancApiUrl);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 p.SetCredentials("orthanc", "orthanc");
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 typedLoadersContext.SetOrthancParameters(p);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 typedLoadersContext.StartOracle();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 void Exitialize(OrthancStone::ILoadersContext& loadersContext)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 OrthancStone::GenericLoadersContext& typedLoadersContext =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 dynamic_cast<OrthancStone::GenericLoadersContext&>(loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 typedLoadersContext.StopOracle();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 #if 0
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 class TestObserver : public ObserverBase<TestObserver>
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 public:
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 TestObserver() {};
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 virtual void Handle
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 };
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 #endif
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 TEST(StructureSet, DISABLED_StructureSetLoader_injection_feature_2020_05_10)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 namespace pt = boost::posix_time;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 std::unique_ptr<OrthancStone::ILoadersContext> loadersContext(new OrthancStone::GenericLoadersContext(1,4,1));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 Initialize("http://localhost:8042/", *loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 boost::shared_ptr<DicomStructureSetLoader> loader = DicomStructureSetLoader::Create(*loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 // replace with Orthanc ID of an uploaded RTSTRUCT instance!
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 loader->LoadInstanceFullVisibility("72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661");
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 bool bContinue(true);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 pt::ptime initialTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 while (bContinue)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 bContinue = !loader->AreStructuresReady();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 pt::ptime nowTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 pt::time_duration diff = nowTime - initialTime;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 double seconds = static_cast<double>(diff.total_milliseconds()) * 0.001;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 std::cout << seconds << " seconds elapsed...\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 if (seconds > 30)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 std::cout << "More than 30 seconds elapsed... Aborting test :(\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 //GTEST_FATAL_FAILURE_("More than 30 seconds elapsed... Aborting test :(");
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 //bContinue = false;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 class SliceProcessor :
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 public OrthancStone::OrthancSeriesVolumeProgressiveLoader::ISlicePostProcessor,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 public OrthancStone::DicomStructureSetLoader::IInstanceLookupHandler
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 public:
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 SliceProcessor(OrthancStone::DicomStructureSetLoader& structLoader) : structLoader_(structLoader)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 virtual void ProcessCTDicomSlice(const Orthanc::DicomMap& instance) ORTHANC_OVERRIDE
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 std::string sopInstanceUid;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 if (!instance.LookupStringValue(sopInstanceUid, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, "Missing SOPInstanceUID in a DICOM instance");
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 slicesDicom_[sopInstanceUid] = boost::shared_ptr<DicomMap>(instance.Clone());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 virtual void RetrieveReferencedSlices(const std::set<std::string>& nonEmptyInstances) ORTHANC_OVERRIDE
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 for (std::set<std::string>::const_iterator it = nonEmptyInstances.begin();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 it != nonEmptyInstances.end();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 ++it)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 const std::string nonEmptyInstance = *it;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 if (slicesDicom_.find(nonEmptyInstance) == slicesDicom_.end())
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, "Referenced SOPInstanceUID not found in CT");
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 boost::shared_ptr<Orthanc::DicomMap> instance = slicesDicom_[nonEmptyInstance];
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 structLoader_.AddReferencedSlice(*instance);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 OrthancStone::DicomStructureSetLoader& structLoader_;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 std::map<std::string, boost::shared_ptr<Orthanc::DicomMap> > slicesDicom_;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 };
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 void LoadCtSeriesBlocking(boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader, std::string seriesId)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 namespace pt = boost::posix_time;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 // Load the CT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 ctLoader->LoadSeries(seriesId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 // Wait for CT to be loaded
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 pt::ptime initialTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 bool bContinue(true);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 while (bContinue)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 bContinue = !ctLoader->IsVolumeImageReadyInHighQuality();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 pt::ptime nowTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 pt::time_duration diff = nowTime - initialTime;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 double seconds = static_cast<double>(diff.total_milliseconds()) * 0.001;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 std::cout << seconds << " seconds elapsed...\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 if (seconds > 30)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 const char* msg = "More than 30 seconds elapsed when waiting for CT... Aborting test :(\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 GTEST_FATAL_FAILURE_(msg);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 bContinue = false;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 /**
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 Will fill planes
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 */
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 void GetCTPlanes(std::vector<OrthancStone::CoordinateSystem3D>& planes,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 OrthancStone::VolumeProjection projection,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 planes.clear(); // inefficient : we don't care
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 const VolumeImageGeometry& geometry = ctLoader->GetImageGeometry();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 const unsigned int depth = geometry.GetProjectionDepth(projection);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 planes.resize(depth);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 for (unsigned int z = 0; z < depth; z++)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 planes[z] = geometry.GetProjectionSlice(projection, z);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 void LoadRtStructBlocking(boost::shared_ptr<OrthancStone::DicomStructureSetLoader> structLoader, std::string instanceId)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 namespace pt = boost::posix_time;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 // Load RTSTRUCT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 structLoader->LoadInstanceFullVisibility(instanceId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 pt::ptime initialTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 // Wait for the loading process to complete
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 bool bContinue(true);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 while (bContinue)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 bContinue = !structLoader->AreStructuresReady();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 pt::ptime nowTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 pt::time_duration diff = nowTime - initialTime;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 double seconds = static_cast<double>(diff.total_milliseconds()) * 0.001;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 std::cout << seconds << " seconds elapsed...\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 if (seconds > 30)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 const char* msg = "More than 30 seconds elapsed when waiting for RTSTRUCT... Aborting test :(\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 GTEST_FATAL_FAILURE_(msg);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 bContinue = false;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 TEST(StructureSet, DISABLED_Integration_Compound_CT_Struct_Loading)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 const double TOLERANCE = 0.0000001;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 // create loaders context
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 std::unique_ptr<OrthancStone::ILoadersContext> loadersContext(new OrthancStone::GenericLoadersContext(1,4,1));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 Initialize("http://localhost:8042/", *loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 const char* ctSeriesId = "a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 const char* rtStructInstanceId = "54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 // we'll compare normal loading and optimized loading with SliceProcessor to store the dicom
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 boost::shared_ptr<OrthancStone::DicomStructureSetLoader> normalStructLoader;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 boost::shared_ptr<OrthancStone::DicomStructureSetLoader> optimizedStructLoader;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 // Create the CT volume
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume = boost::make_shared<OrthancStone::DicomVolumeImage>();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 // Create CT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 OrthancStone::OrthancSeriesVolumeProgressiveLoader::Create(*loadersContext, volume);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 // Create struct loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 normalStructLoader = OrthancStone::DicomStructureSetLoader::Create(*loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 // Load the CT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 LoadCtSeriesBlocking(ctLoader, ctSeriesId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 const OrthancStone::VolumeImageGeometry& imageGeometry = ctLoader->GetImageGeometry();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 unsigned int width = imageGeometry.GetWidth();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 EXPECT_EQ(512u, width);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 unsigned int height = imageGeometry.GetHeight();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 EXPECT_EQ(512u, height);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 unsigned int depth = imageGeometry.GetDepth();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 EXPECT_EQ(109u, depth);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 // Load the RTStruct
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 LoadRtStructBlocking(normalStructLoader, rtStructInstanceId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 std::vector<OrthancStone::CoordinateSystem3D> axialPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 std::vector<OrthancStone::CoordinateSystem3D> coronalPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 std::vector<OrthancStone::CoordinateSystem3D> sagittalPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 // Create the CT volume
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume = boost::make_shared<OrthancStone::DicomVolumeImage>();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 // Create CT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 OrthancStone::OrthancSeriesVolumeProgressiveLoader::Create(*loadersContext, volume);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 // Create struct loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 optimizedStructLoader = OrthancStone::DicomStructureSetLoader::Create(*loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 // create the slice processor / instance lookup
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 boost::shared_ptr<SliceProcessor> sliceProcessor(new SliceProcessor(*optimizedStructLoader));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 // Inject it into CT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 ctLoader->SetDicomSlicePostProcessor(sliceProcessor);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 // Inject it into RTSTRUCT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 optimizedStructLoader->SetInstanceLookupHandler(sliceProcessor);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 // Load the CT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 LoadCtSeriesBlocking(ctLoader, ctSeriesId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 // now, the slices are collected. let's do some checks
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 EXPECT_EQ(109u, sliceProcessor->slicesDicom_.size());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 // Load the RTStruct
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 LoadRtStructBlocking(optimizedStructLoader, rtStructInstanceId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 GetCTPlanes(axialPlanes, VolumeProjection_Axial, ctLoader);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 GetCTPlanes(coronalPlanes, VolumeProjection_Coronal, ctLoader);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 GetCTPlanes(sagittalPlanes, VolumeProjection_Sagittal, ctLoader);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 // DO NOT DELETE THOSE!
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 OrthancStone::DicomStructureSet* normalContent = normalStructLoader->GetContent();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 OrthancStone::DicomStructureSet* optimizedContent = optimizedStructLoader->GetContent();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 EXPECT_EQ(normalContent->GetStructuresCount(), optimizedContent->GetStructuresCount());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 /*void GetCTPlanes(std::vector<OrthancStone::CoordinateSystem3D>& planes,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 OrthancStone::VolumeProjection projection,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader)*/
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 std::vector<OrthancStone::CoordinateSystem3D> allPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 // let's gather all the possible cutting planes in a single struct
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 for (size_t i = 0; i < axialPlanes.size(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 allPlanes.push_back(axialPlanes[i]);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 for (size_t i = 0; i < coronalPlanes.size(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 allPlanes.push_back(coronalPlanes[i]);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 for (size_t i = 0; i < sagittalPlanes.size(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 allPlanes.push_back(sagittalPlanes[i]);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 for (size_t i = 0; i < normalContent->GetStructuresCount(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 std::cout << "Testing structure (" << i << "/" << normalContent->GetStructuresCount() << ")\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 Vector structureCenter1 = normalContent->GetStructureCenter(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 const std::string& structureName1 = normalContent->GetStructureName(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 const std::string& structureInterpretation1 = normalContent->GetStructureInterpretation(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 Color structureColor1 = normalContent->GetStructureColor(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 Vector structureCenter2 = optimizedContent->GetStructureCenter(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 const std::string& structureName2 = optimizedContent->GetStructureName(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 const std::string& structureInterpretation2 = optimizedContent->GetStructureInterpretation(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 Color structureColor2 = optimizedContent->GetStructureColor(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 EXPECT_NEAR(structureCenter1[0], structureCenter2[0], TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 EXPECT_NEAR(structureCenter1[1], structureCenter2[1], TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 EXPECT_NEAR(structureCenter1[2], structureCenter2[2], TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 EXPECT_EQ(structureName1, structureName2);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 EXPECT_EQ(structureInterpretation1, structureInterpretation2);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 EXPECT_EQ(structureColor1.GetRed(), structureColor2.GetRed());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 EXPECT_EQ(structureColor1.GetGreen(), structureColor2.GetGreen());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 EXPECT_EQ(structureColor1.GetBlue(), structureColor2.GetBlue());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 // "random" walk through the planes. Processing them all takes too long (~ 1 min)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 for (size_t j = 0; j < allPlanes.size(); j += 37)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 const OrthancStone::CoordinateSystem3D& plane = allPlanes[j];
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 std::vector< std::pair<Point2D, Point2D> > segments1;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 std::vector< std::pair<Point2D, Point2D> > segments2;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 bool ok1 = normalContent->ProjectStructure(segments1, i, plane);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 bool ok2 = optimizedContent->ProjectStructure(segments2, i, plane);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 // checks here
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 EXPECT_EQ(ok1, ok2);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 EXPECT_EQ(segments1.size(), segments2.size());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 for (size_t k = 0; k < segments1.size(); ++k)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 EXPECT_NEAR(segments1[k].first.x, segments2[k].first.x, TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 EXPECT_NEAR(segments1[k].first.y, segments2[k].first.y, TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 EXPECT_NEAR(segments1[k].second.x, segments2[k].second.x, TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 EXPECT_NEAR(segments1[k].second.y, segments2[k].second.y, TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 Exitialize(*loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 }