From: Niklas Fehn Date: Thu, 4 Jun 2020 15:52:19 +0000 (+0200) Subject: add tolerance to BoundingBox::point_inside() X-Git-Tag: v9.3.0-rc1~1480^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6adb44e200c167082a0d048ce4746121f67615f3;p=dealii.git add tolerance to BoundingBox::point_inside() --- diff --git a/include/deal.II/base/bounding_box.h b/include/deal.II/base/bounding_box.h index 040894ac72..f97673e26e 100644 --- a/include/deal.II/base/bounding_box.h +++ b/include/deal.II/base/bounding_box.h @@ -185,7 +185,9 @@ public: * Return true if the point is inside the Bounding Box, false otherwise. */ bool - point_inside(const Point &p) const; + point_inside( + const Point &p, + const double tolerance = std::numeric_limits::epsilon()) const; /** * Increase (or decrease) the size of the bounding box by the given amount. diff --git a/source/base/bounding_box.cc b/source/base/bounding_box.cc index 30b3191d45..72f097aa07 100644 --- a/source/base/bounding_box.cc +++ b/source/base/bounding_box.cc @@ -19,19 +19,17 @@ DEAL_II_NAMESPACE_OPEN template bool -BoundingBox::point_inside( - const Point &p) const +BoundingBox::point_inside(const Point &p, + const double tolerance) const { for (unsigned int i = 0; i < spacedim; ++i) { // Bottom left-top right convention: the point is outside if it's smaller // than the first or bigger than the second boundary point The bounding // box is defined as a closed set - if (std::numeric_limits::epsilon() * - (std::abs(this->boundary_points.first[i] + p[i])) < + if (tolerance * std::abs(this->boundary_points.first[i] + p[i]) < this->boundary_points.first[i] - p[i] || - std::numeric_limits::epsilon() * - (std::abs(this->boundary_points.second[i] + p[i])) < + tolerance * std::abs(this->boundary_points.second[i] + p[i]) < p[i] - this->boundary_points.second[i]) return false; }