From fa84e1284318d01574428f45e588a61e0bb713ef Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 3 Oct 2019 15:47:51 +0300 Subject: [PATCH] Issue #3014: Partition fails --- src/FeaturesPlugin/CMakeLists.txt | 1 + .../FeaturesPlugin_Partition.cpp | 6 +++ src/FeaturesPlugin/Test/Test3014.py | 50 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/FeaturesPlugin/Test/Test3014.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 74564bde1..7640e539a 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -489,6 +489,7 @@ ADD_UNIT_TESTS(TestExtrusion.py Test2854.py Test2878.py Test2971.py + Test3014.py TestBooleanCommon_MultiLevelCompound_v0_1.py TestBooleanCommon_MultiLevelCompound_v0_2.py TestBooleanCommon_MultiLevelCompound_v20190506_1.py diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index 96052010d..48c7141a2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -153,6 +153,12 @@ void FeaturesPlugin_Partition::execute() keepUnusedSubsOfCompound(aFirstShape, anObjects, ObjectHierarchy(), aMakeShapeList); if (anIt.more()) { + if (aResultCompound->shapeType() != GeomAPI_Shape::COMPOUND) { + // put the shape into compound + ListOfShape aShapes; + aShapes.push_back(aResultCompound); + aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); + } std::shared_ptr aBuilder(new GeomAlgoAPI_ShapeBuilder); for (; anIt.more(); anIt.next()) aBuilder->add(aResultCompound, anIt.current()); diff --git a/src/FeaturesPlugin/Test/Test3014.py b/src/FeaturesPlugin/Test/Test3014.py new file mode 100644 index 000000000..711b12e64 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test3014.py @@ -0,0 +1,50 @@ +# Copyright (C) 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 GeomAPI import * +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "nb", "10") +model.addParameter(Part_1_doc, "h", "20") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(0, 55.86212361331221, 9.333219356250011) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center()) +SketchMultiRotation_1 = Sketch_1.addRotation([SketchCircle_1.results()[1]], SketchAPI_Line(SketchLine_1).startPoint(), 360, "nb", True) +[SketchCircle_2, SketchCircle_3, SketchCircle_4, SketchCircle_5, SketchCircle_6, SketchCircle_7, SketchCircle_8, SketchCircle_9, SketchCircle_10] = SketchMultiRotation_1.rotated() +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), "h", 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_4/To_Face"), "h/2", True) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_1"), model.selection("COMPOUND", "all-in-Extrusion_1")], 20190506) +model.end() + +assert(Partition_1.feature().error() == "") + +model.testNbResults(Partition_1, 1) +model.testNbSubResults(Partition_1, [10]) +model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [20]) + +assert(model.checkPythonDump()) -- 2.39.2