From fa195194c69b30be426bd2870dbae741317b7a03 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 22 Mar 2014 10:48:29 +0000 Subject: [PATCH] Prevent a construction error when trying to normalize a zero length normal during triangulation, which happens very, very rarely. --- src/ifcgeom/IfcGeomObjects.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/IfcGeomObjects.cpp b/src/ifcgeom/IfcGeomObjects.cpp index 15ee85cdef..495d9abc36 100644 --- a/src/ifcgeom/IfcGeomObjects.cpp +++ b/src/ifcgeom/IfcGeomObjects.cpp @@ -175,8 +175,11 @@ IfcGeomObjects::IfcRepresentationTriangulation::IfcRepresentationTriangulation(c const gp_Pnt2d& uv = uvs(i); gp_Pnt p; gp_Vec normal_direction; - prop.Normal(uv.X(),uv.Y(),p,normal_direction); - gp_Dir normal = gp_Dir(normal_direction.XYZ() * rotation_matrix); + prop.Normal(uv.X(),uv.Y(),p,normal_direction); + gp_Vec normal(0., 0., 0.); + if (normal_direction.Magnitude() > ALMOST_ZERO) { + normal = gp_Dir(normal_direction.XYZ() * rotation_matrix); + } _normals.push_back((float)normal.X()); _normals.push_back((float)normal.Y()); _normals.push_back((float)normal.Z());