From feb897fa3e1a0dd3dd9d8d6b6f714ab21e715fef Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 11 Oct 2019 10:12:01 +0300 Subject: [PATCH] Fix for the issue #3033: ExtrusionCut error If the result of cut is a whole result, don't call PaveFiller which provides an error if there is only one simple argument. --- src/FeaturesPlugin/CMakeLists.txt | 1 + .../FeaturesPlugin_CompositeBoolean.cpp | 21 +++++---- src/FeaturesPlugin/Test/Test3033.py | 44 +++++++++++++++++++ 3 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 src/FeaturesPlugin/Test/Test3033.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 7b5ba9fb7..05957293a 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -536,4 +536,5 @@ ADD_UNIT_TESTS(TestExtrusion.py Test17261.py Test17281.py TestChamfer.py + Test3033.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp index d10c82d85..cfe002fb0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp @@ -225,17 +225,20 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools, aMakeShapeList->appendAlgo(aBoolAlgo); // Add result to not used solids from compsolid. - aShapesToAdd.push_back(aBoolAlgo->shape()); - std::shared_ptr aFillerAlgo( - new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); - if(!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) { - myFeature->setError("Error: PaveFiller algorithm failed."); - return false; + GeomShapePtr aBoolRes = aBoolAlgo->shape(); + if (!aShapesToAdd.empty()) { + aShapesToAdd.push_back(aBoolRes); + std::shared_ptr aFillerAlgo( + new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); + if(!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) { + myFeature->setError("Error: PaveFiller algorithm failed."); + return false; + } + aBoolRes = aFillerAlgo->shape(); + aMakeShapeList->appendAlgo(aFillerAlgo); } - aMakeShapeList->appendAlgo(aFillerAlgo); - - if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo->shape()) > 1.e-27) { + if(GeomAlgoAPI_ShapeTools::volume(aBoolRes) > 1.e-27) { theObjects.push_back(aCompSolid); theMakeShapes.push_back(aMakeShapeList); } diff --git a/src/FeaturesPlugin/Test/Test3033.py b/src/FeaturesPlugin/Test/Test3033.py new file mode 100644 index 000000000..eaf0c6b77 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test3033.py @@ -0,0 +1,44 @@ +# Copyright (C) 2014-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(10, 25, 7) +SketchCircle_2 = Sketch_1.addCircle(10, 25, 3) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchCircle_2.center()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchCircle_2_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")], model.selection(), 10, 0) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 10, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1_1/To_Face")) +SketchCircle_3 = Sketch_2.addCircle(2, 30, 10) +ExtrusionCut_1.setNestedSketch(Sketch_2) +model.end() + +# check the extrusion-cut result is correct +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(ExtrusionCut_1.feature())) +model.testNbResults(ExtrusionCut_1, 1) + +assert(model.checkPythonDump()) -- 2.39.2