From 9a4d3e706a60f9520c664bd9c6bc72a7bf6704df Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 13 Oct 2022 09:22:28 +0200 Subject: [PATCH] #671 api in faceset_helper to obtain multiple bounds from single loop in case of intersections --- src/ifcgeom/IfcGeom.h | 3 ++- src/ifcgeom/faceset_helper.cpp | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index d9a79353ec..ddc02374eb 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -150,7 +150,8 @@ private: bool edge(int A, int B, TopoDS_Edge& e); - bool wire(const LP& loop, TopoDS_Wire& wire); + bool wire(const LP& loop, TopoDS_Wire& wire); + bool wires(const LP& loop, TopTools_ListOfShape& wires); }; double deflection_tolerance; diff --git a/src/ifcgeom/faceset_helper.cpp b/src/ifcgeom/faceset_helper.cpp index 9d0da57869..56d69ba7ee 100644 --- a/src/ifcgeom/faceset_helper.cpp +++ b/src/ifcgeom/faceset_helper.cpp @@ -243,10 +243,21 @@ bool IfcGeom::Kernel::faceset_helper::edge(int A, int B, TopoDS_Edge& e) } template -bool IfcGeom::Kernel::faceset_helper::wire(const LP& loop, TopoDS_Wire& wire) { +bool IfcGeom::Kernel::faceset_helper::wire(const LP& loop, TopoDS_Wire& w) { + TopTools_ListOfShape ws; + if (!wires(loop, ws)) { + return false; + } + util::select_largest(ws, w); + return true; +} + +template +bool IfcGeom::Kernel::faceset_helper::wires(const LP& loop, TopTools_ListOfShape& wires) { if (duplicates_.find(util::conditional_address_of(loop)) != duplicates_.end()) { return false; } + TopoDS_Wire wire; BRep_Builder builder; builder.MakeWire(wire); int count = 0; @@ -264,10 +275,12 @@ bool IfcGeom::Kernel::faceset_helper::wire(const LP& loop, TopoDS_Wire& wire.Closed(true); TopTools_ListOfShape results; - if (kernel_->getValue(GV_NO_WIRE_INTERSECTION_CHECK) == 0. && util::wire_intersections(wire, results, kernel_->get_wire_intersection_tolerance(wire), kernel_->getValue(IfcGeom::Kernel::GV_PRECISION))) { + if (kernel_->getValue(GV_NO_WIRE_INTERSECTION_CHECK) < 0. && util::wire_intersections(wire, results, kernel_->get_wire_intersection_tolerance(wire), kernel_->getValue(IfcGeom::Kernel::GV_PRECISION))) { Logger::Warning("Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); - util::select_largest(results, wire); non_manifold_ = true; + wires = results; + } else { + wires.Append(wire); } return true;