From 0b2d5db23a4adbd9991dbcb96dbbfd2d4310f622 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 5 Sep 2017 19:40:45 +0200 Subject: [PATCH] use geometrical tolerance to check if the simple normal computation fails; this allows to taylor the accuracy for plane surfaces defined with reduced accuracy (resulting in vertices not really co-planar) --- Geo/GFace.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index e9e41e535a..5f2a2233c4 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -452,7 +452,10 @@ void GFace::computeMeanPlane() for(unsigned int i = 2; i < pts.size(); i++){ SVector3 d0i(pts[0], pts[i]); SVector3 n = crossprod(d01, d0i); - if(norm(n) > 1e-6){ + // if too small, the points are almost colinear; tolerance is relatively + // high so that we don't accept points on plane surfaces defined by + // lines that are not exactly co-planar + if(norm(n) > sqrt(CTX::instance()->geom.tolerance) * CTX::instance()->lc){ res[0] = n.x(); res[1] = n.y(); res[2] = n.z(); xm = pts[0].x(); ym = pts[0].y(); zm = pts[0].z(); ok = true; -- GitLab