annotate UnitTestsSources/Graveyard/TestStructureSet_BGO.cpp @ 1587:a1405ab3a91c

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 22 Oct 2020 16:28:41 +0200
parents OrthancStone/UnitTestsSources/Graveyard/TestStructureSet_BGO.cpp@ae17c8c8838f
children 8c5f9864545f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1541
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /*
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 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
3 (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
4 */
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 static std::string& GetTestJson()
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 static const char* resultRaw = NULL;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 static std::string result;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 if (resultRaw == NULL)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 std::stringstream sst;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 sst << k_rtStruct_json00
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 << k_rtStruct_json01
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 << k_rtStruct_json02
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 << k_rtStruct_json03
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 << k_rtStruct_json04
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 << k_rtStruct_json05
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 << k_rtStruct_json06
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 << k_rtStruct_json07
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 << k_rtStruct_json08;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 std::string wholeBody = sst.str();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 result.swap(wholeBody);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 resultRaw = result.c_str();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 return result;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 }
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
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 void Initialize(const char* orthancApiUrl, OrthancStone::ILoadersContext& loadersContext)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 Orthanc::WebServiceParameters p;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 OrthancStone::GenericLoadersContext& typedLoadersContext =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 dynamic_cast<OrthancStone::GenericLoadersContext&>(loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 // Default is http://localhost:8042
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 // Here's how you may change it
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 p.SetUrl(orthancApiUrl);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 p.SetCredentials("orthanc", "orthanc");
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 typedLoadersContext.SetOrthancParameters(p);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 typedLoadersContext.StartOracle();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 void Exitialize(OrthancStone::ILoadersContext& loadersContext)
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 OrthancStone::GenericLoadersContext& typedLoadersContext =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 dynamic_cast<OrthancStone::GenericLoadersContext&>(loadersContext);
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 typedLoadersContext.StopOracle();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
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
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 #if 0
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 class TestObserver : public ObserverBase<TestObserver>
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 public:
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 TestObserver() {};
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 virtual void Handle
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 };
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 #endif
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 }
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 TEST(StructureSet, DISABLED_StructureSetLoader_injection_feature_2020_05_10)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 namespace pt = boost::posix_time;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 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
75 Initialize("http://localhost:8042/", *loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 boost::shared_ptr<DicomStructureSetLoader> loader = DicomStructureSetLoader::Create(*loadersContext);
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 // replace with Orthanc ID of an uploaded RTSTRUCT instance!
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 loader->LoadInstanceFullVisibility("72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661");
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 bool bContinue(true);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 pt::ptime initialTime = pt::second_clock::local_time();
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 while (bContinue)
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 bContinue = !loader->AreStructuresReady();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
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 pt::ptime nowTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 pt::time_duration diff = nowTime - initialTime;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 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
95 std::cout << seconds << " seconds elapsed...\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 if (seconds > 30)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 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
99 //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
100 //bContinue = false;
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 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
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
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 class SliceProcessor :
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 public OrthancStone::OrthancSeriesVolumeProgressiveLoader::ISlicePostProcessor,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 public OrthancStone::DicomStructureSetLoader::IInstanceLookupHandler
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 public:
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 SliceProcessor(OrthancStone::DicomStructureSetLoader& structLoader) : structLoader_(structLoader)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
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 virtual void ProcessCTDicomSlice(const Orthanc::DicomMap& instance) ORTHANC_OVERRIDE
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 std::string sopInstanceUid;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 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
119 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 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
121 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 slicesDicom_[sopInstanceUid] = boost::shared_ptr<DicomMap>(instance.Clone());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
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 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
126 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 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
128 it != nonEmptyInstances.end();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 ++it)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 const std::string nonEmptyInstance = *it;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 if (slicesDicom_.find(nonEmptyInstance) == slicesDicom_.end())
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 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
135 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 boost::shared_ptr<Orthanc::DicomMap> instance = slicesDicom_[nonEmptyInstance];
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 structLoader_.AddReferencedSlice(*instance);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 }
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
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 OrthancStone::DicomStructureSetLoader& structLoader_;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 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
143 };
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 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
146 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 namespace pt = boost::posix_time;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 // Load the CT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 ctLoader->LoadSeries(seriesId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 // Wait for CT to be loaded
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 pt::ptime initialTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 bool bContinue(true);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 while (bContinue)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 bContinue = !ctLoader->IsVolumeImageReadyInHighQuality();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
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 pt::ptime nowTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 pt::time_duration diff = nowTime - initialTime;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 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
165 std::cout << seconds << " seconds elapsed...\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 if (seconds > 30)
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 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
169 GTEST_FATAL_FAILURE_(msg);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 bContinue = false;
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 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
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 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
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 /**
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 Will fill planes
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 void GetCTPlanes(std::vector<OrthancStone::CoordinateSystem3D>& planes,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 OrthancStone::VolumeProjection projection,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader)
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 planes.clear(); // inefficient : we don't care
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 const VolumeImageGeometry& geometry = ctLoader->GetImageGeometry();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 const unsigned int depth = geometry.GetProjectionDepth(projection);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 planes.resize(depth);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 for (unsigned int z = 0; z < depth; z++)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 planes[z] = geometry.GetProjectionSlice(projection, z);
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 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
199 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 namespace pt = boost::posix_time;
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 // Load RTSTRUCT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 structLoader->LoadInstanceFullVisibility(instanceId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 pt::ptime initialTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 // Wait for the loading process to complete
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 bool bContinue(true);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 while (bContinue)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 bContinue = !structLoader->AreStructuresReady();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
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 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 pt::ptime nowTime = pt::second_clock::local_time();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 pt::time_duration diff = nowTime - initialTime;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 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
219 std::cout << seconds << " seconds elapsed...\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 if (seconds > 30)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 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
223 GTEST_FATAL_FAILURE_(msg);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 bContinue = false;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
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 }
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
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 TEST(StructureSet, DISABLED_Integration_Compound_CT_Struct_Loading)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 const double TOLERANCE = 0.0000001;
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 // create loaders context
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 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
237 Initialize("http://localhost:8042/", *loadersContext);
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 const char* ctSeriesId = "a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 const char* rtStructInstanceId = "54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 // 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
243
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 boost::shared_ptr<OrthancStone::DicomStructureSetLoader> normalStructLoader;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 boost::shared_ptr<OrthancStone::DicomStructureSetLoader> optimizedStructLoader;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 // Create the CT volume
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 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
250
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 // Create CT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 OrthancStone::OrthancSeriesVolumeProgressiveLoader::Create(*loadersContext, volume);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 // Create struct loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 normalStructLoader = OrthancStone::DicomStructureSetLoader::Create(*loadersContext);
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 // Load the CT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 LoadCtSeriesBlocking(ctLoader, ctSeriesId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 const OrthancStone::VolumeImageGeometry& imageGeometry = ctLoader->GetImageGeometry();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 unsigned int width = imageGeometry.GetWidth();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 EXPECT_EQ(512u, width);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 unsigned int height = imageGeometry.GetHeight();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 EXPECT_EQ(512u, height);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 unsigned int depth = imageGeometry.GetDepth();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 EXPECT_EQ(109u, depth);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 // Load the RTStruct
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 LoadRtStructBlocking(normalStructLoader, rtStructInstanceId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 std::vector<OrthancStone::CoordinateSystem3D> axialPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 std::vector<OrthancStone::CoordinateSystem3D> coronalPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 std::vector<OrthancStone::CoordinateSystem3D> sagittalPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
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 the CT volume
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 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
280
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 // Create CT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader =
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 OrthancStone::OrthancSeriesVolumeProgressiveLoader::Create(*loadersContext, volume);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 // Create struct loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 optimizedStructLoader = OrthancStone::DicomStructureSetLoader::Create(*loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 // create the slice processor / instance lookup
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 boost::shared_ptr<SliceProcessor> sliceProcessor(new SliceProcessor(*optimizedStructLoader));
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 // Inject it into CT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 ctLoader->SetDicomSlicePostProcessor(sliceProcessor);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 // Inject it into RTSTRUCT loader
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 optimizedStructLoader->SetInstanceLookupHandler(sliceProcessor);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 // Load the CT
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 LoadCtSeriesBlocking(ctLoader, ctSeriesId);
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 // 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
301 EXPECT_EQ(109u, sliceProcessor->slicesDicom_.size());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 // Load the RTStruct
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 LoadRtStructBlocking(optimizedStructLoader, rtStructInstanceId);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 GetCTPlanes(axialPlanes, VolumeProjection_Axial, ctLoader);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 GetCTPlanes(coronalPlanes, VolumeProjection_Coronal, ctLoader);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 GetCTPlanes(sagittalPlanes, VolumeProjection_Sagittal, ctLoader);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
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 // DO NOT DELETE THOSE!
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 OrthancStone::DicomStructureSet* normalContent = normalStructLoader->GetContent();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 OrthancStone::DicomStructureSet* optimizedContent = optimizedStructLoader->GetContent();
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 EXPECT_EQ(normalContent->GetStructuresCount(), optimizedContent->GetStructuresCount());
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 /*void GetCTPlanes(std::vector<OrthancStone::CoordinateSystem3D>& planes,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 OrthancStone::VolumeProjection projection,
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader)*/
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 std::vector<OrthancStone::CoordinateSystem3D> allPlanes;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 // 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
325 for (size_t i = 0; i < axialPlanes.size(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 allPlanes.push_back(axialPlanes[i]);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 for (size_t i = 0; i < coronalPlanes.size(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 allPlanes.push_back(coronalPlanes[i]);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 for (size_t i = 0; i < sagittalPlanes.size(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 allPlanes.push_back(sagittalPlanes[i]);
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 for (size_t i = 0; i < normalContent->GetStructuresCount(); ++i)
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 std::cout << "Testing structure (" << i << "/" << normalContent->GetStructuresCount() << ")\n";
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 Vector structureCenter1 = normalContent->GetStructureCenter(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 const std::string& structureName1 = normalContent->GetStructureName(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 const std::string& structureInterpretation1 = normalContent->GetStructureInterpretation(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 Color structureColor1 = normalContent->GetStructureColor(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 Vector structureCenter2 = optimizedContent->GetStructureCenter(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 const std::string& structureName2 = optimizedContent->GetStructureName(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 const std::string& structureInterpretation2 = optimizedContent->GetStructureInterpretation(i);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 Color structureColor2 = optimizedContent->GetStructureColor(i);
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 EXPECT_NEAR(structureCenter1[0], structureCenter2[0], TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 EXPECT_NEAR(structureCenter1[1], structureCenter2[1], TOLERANCE);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 EXPECT_NEAR(structureCenter1[2], structureCenter2[2], TOLERANCE);
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 EXPECT_EQ(structureName1, structureName2);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 EXPECT_EQ(structureInterpretation1, structureInterpretation2);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 EXPECT_EQ(structureColor1.GetRed(), structureColor2.GetRed());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 EXPECT_EQ(structureColor1.GetGreen(), structureColor2.GetGreen());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 EXPECT_EQ(structureColor1.GetBlue(), structureColor2.GetBlue());
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 // "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
358 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
359 {
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 const OrthancStone::CoordinateSystem3D& plane = allPlanes[j];
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 std::vector< std::pair<Point2D, Point2D> > segments1;
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 std::vector< std::pair<Point2D, Point2D> > segments2;
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 bool ok1 = normalContent->ProjectStructure(segments1, i, plane);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 bool ok2 = optimizedContent->ProjectStructure(segments2, i, plane);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 // checks here
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 EXPECT_EQ(ok1, ok2);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 EXPECT_EQ(segments1.size(), segments2.size());
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 for (size_t k = 0; k < segments1.size(); ++k)
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_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
375 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
376 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
377 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
378 }
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 }
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 Exitialize(*loadersContext);
ae17c8c8838f standalone compilation of unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }