From 8d3e5a31fb1af21cd6062ca703d945730f317207 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 8 Aug 2016 16:40:11 +0200 Subject: [PATCH] add plausibility for self-intersectin check to filter out false-positives --- src/Mod/Mesh/App/Core/Elements.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Mod/Mesh/App/Core/Elements.cpp b/src/Mod/Mesh/App/Core/Elements.cpp index 32ef85128..5ebefe821 100644 --- a/src/Mod/Mesh/App/Core/Elements.cpp +++ b/src/Mod/Mesh/App/Core/Elements.cpp @@ -808,6 +808,18 @@ int MeshGeomFacet::IntersectWithFacet (const MeshGeomFacet& rclFacet, rclPt0.x = isectpt1[0]; rclPt0.y = isectpt1[1]; rclPt0.z = isectpt1[2]; rclPt1.x = isectpt2[0]; rclPt1.y = isectpt2[1]; rclPt1.z = isectpt2[2]; + // With extremely acute-angled triangles it may happen that the algorithm + // claims an intersection but the intersection points are far outside the + // model. So, a plausability check is to verify that the intersection points + // are inside the bounding boxes of both triangles. + Base::BoundBox3f box1 = this->GetBoundBox(); + if (!box1.IsInBox(rclPt0) || !box1.IsInBox(rclPt1)) + return 0; + + Base::BoundBox3f box2 = rclFacet.GetBoundBox(); + if (!box2.IsInBox(rclPt0) || !box2.IsInBox(rclPt1)) + return 0; + // Note: The algorithm delivers sometimes false-positives, i.e. it claims // that the two triangles intersect but they don't. It seems that this bad // behaviour occurs if the triangles are nearly co-planar