From 6adb44e200c167082a0d048ce4746121f67615f3 Mon Sep 17 00:00:00 2001 From: Niklas Fehn Date: Thu, 4 Jun 2020 17:52:19 +0200 Subject: [PATCH] add tolerance to BoundingBox::point_inside() --- include/deal.II/base/bounding_box.h | 4 +++- source/base/bounding_box.cc | 10 ++++------ 2 files changed, 7 insertions(+), 7 deletions(-) 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; } -- 2.39.5