From 4cfb2f102797cf563107c1939e48e6fcd4d7e9d0 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 15 Jun 2018 12:39:29 +0200 Subject: [PATCH] SetNonDestructive does not exist prior to OCCT 7.0 --- src/ifcgeom/IfcGeomFunctions.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index d5f8f98d02..64ab7e59fa 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -3066,6 +3066,30 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a, const TopoDS_Shap #else namespace { + TopTools_ListOfShape copy_operand(const TopTools_ListOfShape& l) { +#if OCC_VERSION_HEX < 0x70000 + TopTools_ListOfShape r; + TopTools_ListIteratorOfListOfShape it(l); + for (; it.More(); it.Next()) { + r.Append(BRepBuilderAPI_Copy(it.Value())); + } + return r; +#else + // On OCCT 7.0 and higher BRepAlgoAPI_BuilderAlgo::SetNonDestructive(true) is + // called. Not entirely sure on the behaviour before 7.0, so overcautiously + // create copies. + return l; +#endif + } + + TopoDS_Shape copy_operand(const TopoDS_Shape& s) { +#if OCC_VERSION_HEX < 0x70000 + return BRepBuilderAPI_Copy(s); +#else + return s; +#endif + } + double min_edge_length(const TopoDS_Shape& a) { double min_edge_len = std::numeric_limits::infinity(); TopExp_Explorer exp(a, TopAbs_EDGE); @@ -3101,11 +3125,13 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a, const TopTools_Li const double fuzz = (std::min)(min_edge_len / 3., fuzziness); TopTools_ListOfShape s1s; - s1s.Append(a); + s1s.Append(copy_operand(a)); +#if OCC_VERSION_HEX >= 0x70000 builder->SetNonDestructive(true); +#endif builder->SetFuzzyValue(fuzz); builder->SetArguments(s1s); - builder->SetTools(b); + builder->SetTools(copy_operand(b)); builder->Build(); if (builder->IsDone()) { TopoDS_Shape r = *builder;