diff --git a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp index 96af048107..7c888187b2 100644 --- a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp +++ b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp @@ -30,7 +30,9 @@ #include #include #include +#include #include +#include #include #include @@ -78,3 +80,33 @@ void FCBRepAlgoAPIHelper::setAutoFuzzy(BRepAlgoAPI_BuilderAlgo* op) { BRepBndLib::Add(it.Value(), bounds); op->SetFuzzyValue(Part::FuzzyHelper::getBooleanFuzzy() * sqrt(bounds.SquareExtent()) * Precision::Confusion()); } + +void FCBRepAlgoAPI_BooleanOperation::Build(const Message_ProgressRange& theRange) { + + if (myOperation==BOPAlgo_CUT && myArguments.Size()==1 && myArguments.First().ShapeType() == TopAbs_COMPOUND) { + myOriginalArguments = myArguments; + myShape = RecursiveCutCompound(myOriginalArguments.First(), theRange); + } else { + return BRepAlgoAPI_BooleanOperation::Build(theRange); + } + +} + +const TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutCompound(const TopoDS_Shape& theArgument, const Message_ProgressRange& theRange) { + BRep_Builder builder; + TopoDS_Compound comp; + builder.MakeCompound(comp); + TopoDS_Iterator it(theArgument); + for (; it.More(); it.Next()) { + TopTools_ListOfShape currentArguments; + currentArguments.Append(it.Value()); + myArguments = currentArguments; + Build(theRange); + if (IsDone()) { + builder.Add(comp, myShape); + } else { + return TopoDS_Shape(); + } + } + return comp; +} diff --git a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h index dcd3451e14..a0e392c00e 100644 --- a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h +++ b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h @@ -49,6 +49,8 @@ public: // set fuzzyness based on size void setAutoFuzzy(); + Standard_EXPORT virtual void Build(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; + protected: //! @name Constructors //! Constructor to perform Boolean operation on only two arguments. @@ -57,5 +59,10 @@ protected: //! @name Constructors const TopoDS_Shape& theS2, const BOPAlgo_Operation theOperation); + +private: + TopTools_ListOfShape myOriginalArguments; + Standard_EXPORT const TopoDS_Shape RecursiveCutCompound(const TopoDS_Shape& theArgument, const Message_ProgressRange& theRange); + }; #endif