Reference documentation for deal.II version 9.0.0
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 at
12 // the top level of the deal.II distribution.
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 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/point.h>
23 #include <deal.II/base/utilities.h>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
31 enum class NeighborType
32 {
36  not_neighbors = 0,
37 
41  simple_neighbors = 1,
42 
46  attached_neighbors = 2,
47 
58  mergeable_neighbors = 3
59 };
60 
93 template <int spacedim, typename Number=double>
95 {
96 public:
101  BoundingBox () = default;
102 
108  BoundingBox (const std::pair<Point<spacedim,Number>,Point<spacedim,Number>> &boundary_points);
109 
113  const std::pair<Point<spacedim,Number>,Point<spacedim,Number>> &get_boundary_points () const;
114 
121  NeighborType get_neighbor_type (const BoundingBox<spacedim,Number> &other_bbox) const;
122 
128  void merge_with(const BoundingBox<spacedim,Number> &other_bbox);
129 
133  bool point_inside (const Point<spacedim, Number> &p) const;
134 
138  double volume() const;
139 
143  template<class Archive>
144  void serialize(Archive &ar, const unsigned int version );
145 
146 private:
147  std::pair<Point<spacedim,Number>,Point<spacedim,Number>> boundary_points;
148 };
149 
150 /*------------------------------- Inline functions: BoundingBox ---------------------------*/
151 
152 #ifndef DOXYGEN
153 
154 
155 template <int spacedim, typename Number>
156 inline
158 {
159  //We check the Bounding Box is not degenerate
160  for (unsigned int i=0; i<spacedim; ++i)
161  Assert (boundary_points.first[i] <= boundary_points.second[i],
162  ExcMessage ("Bounding Box can't be created: the point's order should be bottom left, top right!"));
163 
164  this->boundary_points = boundary_points;
165 }
166 
167 
168 template <int spacedim, typename Number>
169 template<class Archive>
170 void BoundingBox<spacedim, Number>::serialize(Archive &ar, const unsigned int /*version*/)
171 {
172  ar &boundary_points;
173 }
174 
175 #endif // DOXYGEN
176 DEAL_II_NAMESPACE_CLOSE
177 
178 #endif
void merge_with(const BoundingBox< spacedim, Number > &other_bbox)
Definition: bounding_box.cc:37
Definition: point.h:104
BoundingBox()=default
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
Definition: exceptions.h:1142
NeighborType get_neighbor_type(const BoundingBox< spacedim, Number > &other_bbox) const
Definition: bounding_box.cc:47
bool point_inside(const Point< spacedim, Number > &p) const
Definition: bounding_box.cc:20
void serialize(Archive &ar, const unsigned int version)
double volume() const
const std::pair< Point< spacedim, Number >, Point< spacedim, Number > > & get_boundary_points() const