From 4c40fc1629b37230a3d7ad823f23d064ffbaee92 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 17 Jan 2022 13:56:21 +0100 Subject: [PATCH] #1985 consolidate and correct shell count checks in tree --- src/ifcgeom/IfcGeomTree.h | 54 +++++++++++++++------------------------ 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/src/ifcgeom/IfcGeomTree.h b/src/ifcgeom/IfcGeomTree.h index b08fce56fb..eb586c27e0 100644 --- a/src/ifcgeom/IfcGeomTree.h +++ b/src/ifcgeom/IfcGeomTree.h @@ -109,18 +109,26 @@ namespace IfcGeom { } return dss.Value() <= extend; } - } else if (completely_within) { - BRepAlgoAPI_Cut cut(B, A); - if (cut.IsDone()) { - if (IfcGeom::Kernel::count(cut.Shape(), TopAbs_SHELL) == 0) { - return true; - } - } } else { - BRepAlgoAPI_Common common(A, B); - if (common.IsDone()) { - if (IfcGeom::Kernel::count(common.Shape(), TopAbs_SHELL) > 0) { - return true; + if (IfcGeom::Kernel::count(A, TopAbs_SHELL) == 0 || + IfcGeom::Kernel::count(B, TopAbs_SHELL) == 0) + { + return false; + } + + if (completely_within) { + BRepAlgoAPI_Cut cut(B, A); + if (cut.IsDone()) { + if (IfcGeom::Kernel::count(cut.Shape(), TopAbs_SHELL) == 0) { + return true; + } + } + } else { + BRepAlgoAPI_Common common(A, B); + if (common.IsDone()) { + if (IfcGeom::Kernel::count(common.Shape(), TopAbs_SHELL) > 0) { + return true; + } } } } @@ -209,21 +217,14 @@ namespace IfcGeom { return ts; } - std::vector ts_filtered; - const TopoDS_Shape& A = shapes_.find(t)->second; - if (IfcGeom::Kernel::count(A, TopAbs_SHELL) == 0) { - return ts_filtered; - } + std::vector ts_filtered; ts_filtered.reserve(ts.size()); typename std::vector::const_iterator it = ts.begin(); for (it = ts.begin(); it != ts.end(); ++it) { const TopoDS_Shape& B = shapes_.find(*it)->second; - if (IfcGeom::Kernel::count(B, TopAbs_SHELL) == 0) { - continue; - } if (test(A, B, completely_within, extend)) { ts_filtered.push_back(*it); @@ -241,16 +242,7 @@ namespace IfcGeom { BRepBndLib::AddClose(s, bb); bb.SetGap(bb.GetGap() + extend); - std::vector ts; - - if (extend < 0.) { - // Shell are only required when we do the boolean based intersection check - if (IfcGeom::Kernel::count(s, TopAbs_SHELL) == 0) { - return ts; - } - } - - ts = select_box(bb, completely_within); + std::vector ts = select_box(bb, completely_within); if (ts.empty()) { return ts; @@ -263,10 +255,6 @@ namespace IfcGeom { for (it = ts.begin(); it != ts.end(); ++it) { const TopoDS_Shape& B = shapes_.find(*it)->second; - if (IfcGeom::Kernel::count(B, TopAbs_SHELL) == 0) { - continue; - } - if (test(s, B, completely_within, extend)) { ts_filtered.push_back(*it); }