From 6e8252e832436ac73cd78c3971f7e215f1347e12 Mon Sep 17 00:00:00 2001 From: Eric Price Date: Sun, 27 Oct 2024 22:16:14 +0100 Subject: [PATCH] fix #17497 --- .../App/FCBRepAlgoAPI_BooleanOperation.cpp | 35 ++++++++++++++++--- .../Part/App/FCBRepAlgoAPI_BooleanOperation.h | 3 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp index 7c888187b2..6e6a069ad8 100644 --- a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp +++ b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp @@ -83,13 +83,19 @@ void FCBRepAlgoAPIHelper::setAutoFuzzy(BRepAlgoAPI_BuilderAlgo* op) { void FCBRepAlgoAPI_BooleanOperation::Build(const Message_ProgressRange& theRange) { - if (myOperation==BOPAlgo_CUT && myArguments.Size()==1 && myArguments.First().ShapeType() == TopAbs_COMPOUND) { - myOriginalArguments = myArguments; + if (myOperation==BOPAlgo_CUT && myArguments.Size()==1 && myTools.Size()==1 && myTools.First().ShapeType() == TopAbs_COMPOUND) { + TopTools_ListOfShape myOriginalTools = myTools; + TopTools_ListOfShape myOriginalArguments = myArguments; + myShape = RecursiveCutByCompound(myOriginalArguments.First(), myOriginalTools.First(), theRange); + myArguments = myOriginalArguments; + myTools = myOriginalTools; + } else if (myOperation==BOPAlgo_CUT && myArguments.Size()==1 && myArguments.First().ShapeType() == TopAbs_COMPOUND) { + TopTools_ListOfShape myOriginalArguments = myArguments; myShape = RecursiveCutCompound(myOriginalArguments.First(), theRange); + myArguments = myOriginalArguments; } else { - return BRepAlgoAPI_BooleanOperation::Build(theRange); + BRepAlgoAPI_BooleanOperation::Build(theRange); } - } const TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutCompound(const TopoDS_Shape& theArgument, const Message_ProgressRange& theRange) { @@ -110,3 +116,24 @@ const TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutCompound(const To } return comp; } + + +const TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutByCompound(const TopoDS_Shape& theArgument, const TopoDS_Shape& theTool, const Message_ProgressRange& theRange) { + TopoDS_Shape result = theArgument; + TopoDS_Iterator it(theTool); + for (; it.More(); it.Next()) { + TopTools_ListOfShape currentArguments; + TopTools_ListOfShape currentTools; + currentArguments.Append(result); + currentTools.Append(it.Value()); + myArguments = currentArguments; + myTools = currentTools; + Build(theRange); + if (IsDone()) { + result = myShape; + } else { + return TopoDS_Shape(); + } + } + return result; +} diff --git a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h index a0e392c00e..5c90d02218 100644 --- a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h +++ b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h @@ -61,8 +61,7 @@ protected: //! @name Constructors private: - TopTools_ListOfShape myOriginalArguments; Standard_EXPORT const TopoDS_Shape RecursiveCutCompound(const TopoDS_Shape& theArgument, const Message_ProgressRange& theRange); - + Standard_EXPORT const TopoDS_Shape RecursiveCutByCompound(const TopoDS_Shape& theArgument, const TopoDS_Shape& theTool, const Message_ProgressRange& theRange); }; #endif