From 68c37b57befb88ab8b52c83425b6d3c8bfbb9898 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Mon, 15 Oct 2012 07:40:22 +0200 Subject: [PATCH] added method AABB::containsAABB() that checks if another AABB object is inside this AABB and added documentation to two other methods --- GeoLib/AxisAlignedBoundingBox.cpp | 11 +++++++++++ GeoLib/AxisAlignedBoundingBox.h | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/GeoLib/AxisAlignedBoundingBox.cpp b/GeoLib/AxisAlignedBoundingBox.cpp index b4dd113cab6..1d729498e9f 100644 --- a/GeoLib/AxisAlignedBoundingBox.cpp +++ b/GeoLib/AxisAlignedBoundingBox.cpp @@ -86,4 +86,15 @@ bool AABB::containsPoint (double x, double y, double z, double eps) const } else return false; } +bool AABB::containsAABB (AABB const& other_aabb) const +{ + GeoLib::Point const& min_other(other_aabb.getMinPoint()); + GeoLib::Point const& max_other(other_aabb.getMaxPoint()); + for (unsigned k(0); k<3; k++) { + if (_min_pnt[k] > min_other[k] || max_other[k] > _max_pnt[k]) + return false; + } + return true; +} + } // end namespace GeoLib diff --git a/GeoLib/AxisAlignedBoundingBox.h b/GeoLib/AxisAlignedBoundingBox.h index 98c0bef38a8..808c44f28ff 100644 --- a/GeoLib/AxisAlignedBoundingBox.h +++ b/GeoLib/AxisAlignedBoundingBox.h @@ -79,9 +79,29 @@ public: bool containsPoint(double x, double y, double z, double eps = std::numeric_limits<double>::epsilon()) const; + /** + * returns a point that coordinates are minimal for each dimension + * for the given point set + * @return a point + */ GeoLib::Point const& getMinPoint () const { return _min_pnt; } + + /** + * returns a point that coordinates are maximal for each dimension + * within the given point set + * @return a point + */ GeoLib::Point const& getMaxPoint () const { return _max_pnt; } + /** + * Method checks if the given AABB object is contained within the + * AABB represented by this object. + * @param other the AABB to test with + * @return true if the other AABB is contained in the AABB + * represented by this object + */ + bool containsAABB (AABB const& other) const; + protected: GeoLib::Point _min_pnt; GeoLib::Point _max_pnt; -- GitLab