21 #include "libmesh/bounding_box.h" 32 return min <= check && check <= max;
38 Real my_min_x = this->first(0);
39 Real my_max_x = this->second(0);
40 bool x_int =
is_between(my_min_x, p(0), my_max_x);
42 bool intersection_true = x_int;
45 Real my_min_y = this->first(1);
46 Real my_max_y = this->second(1);
47 bool y_int =
is_between(my_min_y, p(1), my_max_y);
49 intersection_true = intersection_true && y_int;
54 Real my_min_z = this->first(2);
55 Real my_max_z = this->second(2);
56 bool z_int =
is_between(my_min_z, p(2), my_max_z);
58 intersection_true = intersection_true && z_int;
61 return intersection_true;
69 for (
unsigned int d = 0; d != LIBMESH_DIM; ++d)
71 Real sized = this->second(d) - this->first(d);
73 this->second(d) != std::numeric_limits<Real>::max() &&
74 this->first(d) != -std::numeric_limits<Real>::max())
75 size = std::max(size, sized);
85 libmesh_assert_greater_equal(abs_tol,
Real(0));
86 libmesh_assert_greater_equal(rel_tol,
Real(0));
89 libmesh_assert_greater(rel_tol+abs_tol,
Real(0));
92 const Real tol = std::max(abs_tol, this->max_size()*rel_tol);
95 const Real my_min_x = this->first(0) - tol;
96 const Real my_max_x = this->second(0) + tol;
97 const bool x_int =
is_between(my_min_x, p(0), my_max_x);
99 bool intersection_true = x_int;
102 const Real my_min_y = this->first(1) - tol;
103 const Real my_max_y = this->second(1) + tol;
104 const bool y_int =
is_between(my_min_y, p(1), my_max_y);
106 intersection_true = intersection_true && y_int;
111 const Real my_min_z = this->first(2) - tol;
112 const Real my_max_z = this->second(2) + tol;
113 const bool z_int =
is_between(my_min_z, p(2), my_max_z);
115 intersection_true = intersection_true && z_int;
118 return intersection_true;
125 this->first(0) = std::max(this->first(0), other_box.first(0));
126 this->second(0) = std::min(this->second(0), other_box.second(0));
129 this->first(1) = std::max(this->first(1), other_box.first(1));
130 this->second(1) = std::min(this->second(1), other_box.second(1));
134 this->first(2) = std::max(this->first(2), other_box.first(2));
135 this->second(2) = std::min(this->second(2), other_box.second(2));
142 this->first(0) = std::min(this->first(0), other_box.first(0));
143 this->second(0) = std::max(this->second(0), other_box.second(0));
146 this->first(1) = std::min(this->first(1), other_box.first(1));
147 this->second(1) = std::max(this->second(1), other_box.second(1));
151 this->first(2) = std::min(this->first(2), other_box.first(2));
152 this->second(2) = std::max(this->second(2), other_box.second(2));
165 Real min_dist = std::numeric_limits<Real>::max();
167 for (
unsigned int dir=0; dir<LIBMESH_DIM; ++dir)
169 min_dist = std::min(min_dist, std::abs(p(dir) - second(dir)));
170 min_dist = std::min(min_dist, std::abs(p(dir) - first(dir)));
177 Real dx[3] = {0., 0., 0.};
182 for (
unsigned int dir=0; dir<LIBMESH_DIM; ++dir)
184 if (p(dir) > second(dir))
185 dx[dir] = p(dir) - second(dir);
186 else if (p(dir) < first(dir))
187 dx[dir] = p(dir) - first(dir);
190 return std::sqrt(dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]);
198 for (
unsigned int dim = 0;
dim != LIBMESH_DIM; ++
dim)
200 if (this->first(
dim) != std::numeric_limits<Real>::max() &&
201 this->second(
dim) != -std::numeric_limits<Real>::max())
203 libmesh_assert_greater_equal(this->second(
dim), this->first(
dim));
204 append = (this->second(
dim) - this->first(
dim)) * factor;
205 this->first(
dim) -= append;
206 this->second(
dim) += append;
214 os <<
"(min=" << this->
min() <<
", max=" << this->
max() <<
")";
bool contains_point(const Point &) const
void intersect_with(const BoundingBox &)
Sets this bounding box to be the intersection with the other bounding box.
The libMesh namespace provides an interface to certain functionality in the library.
Real signed_distance(const Point &p) const
Computes the signed distance, d, from a given Point p to this BoundingBox.
const Point & min() const
Real max_size() const
Returns the maximum size of a finite box extent.
bool is_between(Real min, Real check, Real max)
void print(std::ostream &os=libMesh::out) const
Formatted print, by default to libMesh::out.
Defines a Cartesian bounding box by the two corner extremum.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void union_with(const Point &p)
Enlarges this bounding box to include the given point.
const Point & max() const
void scale(const Real factor)
Scales each dimension of the bounding box by factor.
A Point defines a location in LIBMESH_DIM dimensional Real space.