Mercurial > hg > orthanc-stone
comparison UnitTestsSources/TestStructureSet.cpp @ 1446:ab00f36718ed loader-injection-feature
Test improvements for optimized loader
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 26 May 2020 17:38:54 +0200 |
parents | 04d0c25819c3 |
children | f3f4cd58fde4 |
comparison
equal
deleted
inserted
replaced
1445:04d0c25819c3 | 1446:ab00f36718ed |
---|---|
5560 } | 5560 } |
5561 } | 5561 } |
5562 } | 5562 } |
5563 | 5563 |
5564 | 5564 |
5565 /** | |
5566 Will fill planes | |
5567 */ | |
5568 void GetCTPlanes(std::vector<OrthancStone::CoordinateSystem3D>& planes, | |
5569 OrthancStone::VolumeProjection projection, | |
5570 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader) | |
5571 { | |
5572 planes.clear(); // inefficient : we don't care | |
5573 | |
5574 const VolumeImageGeometry& geometry = ctLoader->GetImageGeometry(); | |
5575 const unsigned int depth = geometry.GetProjectionDepth(projection); | |
5576 | |
5577 planes.resize(depth); | |
5578 | |
5579 for (unsigned int z = 0; z < depth; z++) | |
5580 { | |
5581 planes[z] = geometry.GetProjectionSlice(projection, z); | |
5582 } | |
5583 } | |
5584 | |
5565 void LoadRtStructBlocking(boost::shared_ptr<OrthancStone::DicomStructureSetLoader> structLoader, std::string instanceId) | 5585 void LoadRtStructBlocking(boost::shared_ptr<OrthancStone::DicomStructureSetLoader> structLoader, std::string instanceId) |
5566 { | 5586 { |
5567 namespace pt = boost::posix_time; | 5587 namespace pt = boost::posix_time; |
5568 | 5588 |
5569 // Load RTSTRUCT | 5589 // Load RTSTRUCT |
5635 | 5655 |
5636 // Load the RTStruct | 5656 // Load the RTStruct |
5637 LoadRtStructBlocking(normalStructLoader, rtStructInstanceId); | 5657 LoadRtStructBlocking(normalStructLoader, rtStructInstanceId); |
5638 } | 5658 } |
5639 | 5659 |
5660 std::vector<OrthancStone::CoordinateSystem3D> axialPlanes; | |
5661 std::vector<OrthancStone::CoordinateSystem3D> coronalPlanes; | |
5662 std::vector<OrthancStone::CoordinateSystem3D> sagittalPlanes; | |
5663 | |
5640 { | 5664 { |
5641 // Create the CT volume | 5665 // Create the CT volume |
5642 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume = boost::make_shared<OrthancStone::DicomVolumeImage>(); | 5666 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume = boost::make_shared<OrthancStone::DicomVolumeImage>(); |
5643 | 5667 |
5644 // Create CT loader | 5668 // Create CT loader |
5663 // now, the slices are collected. let's do some checks | 5687 // now, the slices are collected. let's do some checks |
5664 EXPECT_EQ(109u, sliceProcessor->slicesDicom_.size()); | 5688 EXPECT_EQ(109u, sliceProcessor->slicesDicom_.size()); |
5665 | 5689 |
5666 // Load the RTStruct | 5690 // Load the RTStruct |
5667 LoadRtStructBlocking(optimizedStructLoader, rtStructInstanceId); | 5691 LoadRtStructBlocking(optimizedStructLoader, rtStructInstanceId); |
5692 | |
5693 GetCTPlanes(axialPlanes, VolumeProjection_Axial, ctLoader); | |
5694 GetCTPlanes(coronalPlanes, VolumeProjection_Coronal, ctLoader); | |
5695 GetCTPlanes(sagittalPlanes, VolumeProjection_Sagittal, ctLoader); | |
5668 } | 5696 } |
5669 | 5697 |
5670 // DO NOT DELETE THOSE! | 5698 // DO NOT DELETE THOSE! |
5671 OrthancStone::DicomStructureSet* normalContent = normalStructLoader->GetContent(); | 5699 OrthancStone::DicomStructureSet* normalContent = normalStructLoader->GetContent(); |
5672 OrthancStone::DicomStructureSet* optimizedContent = optimizedStructLoader->GetContent(); | 5700 OrthancStone::DicomStructureSet* optimizedContent = optimizedStructLoader->GetContent(); |
5673 | 5701 |
5674 EXPECT_EQ(normalContent->GetStructuresCount(), optimizedContent->GetStructuresCount()); | 5702 EXPECT_EQ(normalContent->GetStructuresCount(), optimizedContent->GetStructuresCount()); |
5703 | |
5704 /*void GetCTPlanes(std::vector<OrthancStone::CoordinateSystem3D>& planes, | |
5705 OrthancStone::VolumeProjection projection, | |
5706 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader)*/ | |
5707 | |
5708 | |
5709 std::vector<OrthancStone::CoordinateSystem3D> allPlanes; | |
5710 for (const auto& plane : axialPlanes) | |
5711 allPlanes.push_back(plane); | |
5712 for (const auto& plane : coronalPlanes) | |
5713 allPlanes.push_back(plane); | |
5714 for (const auto& plane : sagittalPlanes) | |
5715 allPlanes.push_back(plane); | |
5675 | 5716 |
5676 for (size_t i = 0; i < normalContent->GetStructuresCount(); ++i) | 5717 for (size_t i = 0; i < normalContent->GetStructuresCount(); ++i) |
5677 { | 5718 { |
5678 Vector structureCenter1 = normalContent->GetStructureCenter(i); | 5719 Vector structureCenter1 = normalContent->GetStructureCenter(i); |
5679 const std::string& structureName1 = normalContent->GetStructureName(i); | 5720 const std::string& structureName1 = normalContent->GetStructureName(i); |
5692 EXPECT_EQ(structureName1, structureName2); | 5733 EXPECT_EQ(structureName1, structureName2); |
5693 EXPECT_EQ(structureInterpretation1, structureInterpretation2); | 5734 EXPECT_EQ(structureInterpretation1, structureInterpretation2); |
5694 EXPECT_EQ(structureColor1.GetRed(), structureColor2.GetRed()); | 5735 EXPECT_EQ(structureColor1.GetRed(), structureColor2.GetRed()); |
5695 EXPECT_EQ(structureColor1.GetGreen(), structureColor2.GetGreen()); | 5736 EXPECT_EQ(structureColor1.GetGreen(), structureColor2.GetGreen()); |
5696 EXPECT_EQ(structureColor1.GetBlue(), structureColor2.GetBlue()); | 5737 EXPECT_EQ(structureColor1.GetBlue(), structureColor2.GetBlue()); |
5738 | |
5739 for (const auto& plane : allPlanes) | |
5740 { | |
5741 std::vector< std::pair<Point2D, Point2D> > segments1; | |
5742 std::vector< std::pair<Point2D, Point2D> > segments2; | |
5743 | |
5744 bool ok1 = normalContent->ProjectStructure(segments1, i, plane); | |
5745 bool ok2 = optimizedContent->ProjectStructure(segments2, i, plane); | |
5746 | |
5747 // checks here | |
5748 EXPECT_EQ(ok1, ok2); | |
5749 EXPECT_EQ(segments1.size(), segments2.size()); | |
5750 } | |
5697 } | 5751 } |
5752 | |
5753 Exitialize(loadersContext); | |
5698 } | 5754 } |