From e8a2c4570b3c68580950ce18ea433fb50fd20559 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 1 Jul 2020 14:32:51 +0100 Subject: [PATCH] surfaceFeatures: Prevent floating point error when edge is parallel to plane --- .../meshes/primitiveShapes/line/line.H | 4 +--- .../meshes/primitiveShapes/line/lineI.H | 19 +------------------ .../surfaceFeatures/surfaceFeatures.C | 7 ++----- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveShapes/line/line.H b/src/OpenFOAM/meshes/primitiveShapes/line/line.H index 3106abcba2..0eb5a3a5f2 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/line/line.H +++ b/src/OpenFOAM/meshes/primitiveShapes/line/line.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -130,8 +130,6 @@ public: Point& edgePoint ) const; - bool insideBoundBox(const Point&) const; - // Ostream operator diff --git a/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H b/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H index f1cbeefebc..d0c645a9f1 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -257,23 +257,6 @@ Foam::scalar Foam::line::nearestDist } -template -bool Foam::line::insideBoundBox(const Point& p) const -{ - if - ( - ( p.x() < min(a_.x(), b_.x()) || p.x() > max(a_.x(), b_.x()) ) - || ( p.y() < min(a_.y(), b_.y()) || p.y() > max(a_.y(), b_.y()) ) - || ( p.z() < min(a_.z(), b_.z()) || p.z() > max(a_.z(), b_.z()) ) - ) - { - return false; - } - - return true; -} - - // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * // template diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index 72b791fcad..20bb57bb79 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -1540,10 +1540,7 @@ void Foam::selectCutEdges // If edge does not intersect the plane, delete. const scalar intersect = cutPlane.lineIntersect(line); - - const point featPoint = intersect*(p1 - p0) + p0; - - if (!line.insideBoundBox(featPoint)) + if (intersect < 0 || intersect > 1) { edgeStat[edgei] = surfaceFeatures::NONE; }