From 7df94a906db3084c2d7773067fc275f73cc10a2d Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 30 Aug 2022 13:31:26 +0200 Subject: [PATCH] #2305 fix cone boolean op --- src/ifcgeom/IfcGeom.cpp | 6 ++++-- src/ifcgeom_schema_agnostic/Kernel.cpp | 14 ++++++++++++++ src/ifcgeom_schema_agnostic/boolean_utils.cpp | 12 +++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom/IfcGeom.cpp b/src/ifcgeom/IfcGeom.cpp index d2959f2ff7..9e649bf015 100644 --- a/src/ifcgeom/IfcGeom.cpp +++ b/src/ifcgeom/IfcGeom.cpp @@ -4038,7 +4038,8 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a_input, const TopTo a = util::unify(a_input, fuzziness * 1000.); - Logger::Notice( + Logger::Message( + Logger::LOG_DEBUG, "Simplified operand A from "s + std::to_string(count(a_input, TopAbs_FACE)) + " to "s + @@ -4049,7 +4050,8 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a_input, const TopTo TopTools_ListIteratorOfListOfShape it(b_input); for (; it.More(); it.Next()) { b.Append(util::unify(it.Value(), fuzziness)); - Logger::Notice( + Logger::Message( + Logger::LOG_DEBUG, "Simplified operand B from "s + std::to_string(count(it.Value(), TopAbs_FACE)) + " to "s + diff --git a/src/ifcgeom_schema_agnostic/Kernel.cpp b/src/ifcgeom_schema_agnostic/Kernel.cpp index 50c9689ada..0310a40146 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.cpp +++ b/src/ifcgeom_schema_agnostic/Kernel.cpp @@ -5,6 +5,10 @@ #include #include +#include +#include +#include + #include #include @@ -258,6 +262,16 @@ bool IfcGeom::Kernel::is_manifold(const TopoDS_Shape& a) { TopExp::MapShapesAndAncestors(a, TopAbs_EDGE, TopAbs_FACE, map); for (int i = 1; i <= map.Extent(); ++i) { + const TopoDS_Edge& e = TopoDS::Edge(map.FindKey(i)); + + TopoDS_Vertex v0, v1; + TopExp::Vertices(e, v0, v1); + const bool degenerate = !v0.IsNull() && !v1.IsNull() && v0.IsSame(v1); + + if (degenerate) { + continue; + } + if (map.FindFromIndex(i).Extent() != 2) { return false; } diff --git a/src/ifcgeom_schema_agnostic/boolean_utils.cpp b/src/ifcgeom_schema_agnostic/boolean_utils.cpp index 7fc03ef803..b8757aecb6 100644 --- a/src/ifcgeom_schema_agnostic/boolean_utils.cpp +++ b/src/ifcgeom_schema_agnostic/boolean_utils.cpp @@ -45,8 +45,18 @@ double IfcGeom::util::min_edge_length(const TopoDS_Shape & a) { double min_edge_len = std::numeric_limits::infinity(); TopExp_Explorer exp(a, TopAbs_EDGE); for (; exp.More(); exp.Next()) { + const TopoDS_Edge& e = TopoDS::Edge(exp.Current()); + + TopoDS_Vertex v0, v1; + TopExp::Vertices(e, v0, v1); + if (!v0.IsNull() && !v1.IsNull() && v0.IsSame(v1)) { + // Don't consider a 3d-degenerate edge (for example cone apex) + // in calculating overall shape min edge length. + continue; + } + GProp_GProps prop; - BRepGProp::LinearProperties(exp.Current(), prop); + BRepGProp::LinearProperties(e, prop); double l = prop.Mass(); if (l < min_edge_len) { min_edge_len = l;