15 #include <deal.II/base/bounding_box.h> 17 DEAL_II_NAMESPACE_OPEN
19 template <
int spacedim,
typename Number>
22 for (
unsigned int i=0; i < spacedim; ++i)
27 if ( std::numeric_limits<Number>::epsilon()*(std::abs( this->boundary_points.first[i] + p[i]) )
28 < this->boundary_points.first[i] - p[i]
29 || std::numeric_limits<Number>::epsilon()*(std::abs( this->boundary_points.second[i] + p[i]) ) <
30 p[i] - this->boundary_points.second[i] )
36 template <
int spacedim,
typename Number>
39 for (
unsigned int i=0; i < spacedim; ++i)
41 this->boundary_points.first[i] = std::min( this->boundary_points.first[i], other_bbox.boundary_points.first[i] );
42 this->boundary_points.second[i] = std::max( this->boundary_points.second[i], other_bbox.boundary_points.second[i] );
46 template <
int spacedim,
typename Number>
53 if ( this->point_inside(other_bbox.boundary_points.first)
54 || this->point_inside(other_bbox.boundary_points.second) )
55 return NeighborType::mergeable_neighbors;
56 return NeighborType::not_neighbors;
60 std::vector< Point<spacedim,Number> > bbox1;
61 bbox1.push_back(this->get_boundary_points().first);
62 bbox1.push_back(this->get_boundary_points().second);
63 std::vector< Point<spacedim,Number> > bbox2;
64 bbox2.push_back(other_bbox.get_boundary_points().first);
65 bbox2.push_back(other_bbox.get_boundary_points().second);
68 for (
unsigned int d=0 ; d<spacedim; ++d )
69 if ( bbox1[0][d] * ( 1 - std::numeric_limits<Number>::epsilon() ) > bbox2[1][d]
70 || bbox2[0][d] * (1 - std::numeric_limits<Number>::epsilon() ) > bbox1[1][d] )
71 return NeighborType::not_neighbors;
75 std::vector<double> intersect_bbox_min;
76 std::vector<double> intersect_bbox_max;
77 for (
unsigned int d=0; d < spacedim ; ++d)
79 intersect_bbox_min.push_back(std::max(bbox1[0][d],bbox2[0][d]));
80 intersect_bbox_max.push_back(std::min(bbox1[1][d],bbox2[1][d]));
85 unsigned int intersect_dim = spacedim;
86 for (
unsigned int d=0; d < spacedim; ++d)
87 if ( std::abs( intersect_bbox_min[d] - intersect_bbox_max[d] ) <=
88 std::numeric_limits<Number>::epsilon() * (std::abs( intersect_bbox_min[d]) + std::abs(intersect_bbox_max[d] )) )
91 if ( intersect_dim == 0 || intersect_dim + 2 == spacedim )
92 return NeighborType::simple_neighbors;
95 unsigned int not_align_1 = 0, not_align_2 = 0;
96 bool same_direction =
true;
97 for (
unsigned int d = 0; d < spacedim; ++d)
99 if (std::abs(bbox2[0][d] - bbox1[0][d]) >
100 std::numeric_limits<double>::epsilon() * (std::abs( bbox2[0][d]) + std::abs(bbox1[0][d] )) )
102 if (std::abs(bbox1[1][d] - bbox2[1][d]) >
103 std::numeric_limits<double>::epsilon() * (std::abs( bbox1[1][d]) + std::abs( bbox2[1][d] )) )
105 if (not_align_1 != not_align_2)
107 same_direction =
false;
112 if ( not_align_1 <= 1 && not_align_2 <= 1 && same_direction)
113 return NeighborType::mergeable_neighbors;
116 if ( (this->point_inside(bbox2[0]) && this->point_inside(bbox2[1]) )
117 || (other_bbox.point_inside(bbox1[0]) && other_bbox.point_inside(bbox1[1]) ) )
118 return NeighborType::mergeable_neighbors;
121 return NeighborType::attached_neighbors;
126 template <
int spacedim,
typename Number>
129 return this->boundary_points;
132 template <
int spacedim,
typename Number>
136 for (
unsigned int i=0; i < spacedim; ++i)
137 vol *= ( this->boundary_points.second[i] - this->boundary_points.first[i] );
141 #include "bounding_box.inst" 142 DEAL_II_NAMESPACE_CLOSE
void merge_with(const BoundingBox< spacedim, Number > &other_bbox)
bool point_inside(const Point< spacedim, Number > &p) const
const std::pair< Point< spacedim, Number >, Point< spacedim, Number > > & get_boundary_points() const