15 #include <deal.II/base/bounding_box.h> 17 DEAL_II_NAMESPACE_OPEN
19 template <
int spacedim,
typename Number>
24 for (
unsigned int i = 0; i < spacedim; ++i)
29 if (std::numeric_limits<Number>::epsilon() *
30 (std::abs(this->boundary_points.first[i] + p[i])) <
31 this->boundary_points.first[i] - p[i] ||
32 std::numeric_limits<Number>::epsilon() *
33 (std::abs(this->boundary_points.second[i] + p[i])) <
34 p[i] - this->boundary_points.second[i])
40 template <
int spacedim,
typename Number>
45 for (
unsigned int i = 0; i < spacedim; ++i)
47 this->boundary_points.first[i] =
48 std::min(this->boundary_points.first[i],
49 other_bbox.boundary_points.first[i]);
50 this->boundary_points.second[i] =
51 std::max(this->boundary_points.second[i],
52 other_bbox.boundary_points.second[i]);
56 template <
int spacedim,
typename Number>
65 if (this->point_inside(other_bbox.boundary_points.first) ||
66 this->point_inside(other_bbox.boundary_points.second))
67 return NeighborType::mergeable_neighbors;
68 return NeighborType::not_neighbors;
72 std::vector<Point<spacedim, Number>> bbox1;
73 bbox1.push_back(this->get_boundary_points().first);
74 bbox1.push_back(this->get_boundary_points().second);
75 std::vector<Point<spacedim, Number>> bbox2;
80 for (
unsigned int d = 0; d < spacedim; ++d)
81 if (bbox1[0][d] * (1 - std::numeric_limits<Number>::epsilon()) >
83 bbox2[0][d] * (1 - std::numeric_limits<Number>::epsilon()) >
85 return NeighborType::not_neighbors;
89 std::vector<double> intersect_bbox_min;
90 std::vector<double> intersect_bbox_max;
91 for (
unsigned int d = 0; d < spacedim; ++d)
93 intersect_bbox_min.push_back(std::max(bbox1[0][d], bbox2[0][d]));
94 intersect_bbox_max.push_back(std::min(bbox1[1][d], bbox2[1][d]));
99 unsigned int intersect_dim = spacedim;
100 for (
unsigned int d = 0; d < spacedim; ++d)
101 if (std::abs(intersect_bbox_min[d] - intersect_bbox_max[d]) <=
102 std::numeric_limits<Number>::epsilon() *
103 (std::abs(intersect_bbox_min[d]) +
104 std::abs(intersect_bbox_max[d])))
107 if (intersect_dim == 0 || intersect_dim + 2 == spacedim)
108 return NeighborType::simple_neighbors;
112 unsigned int not_align_1 = 0, not_align_2 = 0;
113 bool same_direction =
true;
114 for (
unsigned int d = 0; d < spacedim; ++d)
116 if (std::abs(bbox2[0][d] - bbox1[0][d]) >
117 std::numeric_limits<double>::epsilon() *
118 (std::abs(bbox2[0][d]) + std::abs(bbox1[0][d])))
120 if (std::abs(bbox1[1][d] - bbox2[1][d]) >
121 std::numeric_limits<double>::epsilon() *
122 (std::abs(bbox1[1][d]) + std::abs(bbox2[1][d])))
124 if (not_align_1 != not_align_2)
126 same_direction =
false;
131 if (not_align_1 <= 1 && not_align_2 <= 1 && same_direction)
132 return NeighborType::mergeable_neighbors;
135 if ((this->point_inside(bbox2[0]) && this->point_inside(bbox2[1])) ||
138 return NeighborType::mergeable_neighbors;
141 return NeighborType::attached_neighbors;
147 template <
int spacedim,
typename Number>
151 return this->boundary_points;
156 template <
int spacedim,
typename Number>
160 return this->boundary_points;
165 template <
int spacedim,
typename Number>
170 for (
unsigned int i = 0; i < spacedim; ++i)
171 vol *= (this->boundary_points.second[i] - this->boundary_points.first[i]);
175 #include "bounding_box.inst" 176 DEAL_II_NAMESPACE_CLOSE
void merge_with(const BoundingBox< spacedim, Number > &other_bbox)
NeighborType get_neighbor_type(const BoundingBox< spacedim, Number > &other_bbox) const
bool point_inside(const Point< spacedim, Number > &p) const
std::pair< Point< spacedim, Number >, Point< spacedim, Number > > & get_boundary_points()