]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add the possibility to build bounding boxes with containers of points.
authorLuca Heltai <luca.heltai@sissa.it>
Fri, 10 May 2019 08:55:58 +0000 (10:55 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Fri, 10 May 2019 16:11:10 +0000 (18:11 +0200)
include/deal.II/base/bounding_box.h
include/deal.II/boost_adaptors/bounding_box.h
source/base/bounding_box.cc

index 8922fa6b367626a305b38af4c0e9caeb800611a6..b6962409b166c9ead86416e59290aa0fb665de43 100644 (file)
@@ -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<spacedim, Number> elements.
+   */
+  template <class Container>
+  BoundingBox(const Container &points);
+
+  /**
+   * Return a reference to the boundary_points
    */
-  const std::pair<Point<spacedim, Number>, Point<spacedim, Number>> &
-  get_boundary_points() const;
+  std::pair<Point<spacedim, Number>, Point<spacedim, Number>> &
+  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<spacedim, Number>::BoundingBox(
   this->boundary_points = boundary_points;
 }
 
+
+
+template <int spacedim, typename Number>
+template <class Container>
+inline BoundingBox<spacedim, Number>::BoundingBox(const Container &points)
+{
+  boost::geometry::envelope(
+    boost::geometry::model::multi_point<Point<spacedim, Number>>(points.begin(),
+                                                                 points.end()),
+    *this);
+}
+
+
+
 template <int spacedim, typename Number>
 inline void
 BoundingBox<spacedim, Number>::extend(const Number &amount)
index a85f573aa9435fc51b7c0c1481d5860ef7c10ef7..63f4be68658126434015ba1d82e969e810471a6d 100644 (file)
@@ -21,6 +21,7 @@
 #include <deal.II/boost_adaptors/point.h>
 
 #include <boost/geometry.hpp>
+#include <boost/geometry/geometries/geometries.hpp>
 
 namespace boost
 {
index 410d610d3590d2bcbb8343c9f3440deb7d911997..006721f78caea451e360bf20abb09e4c464b3d59 100644 (file)
@@ -142,13 +142,17 @@ BoundingBox<spacedim, Number>::get_neighbor_type(
     }
 }
 
+
+
 template <int spacedim, typename Number>
-const std::pair<Point<spacedim, Number>, Point<spacedim, Number>> &
-BoundingBox<spacedim, Number>::get_boundary_points() const
+std::pair<Point<spacedim, Number>, Point<spacedim, Number>> &
+BoundingBox<spacedim, Number>::get_boundary_points()
 {
   return this->boundary_points;
 }
 
+
+
 template <int spacedim, typename Number>
 double
 BoundingBox<spacedim, Number>::volume() const

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.