-
Notifications
You must be signed in to change notification settings - Fork 295
Bounding box testing for $Entities in GmshIO #3903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8ac14ed
5a5ba3b
1802440
95d841f
e9ab243
8babc57
3e3a033
52d29fd
eaeedd3
8a0cc8e
cb9cbf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,6 +62,64 @@ bool BoundingBox::contains_point (const Point & p) const | |||||
} | ||||||
|
||||||
|
||||||
|
||||||
Real BoundingBox::max_size() const | ||||||
{ | ||||||
Real size = 0; | ||||||
for (unsigned int d = 0; d != LIBMESH_DIM; ++d) | ||||||
{ | ||||||
Real sized = this->second(d) - this->first(d); | ||||||
if (!libmesh_isinf(sized) && | ||||||
this->second(d) != std::numeric_limits<Real>::max() && | ||||||
this->first(d) != -std::numeric_limits<Real>::max()) | ||||||
size = std::max(size, sized); | ||||||
} | ||||||
return size; | ||||||
} | ||||||
|
||||||
|
||||||
|
||||||
bool BoundingBox::contains_point | ||||||
(const Point & p, Real abs_tol, Real rel_tol) const | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We generally don't pass parameters by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can leave it non-const in the header declaration for the reason you stated but mark it as |
||||||
{ | ||||||
libmesh_assert_greater_equal(abs_tol, Real(0)); | ||||||
libmesh_assert_greater_equal(rel_tol, Real(0)); | ||||||
|
||||||
// Just use the other contains_point overload | ||||||
libmesh_assert_greater(rel_tol+abs_tol, Real(0)); | ||||||
|
||||||
// Find absolute tolerance from relative tolerance | ||||||
const Real tol = std::max(abs_tol, this->max_size()*rel_tol); | ||||||
|
||||||
// Make local variables first to make things more clear in a moment | ||||||
const Real my_min_x = this->first(0) - tol; | ||||||
const Real my_max_x = this->second(0) + tol; | ||||||
const bool x_int = is_between(my_min_x, p(0), my_max_x); | ||||||
|
||||||
bool intersection_true = x_int; | ||||||
|
||||||
#if LIBMESH_DIM > 1 | ||||||
const Real my_min_y = this->first(1) - tol; | ||||||
const Real my_max_y = this->second(1) + tol; | ||||||
const bool y_int = is_between(my_min_y, p(1), my_max_y); | ||||||
|
||||||
intersection_true = intersection_true && y_int; | ||||||
#endif | ||||||
|
||||||
|
||||||
#if LIBMESH_DIM > 2 | ||||||
const Real my_min_z = this->first(2) - tol; | ||||||
const Real my_max_z = this->second(2) + tol; | ||||||
const bool z_int = is_between(my_min_z, p(2), my_max_z); | ||||||
|
||||||
intersection_true = intersection_true && z_int; | ||||||
#endif | ||||||
|
||||||
return intersection_true; | ||||||
} | ||||||
|
||||||
|
||||||
|
||||||
void BoundingBox::intersect_with (const BoundingBox & other_box) | ||||||
{ | ||||||
this->first(0) = std::max(this->first(0), other_box.first(0)); | ||||||
|
@@ -150,4 +208,10 @@ void BoundingBox::scale(const Real factor) | |||||
} | ||||||
} | ||||||
|
||||||
|
||||||
void BoundingBox::print(std::ostream & os) const | ||||||
{ | ||||||
os << "(min=" << this->min() << ", max=" << this->max() << ")"; | ||||||
} | ||||||
|
||||||
} // namespace libMesh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, after #3895 goes in, we could use
make_range
withlibmesh_dim
here