From 4cccfd08d3f314d58dcdf5fde62dfc8a053d3fa1 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 13 Oct 2022 09:34:14 +0200 Subject: [PATCH] #671 check for zero magnitude vector in newells method --- src/ifcgeom_schema_agnostic/wire_utils.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom_schema_agnostic/wire_utils.cpp b/src/ifcgeom_schema_agnostic/wire_utils.cpp index 11876e2aa9..5c53233012 100644 --- a/src/ifcgeom_schema_agnostic/wire_utils.cpp +++ b/src/ifcgeom_schema_agnostic/wire_utils.cpp @@ -74,7 +74,13 @@ bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_P return false; } - plane = gp_Pln(center / n, gp_Dir(x, y, z)); + gp_Vec v(x, y, z); + if (v.SquareMagnitude() < eps_ * eps_) { + Logger::Warning("Degenerate face boundary in normal estimation"); + return false; + } + + plane = gp_Pln(center / n, v); exp.Init(wire); for (; exp.More(); exp.Next()) {