# HG changeset patch # User Benjamin Golinvaux # Date 1590507534 -7200 # Node ID ab00f36718ed5c40a9dd9744cba5dc26d6f12f46 # Parent 04d0c25819c34dd4458b8c047fc44d25375122f9 Test improvements for optimized loader diff -r 04d0c25819c3 -r ab00f36718ed UnitTestsSources/TestStructureSet.cpp --- a/UnitTestsSources/TestStructureSet.cpp Tue May 26 17:12:34 2020 +0200 +++ b/UnitTestsSources/TestStructureSet.cpp Tue May 26 17:38:54 2020 +0200 @@ -5562,6 +5562,26 @@ } +/** +Will fill planes +*/ +void GetCTPlanes(std::vector& planes, + OrthancStone::VolumeProjection projection, + boost::shared_ptr ctLoader) +{ + planes.clear(); // inefficient : we don't care + + const VolumeImageGeometry& geometry = ctLoader->GetImageGeometry(); + const unsigned int depth = geometry.GetProjectionDepth(projection); + + planes.resize(depth); + + for (unsigned int z = 0; z < depth; z++) + { + planes[z] = geometry.GetProjectionSlice(projection, z); + } +} + void LoadRtStructBlocking(boost::shared_ptr structLoader, std::string instanceId) { namespace pt = boost::posix_time; @@ -5637,6 +5657,10 @@ LoadRtStructBlocking(normalStructLoader, rtStructInstanceId); } + std::vector axialPlanes; + std::vector coronalPlanes; + std::vector sagittalPlanes; + { // Create the CT volume boost::shared_ptr volume = boost::make_shared(); @@ -5665,6 +5689,10 @@ // Load the RTStruct LoadRtStructBlocking(optimizedStructLoader, rtStructInstanceId); + + GetCTPlanes(axialPlanes, VolumeProjection_Axial, ctLoader); + GetCTPlanes(coronalPlanes, VolumeProjection_Coronal, ctLoader); + GetCTPlanes(sagittalPlanes, VolumeProjection_Sagittal, ctLoader); } // DO NOT DELETE THOSE! @@ -5673,6 +5701,19 @@ EXPECT_EQ(normalContent->GetStructuresCount(), optimizedContent->GetStructuresCount()); + /*void GetCTPlanes(std::vector& planes, + OrthancStone::VolumeProjection projection, + boost::shared_ptr ctLoader)*/ + + + std::vector allPlanes; + for (const auto& plane : axialPlanes) + allPlanes.push_back(plane); + for (const auto& plane : coronalPlanes) + allPlanes.push_back(plane); + for (const auto& plane : sagittalPlanes) + allPlanes.push_back(plane); + for (size_t i = 0; i < normalContent->GetStructuresCount(); ++i) { Vector structureCenter1 = normalContent->GetStructureCenter(i); @@ -5694,5 +5735,20 @@ EXPECT_EQ(structureColor1.GetRed(), structureColor2.GetRed()); EXPECT_EQ(structureColor1.GetGreen(), structureColor2.GetGreen()); EXPECT_EQ(structureColor1.GetBlue(), structureColor2.GetBlue()); + + for (const auto& plane : allPlanes) + { + std::vector< std::pair > segments1; + std::vector< std::pair > segments2; + + bool ok1 = normalContent->ProjectStructure(segments1, i, plane); + bool ok2 = optimizedContent->ProjectStructure(segments2, i, plane); + + // checks here + EXPECT_EQ(ok1, ok2); + EXPECT_EQ(segments1.size(), segments2.size()); + } } + + Exitialize(loadersContext); }