Salome HOME
Rename tests for moving groups
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove08.py
1 ## Copyright (C) 2014-2017  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 # Test of deep nested results history. Fillet operation.
22 # Check the groups of initial solids moved to the end contain the corresponding
23 # results, but divided.
24
25 from salome.shaper import model
26
27 model.begin()
28 partSet = model.moduleDocument()
29 Part_1 = model.addPart(partSet)
30 Part_1_doc = Part_1.document()
31 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
32 Group_1 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Box_1_1")])
33 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")]
34 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
35 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]")]
36 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
37 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
38 Group_4 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")])
39 Group_5_objects = [model.selection("FACE", "Cylinder_1_1/Face_1"), model.selection("FACE", "Cylinder_1_1/Face_2"), model.selection("FACE", "Cylinder_1_1/Face_3")]
40 Group_5 = model.addGroup(Part_1_doc, Group_5_objects)
41 Group_6_objects = [model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]"), model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_3]"), model.selection("EDGE", "([Cylinder_1_1/Face_1][Cylinder_1_1/Face_2])([Cylinder_1_1/Face_1][Cylinder_1_1/Face_3])")]
42 Group_6 = model.addGroup(Part_1_doc, Group_6_objects)
43 Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")], 2)
44 model.do()
45 # move groups to the end
46 Part_1_doc.moveFeature(Group_1.feature(), Fillet_1.feature())
47 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
48 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
49 model.end()
50
51 from ModelAPI import *
52
53 aFactory = ModelAPI_Session.get().validators()
54
55 # groups related to original box should be split
56 selectionList = Group_1.feature().selectionList("group_list")
57 assert(selectionList.size() == 1)
58 assert(aFactory.validate(Group_1.feature()))
59
60 selectionList = Group_2.feature().selectionList("group_list")
61 assert(selectionList.size() == 6)
62 assert(aFactory.validate(Group_2.feature()))
63
64 selectionList = Group_3.feature().selectionList("group_list")
65 assert(selectionList.size() == 11)
66 assert(aFactory.validate(Group_3.feature()))
67
68 model.begin()
69 Fillet_2 = model.addFillet(Part_1_doc, [model.selection("FACE", "Cylinder_1_1/Face_2")], 2)
70 model.do()
71 # move groups to the end
72 Part_1_doc.moveFeature(Group_4.feature(), Fillet_2.feature())
73 Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature())
74 Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature())
75 model.end()
76
77 # groups related to original cylinder should be split
78 selectionList = Group_4.feature().selectionList("group_list")
79 assert(selectionList.size() == 1)
80 assert(aFactory.validate(Group_4.feature()))
81
82 selectionList = Group_5.feature().selectionList("group_list")
83 assert(selectionList.size() == 3)
84 assert(aFactory.validate(Group_5.feature()))
85
86 selectionList = Group_6.feature().selectionList("group_list")
87 assert(selectionList.size() == 2) # edge selected for the fillet become removed
88 assert(aFactory.validate(Group_6.feature()))
89
90 model.begin()
91 Fillet_3 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Fillet_1_1/MF:Fillet_Face&Box_1_1/Front][Fillet_1_1/MF:Fillet_Face&Box_1_1/Left]")], 1, 2)
92 model.do()
93 # move groups to the end
94 Part_1_doc.moveFeature(Group_1.feature(), Fillet_3.feature())
95 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
96 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
97 Part_1_doc.moveFeature(Group_4.feature(), Group_3.feature())
98 Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature())
99 Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature())
100 model.end()
101
102 # groups related to original box should be split
103 selectionList = Group_1.feature().selectionList("group_list")
104 assert(selectionList.size() == 1)
105 assert(aFactory.validate(Group_1.feature()))
106
107 selectionList = Group_2.feature().selectionList("group_list")
108 assert(selectionList.size() == 6)
109 assert(aFactory.validate(Group_2.feature()))
110
111 selectionList = Group_3.feature().selectionList("group_list")
112 assert(selectionList.size() == 9)
113 assert(aFactory.validate(Group_3.feature()))
114
115 # groups related to original cylinder should stay untouched
116 selectionList = Group_4.feature().selectionList("group_list")
117 assert(selectionList.size() == 1)
118 assert(aFactory.validate(Group_4.feature()))
119
120 selectionList = Group_5.feature().selectionList("group_list")
121 assert(selectionList.size() == 3)
122 assert(aFactory.validate(Group_5.feature()))
123
124 selectionList = Group_6.feature().selectionList("group_list")
125 assert(selectionList.size() == 2)
126 assert(aFactory.validate(Group_6.feature()))
127
128 assert(model.checkPythonDump())