From: Luca Heltai Date: Fri, 10 May 2019 08:55:58 +0000 (+0200) Subject: Add the possibility to build bounding boxes with containers of points. X-Git-Tag: v9.1.0-rc1~70^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e38e0401f4b812e142ea2392ad3c34767e92d83c;p=dealii.git Add the possibility to build bounding boxes with containers of points. --- diff --git a/include/deal.II/base/bounding_box.h b/include/deal.II/base/bounding_box.h index 8922fa6b36..b6962409b1 100644 --- a/include/deal.II/base/bounding_box.h +++ b/include/deal.II/base/bounding_box.h @@ -67,7 +67,7 @@ enum class NeighborType * * Objects of this class are used to represent bounding boxes. They are, * among other uses, useful in parallel distributed meshes to give a general - * description the owners of each portion of the mesh. + * description of the owners of each portion of the mesh. * * Bounding boxes are represented by two vertices (bottom left and top right). * Geometrically, a bounding box is: @@ -89,7 +89,7 @@ enum class NeighborType * | |/ * V------. * @endcode - * Notice the sides are always parallel to the respective axis. + * Notice that the sides are always parallel to the respective axis. * * @author Giovanni Alzetta, 2017. */ @@ -112,10 +112,20 @@ public: &boundary_points); /** - * Return the boundary_points + * Construct the bounding box that encloses all the points in the given + * container. + * + * The constructor supports any Container that provides begin() and end() + * iterators to Point elements. + */ + template + BoundingBox(const Container &points); + + /** + * Return a reference to the boundary_points */ - const std::pair, Point> & - get_boundary_points() const; + std::pair, Point> & + get_boundary_points(); /** * Check if the current object and @p other_bbox are neighbors, i.e. if the boxes @@ -189,6 +199,20 @@ inline BoundingBox::BoundingBox( this->boundary_points = boundary_points; } + + +template +template +inline BoundingBox::BoundingBox(const Container &points) +{ + boost::geometry::envelope( + boost::geometry::model::multi_point>(points.begin(), + points.end()), + *this); +} + + + template inline void BoundingBox::extend(const Number &amount) diff --git a/include/deal.II/boost_adaptors/bounding_box.h b/include/deal.II/boost_adaptors/bounding_box.h index a85f573aa9..63f4be6865 100644 --- a/include/deal.II/boost_adaptors/bounding_box.h +++ b/include/deal.II/boost_adaptors/bounding_box.h @@ -21,6 +21,7 @@ #include #include +#include namespace boost { diff --git a/source/base/bounding_box.cc b/source/base/bounding_box.cc index 410d610d35..006721f78c 100644 --- a/source/base/bounding_box.cc +++ b/source/base/bounding_box.cc @@ -142,13 +142,17 @@ BoundingBox::get_neighbor_type( } } + + template -const std::pair, Point> & -BoundingBox::get_boundary_points() const +std::pair, Point> & +BoundingBox::get_boundary_points() { return this->boundary_points; } + + template double BoundingBox::volume() const