Salome HOME
ef298d1c5a4f7910f887bf77d81a18dfdf809878
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove16.py
1 # Copyright (C) 2014-2021  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # Test of deep nested results history. Compsolid operation.
21 # Check the initial groups moved to the end contain the corresponding results.
22
23 from salome.shaper import model
24 from ModelAPI import *
25
26 aFactory = ModelAPI_Session.get().validators()
27
28 def moveGroupsAndVerify(thePart, theLastFeature, theRefNumInGroups):
29     # move groups to the end
30     model.begin()
31     LastFeature = theLastFeature
32     for i in range(thePart.size("Groups")):
33         GroupFeature = thePart.feature(objectToResult(thePart.object("Groups", 0))) # move always the very first group
34         Part_1_doc.moveFeature(GroupFeature, LastFeature)
35         LastFeature = GroupFeature
36     model.end()
37
38     a = 0
39     for i in range(thePart.size("Groups")):
40         GroupFeature = thePart.feature(objectToResult(thePart.object("Groups", i)))
41         assert(aFactory.validate(GroupFeature))
42         assert(GroupFeature.selectionList("group_list").size() == theRefNumInGroups[a])
43         a = a + 1
44
45
46 model.begin()
47 partSet = model.moduleDocument()
48 Part_1 = model.addPart(partSet)
49 Part_1_doc = Part_1.document()
50 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
51 Group_1 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Box_1_1")])
52 Group_2_objects = [model.selection("FACE", "Box_1_1/Back"), model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Right"), model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Bottom"), model.selection("FACE", "Box_1_1/Front")]
53 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
54 Group_3_objects = [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")]
55 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
56 Group_4_objects = [model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Bottom]")]
57 Group_4 = model.addGroup(Part_1_doc, Group_4_objects)
58 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), model.selection("FACE", "Box_1_1/Top"))
59 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
60 SketchCircle_1 = Sketch_1.addCircle(3.528942405489753, -5.938455554641368, 11.4411217503133)
61 model.do()
62 CompSolid_1 = model.addCompSolid(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")])
63 model.do()
64 model.end()
65
66 num_in_groups = [2, 10, 16, 8]
67 moveGroupsAndVerify(Part_1_doc, CompSolid_1.feature(), num_in_groups)
68
69 assert(model.checkPythonDump())