diff --git a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp index de6fad06fe..9f6e56ab42 100644 --- a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp +++ b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.cpp @@ -88,7 +88,7 @@ void FCBRepAlgoAPI_BooleanOperation::RecursiveAddArguments(const TopoDS_Shape& t if (it.Value().ShapeType() == TopAbs_COMPOUND) { RecursiveAddArguments(it.Value()); } else { - if (!myArguments.Size()) { + if (myArguments.IsEmpty()) { myArguments.Append(it.Value()); } else { myTools.Append(it.Value()); @@ -102,11 +102,12 @@ void FCBRepAlgoAPI_BooleanOperation::Build() { if (myOperation == BOPAlgo_CUT && myArguments.Size() == 1 && myTools.Size() == 1 && myTools.First().ShapeType() == TopAbs_COMPOUND) { TopTools_ListOfShape myOriginalArguments = myArguments; TopTools_ListOfShape myOriginalTools = myTools; - TopTools_ListOfShape currentTools, currentArguments; + TopTools_ListOfShape currentTools; + TopTools_ListOfShape currentArguments; myArguments = currentArguments; myTools = currentTools; RecursiveAddArguments(myOriginalTools.First()); - if (myTools.Size()) { + if (!myTools.IsEmpty()) { myOperation = BOPAlgo_FUSE; // fuse tools together Build(); myOperation = BOPAlgo_CUT; // restore @@ -130,7 +131,7 @@ void FCBRepAlgoAPI_BooleanOperation::Build() { } } -const TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutCompound(const TopoDS_Shape& theArgument) { +TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutCompound(const TopoDS_Shape& theArgument) { BRep_Builder builder; TopoDS_Compound comp; builder.MakeCompound(comp); @@ -143,7 +144,7 @@ const TopoDS_Shape FCBRepAlgoAPI_BooleanOperation::RecursiveCutCompound(const To if (IsDone()) { builder.Add(comp, myShape); } else { - return TopoDS_Shape(); + return {}; } } return comp; diff --git a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h index 4d1254c4d4..d86a5f0910 100644 --- a/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h +++ b/src/Mod/Part/App/FCBRepAlgoAPI_BooleanOperation.h @@ -49,19 +49,20 @@ public: // set fuzzyness based on size void setAutoFuzzy(); - Standard_EXPORT virtual void Build(); // not an override - real Build() has optionals, sadly type of those optionals that are differs between OCCT versions + // not an override - real Build() has optionals, sadly type of those optionals that are differs between OCCT versions + Standard_EXPORT virtual void Build(); // NOLINT(clang-diagnostic-overloaded-virtual, -Woverloaded-virtual) protected: //! @name Constructors //! Constructor to perform Boolean operation on only two arguments. //! Obsolete Standard_EXPORT FCBRepAlgoAPI_BooleanOperation(const TopoDS_Shape& theS1, - const TopoDS_Shape& theS2, - const BOPAlgo_Operation theOperation); + const TopoDS_Shape& theS2, + BOPAlgo_Operation theOperation); private: - Standard_EXPORT const TopoDS_Shape RecursiveCutCompound(const TopoDS_Shape& theArgument); + Standard_EXPORT TopoDS_Shape RecursiveCutCompound(const TopoDS_Shape& theArgument); Standard_EXPORT void RecursiveAddArguments(const TopoDS_Shape& theArgument); }; #endif diff --git a/src/Mod/Part/parttests/TopoShapeTest.py b/src/Mod/Part/parttests/TopoShapeTest.py index a6a6405e2d..c41e789794 100644 --- a/src/Mod/Part/parttests/TopoShapeTest.py +++ b/src/Mod/Part/parttests/TopoShapeTest.py @@ -774,7 +774,11 @@ class TopoShapeTest(unittest.TestCase, TopoShapeAssertions): self.doc.recompute() cut1 = self.doc.Cut.Shape # Assert elementMap - refkeys = ['Vertex6', 'Vertex5', 'Edge7', 'Edge8', 'Edge9', 'Edge5', 'Edge6', 'Face4', 'Face2', 'Edge1', 'Vertex4', 'Edge4', 'Vertex3', 'Edge2', 'Edge3', 'Face1', 'Face5', 'Face3', 'Vertex1', 'Vertex2'] + refkeys = [ + 'Vertex6', 'Vertex5', 'Edge7', 'Edge8', 'Edge9', 'Edge5', 'Edge6', 'Face4', 'Face2', + 'Edge1', 'Vertex4', 'Edge4', 'Vertex3', 'Edge2', 'Edge3', 'Face1', 'Face5', 'Face3', + 'Vertex1', 'Vertex2' + ] if cut1.ElementMapVersion != "": # Should be '4' as of Mar 2023. self.assertKeysInMap(cut1.ElementReverseMap, refkeys ) self.assertEqual(len(cut1.ElementReverseMap.keys()),len(refkeys)) @@ -790,7 +794,14 @@ class TopoShapeTest(unittest.TestCase, TopoShapeAssertions): self.doc.recompute() cut1 = self.doc.Cut.Shape # Assert elementMap - refkeys = ['Vertex3', 'Vertex4', 'Vertex8', 'Vertex10', 'Vertex7', 'Vertex9', 'Vertex13', 'Vertex14', 'Vertex18', 'Vertex20', 'Vertex17', 'Vertex19', 'Edge3', 'Edge15', 'Edge9', 'Edge12', 'Edge13', 'Edge11', 'Edge8', 'Edge17', 'Edge18', 'Edge19', 'Edge30', 'Edge24', 'Edge27', 'Edge28', 'Edge29', 'Edge25', 'Edge26', 'Edge23', 'Face7', 'Face4', 'Face8', 'Face14', 'Face13', 'Face11', 'Face12', 'Face10', 'Edge22', 'Vertex12', 'Edge20', 'Vertex11', 'Edge21', 'Edge16', 'Face9', 'Vertex15', 'Vertex16'] + refkeys = [ + 'Vertex3', 'Vertex4', 'Vertex8', 'Vertex10', 'Vertex7', 'Vertex9', 'Vertex13', + 'Vertex14', 'Vertex18', 'Vertex20', 'Vertex17', 'Vertex19', 'Edge3', 'Edge15', 'Edge9', + 'Edge12', 'Edge13', 'Edge11', 'Edge8', 'Edge17', 'Edge18', 'Edge19', 'Edge30', 'Edge24', + 'Edge27', 'Edge28', 'Edge29', 'Edge25', 'Edge26', 'Edge23', 'Face7', 'Face4', 'Face8', + 'Face14', 'Face13', 'Face11', 'Face12', 'Face10', 'Edge22', 'Vertex12', 'Edge20', + 'Vertex11', 'Edge21', 'Edge16', 'Face9', 'Vertex15', 'Vertex16' + ] if cut1.ElementMapVersion != "": # Should be '4' as of Mar 2023. self.assertKeysInMap(cut1.ElementReverseMap, refkeys ) self.assertEqual(len(cut1.ElementReverseMap.keys()),len(refkeys))