From 6f6175c8c5de0d6ea75e4e121494bd2c00fed981 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 15 Feb 2024 14:04:12 +0500 Subject: [PATCH] IfcGeom::util::is_manifold not to consider circles as manifold #4283 Investigating I've found that SvgSerializer with prefiltering enabled (after #3359) was ignoring representations that consisted only of a circle curves since it was considered manifold by `IfcGeom::util::is_manifold(s)` in https://github.com/IfcOpenShell/IfcOpenShell/blob/0e0678b926c34f2c28e69558959d3b29e51a50ec/src/serializers/SvgSerializer.h#L433 and topology explorer `TopExp_Explorer exp(s, TopAbs_FACE)` ignored that shape as it had no faces. IfcGeom::util::is_manifold considered a full circle manifold since it was ignoring edges with `v0.IsSame(v1)` considering them manifold but in case of a full circle, circle is a TopoDS_Edge with both vertices at the same location but it also has a circle curve and I've added check for that. --- src/ifcgeom_schema_agnostic/base_utils.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom_schema_agnostic/base_utils.cpp b/src/ifcgeom_schema_agnostic/base_utils.cpp index e9eff396d4..9f2ac8946d 100644 --- a/src/ifcgeom_schema_agnostic/base_utils.cpp +++ b/src/ifcgeom_schema_agnostic/base_utils.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -106,10 +107,17 @@ bool IfcGeom::util::is_manifold(const TopoDS_Shape& a) { TopoDS_Vertex v0, v1; TopExp::Vertices(e, v0, v1); - const bool degenerate = !v0.IsNull() && !v1.IsNull() && v0.IsSame(v1); - if (degenerate) { - continue; + // consider degenerate edges as manifold + if (!v0.IsNull() && !v1.IsNull()) { + if (v0.IsSame(v1)) { + // full circle curves have both verts match but still may be non-manifold + double dF, dL; + Handle(Geom_Curve) curve = BRep_Tool::Curve(TopoDS::Edge(e), dF, dL); + if (curve.IsNull() || dynamic_cast(curve.get()) == nullptr) { + continue; + } + } } if (map.FindFromIndex(i).Extent() != 2) {