Reference documentation for deal.II version 9.1.0-pre
bounding_box.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2018 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 
117  const std::pair<Point<spacedim, Number>, Point<spacedim, Number>> &
118  get_boundary_points() const;
119 
126  NeighborType
127  get_neighbor_type(const BoundingBox<spacedim, Number> &other_bbox) const;
128 
134  void
135  merge_with(const BoundingBox<spacedim, Number> &other_bbox);
136 
140  bool
141  point_inside(const Point<spacedim, Number> &p) const;
142 
146  double
147  volume() const;
148 
152  template <class Archive>
153  void
154  serialize(Archive &ar, const unsigned int version);
155 
156 private:
157  std::pair<Point<spacedim, Number>, Point<spacedim, Number>> boundary_points;
158 };
159 
160 /*------------------------ Inline functions: BoundingBox --------------------*/
161 
162 #ifndef DOXYGEN
163 
164 
165 template <int spacedim, typename Number>
168  &boundary_points)
169 {
170  // We check the Bounding Box is not degenerate
171  for (unsigned int i = 0; i < spacedim; ++i)
172  Assert(boundary_points.first[i] <= boundary_points.second[i],
173  ExcMessage("Bounding Box can't be created: the points' "
174  "order should be bottom left, top right!"));
175 
176  this->boundary_points = boundary_points;
177 }
178 
179 
180 template <int spacedim, typename Number>
181 template <class Archive>
182 void
184  const unsigned int /*version*/)
185 {
186  ar &boundary_points;
187 }
188 
189 #endif // DOXYGEN
190 DEAL_II_NAMESPACE_CLOSE
191 
192 #endif
Definition: point.h:106
BoundingBox()=default
static::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
Definition: exceptions.h:1227
void serialize(Archive &ar, const unsigned int version)