From b9a7dffdc94dee0d0e49d3bfd1fcb493a9ac6af4 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 10 Jun 2011 07:40:52 +0000 Subject: [PATCH] fixes very old bug (crash if plane surface control points are colinear): fixes #128 and Debian Bug#607875 --- Geo/GFace.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index ee6bd136ce..2baf220afa 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -326,7 +326,13 @@ void GFace::computeMeanPlane() pts.push_back(SPoint3(v->x(), v->y(), v->z())); } - if(pts.size() < 3){ + bool colinear = (pts.size() < 3); + if(pts.size() > 2){ + SVector3 d01(pts[0], pts[1]), d02(pts[0], pts[2]); + if(norm(crossprod(d01, d02)) < 1e-12) colinear = true; + } + + if(colinear){ Msg::Info("Adding edge points to compute mean plane of face %d", tag()); std::list<GEdge*> edg = edges(); for(std::list<GEdge*>::const_iterator ite = edg.begin(); ite != edg.end(); ite++){ -- GitLab