Salome HOME
bos #20661 EDF 22847 - Move to the end
authormpv <mpv@opencascade.com>
Wed, 3 Feb 2021 08:41:47 +0000 (11:41 +0300)
committermpv <mpv@opencascade.com>
Wed, 3 Feb 2021 08:41:47 +0000 (11:41 +0300)
Fixed the RemoveSubShape feature naming structure: sub-bodies of the main result should be stored as "modification",  not "primitives".

src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp
src/FeaturesPlugin/Test/Test22847.py [new file with mode: 0644]

index 1dce791a91c48cc0b07a8e657e6e0f197598d6e1..ae6ccc7ceb29442c65895d7992c7afbe69a4b1ef 100644 (file)
@@ -688,4 +688,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test20245_2.py
                Test20245_3.py
                Test20247.py
+               Test22847.py
 )
index e00351b73037df9e32d8d5417f07a22356040868..f34e5242f8f3685338f4fce1fc8bda226d8c51d2 100644 (file)
@@ -290,7 +290,9 @@ void FeaturesPlugin_RemoveSubShapes::execute()
 
   // Store result.
   ResultBodyPtr aResultBody = document()->createBody(data());
-  aResultBody->storeModified(aBaseShape, aResultShape);
+  std::list<GeomShapePtr> anOldShapes;
+  anOldShapes.push_back(aBaseShape);
+  aResultBody->storeModified(anOldShapes, aResultShape, aMakeShapeList);
   for (std::set<GeomAPI_Shape::ShapeType>::iterator aTypeIter = aTypes.begin();
        aTypeIter != aTypes.end();
        ++aTypeIter)
diff --git a/src/FeaturesPlugin/Test/Test22847.py b/src/FeaturesPlugin/Test/Test22847.py
new file mode 100644 (file)
index 0000000..9efcf3d
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright (C) 2020  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()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(22, 23, 60, 70)
+SketchLine_2 = Sketch_1.addLine(60, 70, 90, 23)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(90, 23, 22, 23)
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
+Sketch_1.setHorizontal(SketchLine_3.result())
+SketchLine_4 = Sketch_1.addLine(60, 72, 54, 23)
+Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_3.result())
+Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_2.startPoint())
+model.do()
+
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), 10, 0, "Faces|Wires")
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OY"), 60, 2, model.selection("EDGE", "PartSet/OX"), 75, 2, keepSubResults = True)
+
+### Create Group
+Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "LinearCopy_1_1_1_2/MF:Translated&Sketch_1/SketchLine_2")])
+
+### Create Remove_SubShapes
+Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPOUND", "LinearCopy_1_1"))
+Remove_SubShapes_1.setSubShapesToRemove([model.selection("SOLID", "LinearCopy_1_1_4_2")])
+model.end()
+
+# Move the group to the end of history
+model.begin()
+Part_1_doc.moveFeature(Group_1.feature(), Remove_SubShapes_1.feature())
+model.end()
+
+# check that all groups are correct
+from ModelAPI import *
+aFactory = ModelAPI_Session.get().validators()
+
+assert(aFactory.validate(Group_1.feature()))
+assert(Group_1.groupList().size() == 1)
+assert(Group_1.groupList().value(0).value().shapeTypeStr() == "FACE")
+assert(len(Group_1.groupList().value(0).namingName()) > 0)
+
+assert(model.checkPythonDump())