@@ -3066,6 +3066,30 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a, const TopoDS_Shap
30663066#else
30673067
30683068namespace {
3069+ TopTools_ListOfShape copy_operand (const TopTools_ListOfShape& l) {
3070+ #if OCC_VERSION_HEX < 0x70000
3071+ TopTools_ListOfShape r;
3072+ TopTools_ListIteratorOfListOfShape it (l);
3073+ for (; it.More (); it.Next ()) {
3074+ r.Append (BRepBuilderAPI_Copy (it.Value ()));
3075+ }
3076+ return r;
3077+ #else
3078+ // On OCCT 7.0 and higher BRepAlgoAPI_BuilderAlgo::SetNonDestructive(true) is
3079+ // called. Not entirely sure on the behaviour before 7.0, so overcautiously
3080+ // create copies.
3081+ return l;
3082+ #endif
3083+ }
3084+
3085+ TopoDS_Shape copy_operand (const TopoDS_Shape& s) {
3086+ #if OCC_VERSION_HEX < 0x70000
3087+ return BRepBuilderAPI_Copy (s);
3088+ #else
3089+ return s;
3090+ #endif
3091+ }
3092+
30693093 double min_edge_length (const TopoDS_Shape& a) {
30703094 double min_edge_len = std::numeric_limits<double >::infinity ();
30713095 TopExp_Explorer exp (a, TopAbs_EDGE);
@@ -3101,11 +3125,13 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a, const TopTools_Li
31013125 const double fuzz = (std::min)(min_edge_len / 3 ., fuzziness);
31023126
31033127 TopTools_ListOfShape s1s;
3104- s1s.Append (a);
3128+ s1s.Append (copy_operand (a));
3129+ #if OCC_VERSION_HEX >= 0x70000
31053130 builder->SetNonDestructive (true );
3131+ #endif
31063132 builder->SetFuzzyValue (fuzz);
31073133 builder->SetArguments (s1s);
3108- builder->SetTools (b );
3134+ builder->SetTools (copy_operand (b) );
31093135 builder->Build ();
31103136 if (builder->IsDone ()) {
31113137 TopoDS_Shape r = *builder;
0 commit comments