Salome HOME
Fix for the issue #3033: ExtrusionCut error
authormpv <mpv@opencascade.com>
Fri, 11 Oct 2019 07:12:01 +0000 (10:12 +0300)
committermpv <mpv@opencascade.com>
Fri, 11 Oct 2019 07:12:01 +0000 (10:12 +0300)
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
src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp
src/FeaturesPlugin/Test/Test3033.py [new file with mode: 0644]

index 81a1128546dd173c56e99d7d2a1f0f6d02b85ffd..2634bb5dc6fa92eb60b3e92dc4f83c422bb10eba 100644 (file)
@@ -532,4 +532,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test17261.py
                Test17281.py
                TestChamfer.py
+               Test3033.py
 )
index d10c82d852ff728393fc144d6cfcf34e01ffda99..cfe002fb0b1ff080ad3d279ac92825f87d85b8e5 100644 (file)
@@ -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<GeomAlgoAPI_PaveFiller> 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<GeomAlgoAPI_PaveFiller> 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 (file)
index 0000000..eaf0c6b
--- /dev/null
@@ -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())