From 622853d73deca7f0784c1955315e7ecf243980b2 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 19 Sep 2018 16:42:34 +0200 Subject: [PATCH] Filter boolean subtraction operands by intial bounding box test --- src/ifcgeom/IfcGeomFunctions.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index d9de6aa121..02a145dd3c 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -3362,17 +3362,35 @@ namespace { return true; } + void bounding_box_overlap(double p, const TopoDS_Shape& a, const TopTools_ListOfShape& b, TopTools_ListOfShape& c) { + Bnd_Box A; + BRepBndLib::Add(a, A); + + TopTools_ListIteratorOfListOfShape it(b); + for (; it.More(); it.Next()) { + Bnd_Box B; + BRepBndLib::Add(it.Value(), B); + + if (A.Distance(B) < p) { + c.Append(it.Value()); + } + } + } } -bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a, const TopTools_ListOfShape& b, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { +bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a, const TopTools_ListOfShape& b_, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { bool success = false; BRepAlgoAPI_BooleanOperation* builder; + TopTools_ListOfShape b; if (op == BOPAlgo_CUT) { builder = new BRepAlgoAPI_Cut(); + bounding_box_overlap(getValue(GV_PRECISION), a, b_, b); } else if (op == BOPAlgo_COMMON) { builder = new BRepAlgoAPI_Common(); + bounding_box_overlap(getValue(GV_PRECISION), a, b_, b); } else if (op == BOPAlgo_FUSE) { builder = new BRepAlgoAPI_Fuse(); + b = b_; } else { return false; }