From 79839d487ae3e74cfb5c4e7dcf103b00b84d67b0 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 11 Jun 2014 10:32:15 +0000 Subject: [PATCH] Detect cases where Newell's Method returns a zero-length vector and make no attempt to normalize it in order to prevent an exception. In this case the face will be flagged as invalid down the road, because its perimeter doesn't span any area. --- src/ifcgeom/IfcGeomFaces.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom/IfcGeomFaces.cpp b/src/ifcgeom/IfcGeomFaces.cpp index d8a6b0b687..eb38faa33e 100644 --- a/src/ifcgeom/IfcGeomFaces.cpp +++ b/src/ifcgeom/IfcGeomFaces.cpp @@ -170,9 +170,12 @@ bool IfcGeom::convert(const Ifc2x3::IfcFace::ptr l, TopoDS_Face& face) { // as the topological face normal the face orientation is // reversed gp_Vec face_normal2(x,y,z); - if ( face_normal1.Dot(face_normal2) < 0 ) { - TopAbs_Orientation o = face.Orientation(); - face.Orientation(o == TopAbs_FORWARD ? TopAbs_REVERSED : TopAbs_FORWARD); + + if (face_normal2.Magnitude() > ALMOST_ZERO) { + if ( face_normal1.Dot(face_normal2) < 0 ) { + TopAbs_Orientation o = face.Orientation(); + face.Orientation(o == TopAbs_FORWARD ? TopAbs_REVERSED : TopAbs_FORWARD); + } } }