changeset 146:fb7d602e7025 wasm

OrientedBoundingBox::ComputeExtent
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Jan 2018 17:30:34 +0100
parents 6941b98cf0fd
children f48c5d422d45
files Framework/Toolbox/OrientedBoundingBox.cpp Framework/Toolbox/OrientedBoundingBox.h
diffstat 2 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Toolbox/OrientedBoundingBox.cpp	Mon Jan 22 16:44:52 2018 +0100
+++ b/Framework/Toolbox/OrientedBoundingBox.cpp	Mon Jan 22 17:30:34 2018 +0100
@@ -264,4 +264,28 @@
 
     GeometryToolbox::AssignVector(target, x, y, z);
   }
+
+
+  bool OrientedBoundingBox::ComputeExtent(Extent2D& extent,
+                                          const CoordinateSystem3D& plane) const
+  {
+    extent.Reset();
+    
+    std::vector<Vector> points;
+    if (HasIntersection(points, plane))
+    {
+      for (size_t i = 0; i < points.size(); i++)
+      {
+        double x, y;
+        plane.ProjectPoint(x, y, points[i]);
+        extent.AddPoint(x, y);
+      }
+      
+      return true;
+    }
+    else
+    {
+      return false;
+    }
+  }
 }
--- a/Framework/Toolbox/OrientedBoundingBox.h	Mon Jan 22 16:44:52 2018 +0100
+++ b/Framework/Toolbox/OrientedBoundingBox.h	Mon Jan 22 17:30:34 2018 +0100
@@ -21,6 +21,7 @@
 
 #pragma once
 
+#include "Extent2D.h"
 #include "GeometryToolbox.h"
 #include "../Volumes/ImageBuffer3D.h"
 
@@ -40,6 +41,11 @@
   public:
     OrientedBoundingBox(const ImageBuffer3D& image);
 
+    const Vector& GetCenter() const
+    {
+      return c_;
+    }
+
     bool HasIntersectionWithPlane(std::vector<Vector>& points,
                                   const Vector& normal,
                                   double d) const;
@@ -60,10 +66,8 @@
     void ToInternalCoordinates(Vector& target,
                                const Vector& source) const;
 
-    const Vector& GetCenter() const
-    {
-      return c_;
-    }
+    bool ComputeExtent(Extent2D& extent,
+                       const CoordinateSystem3D& plane) const;
   };
 }