changeset 1905:e318b524ad3f

use UnionOfRectangles algorithm to render RT-STRUCT
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 31 Jan 2022 18:50:35 +0100
parents 738814c24574
children 925aaf49150c
files OrthancStone/Sources/Toolbox/DicomStructureSet.cpp OrthancStone/Sources/Toolbox/Internals/RectanglesIntegerProjection.cpp OrthancStone/Sources/Toolbox/UnionOfRectangles.cpp
diffstat 3 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp	Mon Jan 31 18:22:57 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp	Mon Jan 31 18:50:35 2022 +0100
@@ -900,7 +900,7 @@
       {
         double x1, y1, x2, y2;
 
-        if (polygon->Project(x1, y1, x2, y2, slice))
+        if (polygon->Project(x1, y1, x2, y2, slice, GetEstimatedNormal(), GetEstimatedSliceThickness()))
         {
           projected.push_back(CreateRectangle(x1, y1, x2, y2));
         }
@@ -921,10 +921,8 @@
         }
       }  
 
-#elif 0
+#elif 1
 
-      // TODO - Fix possible infinite loop in UnionOfRectangles
-      
       std::list<Extent2D> rectangles;
       
       for (Polygons::const_iterator polygon = structure.polygons_.begin();
@@ -932,7 +930,7 @@
       {
         double x1, y1, x2, y2;
 
-        if (polygon->Project(x1, y1, x2, y2, slice))
+        if (polygon->Project(x1, y1, x2, y2, slice, GetEstimatedNormal(), GetEstimatedSliceThickness()))
         {
           rectangles.push_back(Extent2D(x1, y1, x2, y2));
         }
--- a/OrthancStone/Sources/Toolbox/Internals/RectanglesIntegerProjection.cpp	Mon Jan 31 18:22:57 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/Internals/RectanglesIntegerProjection.cpp	Mon Jan 31 18:50:35 2022 +0100
@@ -58,7 +58,7 @@
         }
         else if (value_ == other.value_)
         {
-          return isLow_;
+          return static_cast<int>(isLow_) < static_cast<int>(other.isLow_);
         }
         else
         {
--- a/OrthancStone/Sources/Toolbox/UnionOfRectangles.cpp	Mon Jan 31 18:22:57 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/UnionOfRectangles.cpp	Mon Jan 31 18:50:35 2022 +0100
@@ -307,7 +307,7 @@
       }
       else if (x_ == other.x_)
       {
-        return isLeft_;
+        return static_cast<int>(isLeft_) < static_cast<int>(other.isLeft_);
       }
       else
       {