# HG changeset patch # User Sebastien Jodogne # Date 1516638634 -3600 # Node ID fb7d602e70253af17fc007222a5b131b24d2dbef # Parent 6941b98cf0fd6745497fb3814498e2f40ee2b7c4 OrientedBoundingBox::ComputeExtent diff -r 6941b98cf0fd -r fb7d602e7025 Framework/Toolbox/OrientedBoundingBox.cpp --- 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 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; + } + } } diff -r 6941b98cf0fd -r fb7d602e7025 Framework/Toolbox/OrientedBoundingBox.h --- 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& 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; }; }