changeset 1006:4f28d9459e31 toa2019092001

Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 20 Sep 2019 12:13:10 +0200
parents 7e861cfd142d
children 1c82598d4e68
files Framework/Deprecated/Layers/DicomStructureSetSlicer.cpp Framework/Loaders/DicomStructureSetLoader.cpp Framework/Toolbox/DicomStructureSet.cpp Framework/Toolbox/DicomStructureSet.h Framework/Toolbox/DicomStructureSet2.cpp UnitTestsSources/TestStructureSet.cpp
diffstat 6 files changed, 49 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Deprecated/Layers/DicomStructureSetSlicer.cpp	Fri Sep 20 12:01:20 2019 +0200
+++ b/Framework/Deprecated/Layers/DicomStructureSetSlicer.cpp	Fri Sep 20 12:13:10 2019 +0200
@@ -29,12 +29,12 @@
     class Structure
     {
     private:
-      bool                                                         visible_;
-      uint8_t                                                      red_;
-      uint8_t                                                      green_;
-      uint8_t                                                      blue_;
-      std::string                                                  name_;
-      std::vector< std::vector<OrthancStone::DicomStructureSet::PolygonPoint2D> >  polygons_;
+      bool                                                                   visible_;
+      uint8_t                                                                red_;
+      uint8_t                                                                green_;
+      uint8_t                                                                blue_;
+      std::string                                                            name_;
+      std::vector< std::pair<OrthancStone::Point2D, OrthancStone::Point2D> > segments_;
 
     public:
       Structure(OrthancStone::DicomStructureSet& structureSet,
@@ -43,7 +43,7 @@
         name_(structureSet.GetStructureName(index))
       {
         structureSet.GetStructureColor(red_, green_, blue_, index);
-        visible_ = structureSet.ProjectStructure(polygons_, index, plane);
+        visible_ = structureSet.ProjectStructure(segments_, index, plane);
       }
 
       void Render(OrthancStone::CairoContext& context)
@@ -54,16 +54,10 @@
         
           context.SetSourceColor(red_, green_, blue_);
 
-          for (size_t i = 0; i < polygons_.size(); i++)
+          for (size_t i = 0; i < segments_.size(); i++)
           {
-            cairo_move_to(cr, polygons_[i][0].first, polygons_[i][0].second);
-
-            for (size_t j = 1; j < polygons_[i].size(); j++)
-            {
-              cairo_line_to(cr, polygons_[i][j].first, polygons_[i][j].second);
-            }
-
-            cairo_line_to(cr, polygons_[i][0].first, polygons_[i][0].second);
+            cairo_move_to(cr, segments_[i].first.x, segments_[i].first.y);
+            cairo_move_to(cr, segments_[i].second.x, segments_[i].second.y);
             cairo_stroke(cr);
           }
         }
--- a/Framework/Loaders/DicomStructureSetLoader.cpp	Fri Sep 20 12:01:20 2019 +0200
+++ b/Framework/Loaders/DicomStructureSetLoader.cpp	Fri Sep 20 12:13:10 2019 +0200
@@ -243,7 +243,7 @@
       {
         const Color& color = content_.GetStructureColor(i);
 
-#ifdef USE_OLD_SJO_CUT_CODE 
+#ifdef USE_BOOST_UNION_FOR_POLYGONS 
         std::vector< std::vector<Point2D> > polygons;
           
         if (content_.ProjectStructure(polygons, i, cuttingPlane))
--- a/Framework/Toolbox/DicomStructureSet.cpp	Fri Sep 20 12:01:20 2019 +0200
+++ b/Framework/Toolbox/DicomStructureSet.cpp	Fri Sep 20 12:13:10 2019 +0200
@@ -81,7 +81,7 @@
   }
 }
 
-#ifdef USE_OLD_SJO_CUT_CODE
+#ifdef USE_BOOST_UNION_FOR_POLYGONS
 
 static BoostPolygon CreateRectangle(float x1, float y1,
                                     float x2, float y2)
@@ -803,7 +803,7 @@
     }
   }
 
-#ifdef USE_OLD_SJO_CUT_CODE 
+#ifdef USE_BOOST_UNION_FOR_POLYGONS 
   bool DicomStructureSet::ProjectStructure(std::vector< std::vector<Point2D> >& polygons,
                                            const Structure& structure,
                                            const CoordinateSystem3D& slice) const
@@ -813,7 +813,7 @@
     const CoordinateSystem3D& slice) const
 #endif
   {
-#ifdef USE_OLD_SJO_CUT_CODE 
+#ifdef USE_BOOST_UNION_FOR_POLYGONS 
     polygons.clear();
 #else
     segments.clear();
@@ -831,7 +831,7 @@
       {
         if (polygon->IsOnSlice(slice))
         {
-#ifdef USE_OLD_SJO_CUT_CODE 
+#ifdef USE_BOOST_UNION_FOR_POLYGONS 
           polygons.push_back(std::vector<Point2D>());
           
           for (Points::const_iterator p = polygon->GetPoints().begin();
@@ -882,7 +882,7 @@
 #if 1
       // Sagittal or coronal projection
 
-#ifdef USE_OLD_SJO_CUT_CODE 
+#ifdef USE_BOOST_UNION_FOR_POLYGONS 
       std::vector<BoostPolygon> projected;
 #else
       // this will contain the intersection of the polygon slab with
@@ -909,7 +909,7 @@
             static_cast<float>(y2)),curZ));
         }
       }
-#ifndef USE_OLD_SJO_CUT_CODE
+#ifndef USE_BOOST_UNION_FOR_POLYGONS
       // projected contains a set of rectangles specified by two opposite
       // corners (x1,y1,x2,y2)
       // we need to merge them 
--- a/Framework/Toolbox/DicomStructureSet.h	Fri Sep 20 12:01:20 2019 +0200
+++ b/Framework/Toolbox/DicomStructureSet.h	Fri Sep 20 12:13:10 2019 +0200
@@ -26,7 +26,7 @@
 #include "Extent2D.h"
 #include "../Scene2D/Color.h"
 
-//#define USE_OLD_SJO_CUT_CODE 1
+//#define USE_BOOST_UNION_FOR_POLYGONS 1
 
 #include <Plugins/Samples/Common/FullOrthancDataset.h>
 
@@ -141,7 +141,7 @@
 
     Structure& GetStructure(size_t index);
   
-#ifdef USE_OLD_SJO_CUT_CODE 
+#ifdef USE_BOOST_UNION_FOR_POLYGONS 
     bool ProjectStructure(std::vector< std::vector<Point2D> >& polygons,
                           const Structure& structure,
                           const CoordinateSystem3D& slice) const;
@@ -185,7 +185,7 @@
 
     Vector GetNormal() const;
 
-#ifdef USE_OLD_SJO_CUT_CODE 
+#ifdef USE_BOOST_UNION_FOR_POLYGONS 
     bool ProjectStructure(std::vector< std::vector<Point2D> >& polygons,
       size_t index,
       const CoordinateSystem3D& slice) const
--- a/Framework/Toolbox/DicomStructureSet2.cpp	Fri Sep 20 12:01:20 2019 +0200
+++ b/Framework/Toolbox/DicomStructureSet2.cpp	Fri Sep 20 12:13:10 2019 +0200
@@ -92,6 +92,17 @@
   }
 
 
+  DicomStructureSet2::DicomStructureSet2()
+  {
+
+  }
+
+
+  DicomStructureSet2::~DicomStructureSet2()
+  {
+
+  }
+
   void DicomStructureSet2::SetContents(const OrthancPlugins::FullOrthancDataset& tags)
   {
     FillStructuresFromDataset(tags);
--- a/UnitTestsSources/TestStructureSet.cpp	Fri Sep 20 12:01:20 2019 +0200
+++ b/UnitTestsSources/TestStructureSet.cpp	Fri Sep 20 12:13:10 2019 +0200
@@ -4810,14 +4810,14 @@
 }
 
 /*
-void DicomStructure2::AddSlabBoundaries(
+void AddSlabBoundaries(
   std::vector<std::pair<double, RectangleBoundaryKind> >& boundaries,
   const std::vector<RtStructRectanglesInSlab>& slabCuts, size_t iSlab)
 */
 
 
 /*
-void DicomStructure2::ProcessBoundaryList(
+void ProcessBoundaryList(
   std::vector< std::pair<Point2D, Point2D> >& segments,
   const std::vector<std::pair<double, RectangleBoundaryKind> >& boundaries,
   double y)
@@ -4830,7 +4830,7 @@
   std::vector<std::pair<double, RectangleBoundaryKind> > boundaries;
 
   boundaries.clear();
-  EXPECT_NO_THROW(DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 0));
+  EXPECT_NO_THROW(AddSlabBoundaries(boundaries, slabCuts, 0));
   ASSERT_EQ(0, boundaries.size());
 }
 
@@ -4841,7 +4841,7 @@
   FillTestRectangleList(slabCuts);
 
   boundaries.clear();
-  DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 0);
+  AddSlabBoundaries(boundaries, slabCuts, 0);
 
   {
     size_t i = 0;
@@ -4872,8 +4872,8 @@
   FillTestRectangleList(slabCuts);
 
   boundaries.clear();
-  DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 0);
-  DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 1);
+  AddSlabBoundaries(boundaries, slabCuts, 0);
+  AddSlabBoundaries(boundaries, slabCuts, 1);
 
   ASSERT_EQ(8, boundaries.size());
 
@@ -4921,7 +4921,7 @@
   FillTestRectangleList(slabCuts);
   boundaries.clear();
   std::vector< std::pair<Point2D, Point2D> > segments;
-  ASSERT_NO_THROW(DicomStructure2::ProcessBoundaryList(segments, boundaries, 42.0));
+  ASSERT_NO_THROW(ProcessBoundaryList(segments, boundaries, 42.0));
   ASSERT_EQ(0u, segments.size());
 }
 
@@ -4934,8 +4934,8 @@
   {
     std::vector< std::pair<Point2D, Point2D> > segments;
     std::vector<std::pair<double, RectangleBoundaryKind> > boundaries;
-    DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 0);
-    DicomStructure2::ProcessBoundaryList(segments, boundaries, slabCuts[0][0].ymin);
+    AddSlabBoundaries(boundaries, slabCuts, 0);
+    ProcessBoundaryList(segments, boundaries, slabCuts[0][0].ymin);
 
     ASSERT_EQ(2u, segments.size());
 
@@ -4960,18 +4960,18 @@
   // top row
   {
     std::vector<std::pair<double, RectangleBoundaryKind> > boundaries;
-    DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 0);
+    AddSlabBoundaries(boundaries, slabCuts, 0);
     std::vector< std::pair<Point2D, Point2D> > segments;
-    DicomStructure2::ProcessBoundaryList(segments, boundaries, slabCuts[0][0].ymin);
+    ProcessBoundaryList(segments, boundaries, slabCuts[0][0].ymin);
   }
 
   // mids
   {
     std::vector<std::pair<double, RectangleBoundaryKind> > boundaries;
-    DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 0);
-    DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 1);
+    AddSlabBoundaries(boundaries, slabCuts, 0);
+    AddSlabBoundaries(boundaries, slabCuts, 1);
     std::vector< std::pair<Point2D, Point2D> > segments;
-    DicomStructure2::ProcessBoundaryList(segments, boundaries, slabCuts[0][0].ymax);
+    ProcessBoundaryList(segments, boundaries, slabCuts[0][0].ymax);
 
     ASSERT_EQ(4u, segments.size());
 
@@ -4999,9 +4999,9 @@
   // bottom row
   {
     std::vector<std::pair<double, RectangleBoundaryKind> > boundaries;
-    DicomStructure2::AddSlabBoundaries(boundaries, slabCuts, 1);
+    AddSlabBoundaries(boundaries, slabCuts, 1);
     std::vector< std::pair<Point2D, Point2D> > segments;
-    DicomStructure2::ProcessBoundaryList(segments, boundaries, slabCuts[1][0].ymax);
+    ProcessBoundaryList(segments, boundaries, slabCuts[1][0].ymax);
 
     ASSERT_EQ(2u, segments.size());
 
@@ -5025,7 +5025,7 @@
 
   std::vector< std::pair<Point2D, Point2D> > segments;
 
-  ASSERT_NO_THROW(DicomStructure2::ConvertListOfSlabsToSegments(segments, slabCuts, 0));
+  ASSERT_NO_THROW(ConvertListOfSlabsToSegments(segments, slabCuts, 0));
   ASSERT_EQ(0u, segments.size());
 }
 
@@ -5037,7 +5037,7 @@
 
   std::vector< std::pair<Point2D, Point2D> > segments;
 
-  ASSERT_NO_THROW(DicomStructure2::ConvertListOfSlabsToSegments(segments, slabCuts, totalRectCount));
+  ASSERT_NO_THROW(ConvertListOfSlabsToSegments(segments, slabCuts, totalRectCount));
   ASSERT_EQ(60u, segments.size());
 
   size_t i = 0;