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