Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
bounding_box.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_base_bounding_box_h
17 #define dealii_base_bounding_box_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/exceptions.h>
23 #include <deal.II/base/point.h>
24 #include <deal.II/base/utilities.h>
25 
26 DEAL_II_NAMESPACE_OPEN
27 
32 enum class NeighborType
33 {
37  not_neighbors = 0,
38 
43  simple_neighbors = 1,
44 
49  attached_neighbors = 2,
50 
61  mergeable_neighbors = 3
62 };
63 
96 template <int spacedim, typename Number = double>
98 {
99 public:
104  BoundingBox() = default;
105 
112  &boundary_points);
113 
121  template <class Container>
122  BoundingBox(const Container &points);
123 
127  std::pair<Point<spacedim, Number>, Point<spacedim, Number>> &
129 
133  const std::pair<Point<spacedim, Number>, Point<spacedim, Number>> &
134  get_boundary_points() const;
135 
142  NeighborType
143  get_neighbor_type(const BoundingBox<spacedim, Number> &other_bbox) const;
144 
150  void
151  merge_with(const BoundingBox<spacedim, Number> &other_bbox);
152 
156  bool
157  point_inside(const Point<spacedim, Number> &p) const;
158 
169  void
170  extend(const Number &amount);
171 
175  double
176  volume() const;
177 
181  template <class Archive>
182  void
183  serialize(Archive &ar, const unsigned int version);
184 
185 private:
186  std::pair<Point<spacedim, Number>, Point<spacedim, Number>> boundary_points;
187 };
188 
189 /*------------------------ Inline functions: BoundingBox --------------------*/
190 
191 #ifndef DOXYGEN
192 
193 
194 template <int spacedim, typename Number>
197  &boundary_points)
198 {
199  // We check the Bounding Box is not degenerate
200  for (unsigned int i = 0; i < spacedim; ++i)
201  Assert(boundary_points.first[i] <= boundary_points.second[i],
202  ExcMessage("Bounding Box can't be created: the points' "
203  "order should be bottom left, top right!"));
204 
205  this->boundary_points = boundary_points;
206 }
207 
208 
209 
210 template <int spacedim, typename Number>
211 template <class Container>
212 inline BoundingBox<spacedim, Number>::BoundingBox(const Container &points)
213 {
214  boost::geometry::envelope(
215  boost::geometry::model::multi_point<Point<spacedim, Number>>(points.begin(),
216  points.end()),
217  *this);
218 }
219 
220 
221 
222 template <int spacedim, typename Number>
223 inline void
224 BoundingBox<spacedim, Number>::extend(const Number &amount)
225 {
226  for (unsigned int d = 0; d < spacedim; ++d)
227  {
228  boundary_points.first[d] -= amount;
229  boundary_points.second[d] += amount;
230  Assert(boundary_points.first[d] <= boundary_points.second[d],
231  ExcMessage("Bounding Box can't be shrunk this much: the points' "
232  "order should remain bottom left, top right."));
233  }
234 }
235 
236 
237 template <int spacedim, typename Number>
238 template <class Archive>
239 void
241  const unsigned int /*version*/)
242 {
243  ar &boundary_points;
244 }
245 
246 #endif // DOXYGEN
247 DEAL_II_NAMESPACE_CLOSE
248 
249 #endif
void extend(const Number &amount)
void merge_with(const BoundingBox< spacedim, Number > &other_bbox)
Definition: bounding_box.cc:42
Definition: point.h:110
BoundingBox()=default
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
Definition: exceptions.h:1407
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
NeighborType get_neighbor_type(const BoundingBox< spacedim, Number > &other_bbox) const
Definition: bounding_box.cc:58
bool point_inside(const Point< spacedim, Number > &p) const
Definition: bounding_box.cc:21
void serialize(Archive &ar, const unsigned int version)
std::pair< Point< spacedim, Number >, Point< spacedim, Number > > & get_boundary_points()
double volume() const