Salome HOME
Copyright update 2022
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove06.py
1 # Copyright (C) 2014-2022  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.
21 # Copied boxes are involved to Split operation.
22 # Check the groups of initial boxes 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 Axis_4 = model.addAxis(Part_1_doc, 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/Top]"))
33 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Axis_1"), 10, 2)
34 Group_1 = model.addGroup(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_1")])
35 Group_2_objects = [model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Back"), model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Top"), model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Right"), model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Left"), model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom"), model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Front")]
36 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
37 Group_3_objects = [model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right]"), model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]")]
38 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
39 Group_4 = model.addGroup(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_2")])
40 Group_5_objects = [model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Back"), model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Top"), model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Right"), model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Left"), model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Bottom"), model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Front")]
41 Group_5 = model.addGroup(Part_1_doc, Group_5_objects)
42 Group_6_objects = [model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Back][LinearCopy_1_1_2/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Back][LinearCopy_1_1_2/MF:Translated&Box_1_1/Right]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Back][LinearCopy_1_1_2/MF:Translated&Box_1_1/Left]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Back][LinearCopy_1_1_2/MF:Translated&Box_1_1/Top]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Right][LinearCopy_1_1_2/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Left][LinearCopy_1_1_2/MF:Translated&Box_1_1/Top]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Left][LinearCopy_1_1_2/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Right][LinearCopy_1_1_2/MF:Translated&Box_1_1/Top]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Front][LinearCopy_1_1_2/MF:Translated&Box_1_1/Bottom]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Front][LinearCopy_1_1_2/MF:Translated&Box_1_1/Left]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Front][LinearCopy_1_1_2/MF:Translated&Box_1_1/Right]"), model.selection("EDGE", "[LinearCopy_1_1_2/MF:Translated&Box_1_1/Front][LinearCopy_1_1_2/MF:Translated&Box_1_1/Top]")]
43 Group_6 = model.addGroup(Part_1_doc, Group_6_objects)
44 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Left"), model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Right"))
45 Split_1 = model.addSplit(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_1")], [model.selection("SOLID", "LinearCopy_1_1_2"), model.selection("FACE", "Plane_1")])
46 model.do()
47 # move groups to the end
48 Part_1_doc.moveFeature(Group_1.feature(), Split_1.feature())
49 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
50 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
51 Part_1_doc.moveFeature(Group_4.feature(), Group_3.feature())
52 Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature())
53 Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature())
54 model.end()
55
56 from ModelAPI import *
57
58 aFactory = ModelAPI_Session.get().validators()
59
60 # groups related to original box should be split
61 selectionList = Group_1.feature().selectionList("group_list")
62 assert(selectionList.size() == 3)
63 assert(aFactory.validate(Group_1.feature()))
64
65 selectionList = Group_2.feature().selectionList("group_list")
66 assert(selectionList.size() == 13)
67 assert(aFactory.validate(Group_2.feature()))
68
69 selectionList = Group_3.feature().selectionList("group_list")
70 assert(selectionList.size() == 19)
71 assert(aFactory.validate(Group_3.feature()))
72
73 # groups related to the copied box should contain only the elements connected with the original box
74 selectionList = Group_4.feature().selectionList("group_list")
75 assert(selectionList.size() == 1)
76 assert(aFactory.validate(Group_4.feature()))
77
78 selectionList = Group_5.feature().selectionList("group_list")
79 assert(selectionList.size() == 3)
80 assert(aFactory.validate(Group_5.feature()))
81
82 selectionList = Group_6.feature().selectionList("group_list")
83 assert(selectionList.size() == 3)
84 assert(aFactory.validate(Group_6.feature()))
85
86
87 model.begin()
88 Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Split_1_1_2/Generated_Edge&Plane_1/Plane_1&Box_1_1/Top"), model.selection("EDGE", "[Split_1_1_2/Modified_Face&Box_1_1/Right][(Split_1_1_2/Modified_Face&Box_1_1/Right)(Split_1_1_2/Modified_Face&Plane_1/Plane_1)(Split_1_1_2/Modified_Face&Box_1_1/Front)(Split_1_1_2/Modified_Face&Box_1_1/Top)2(Split_1_1_2/Modified_Face&Box_1_1/Left)2]")])
89 Split_2 = model.addSplit(Part_1_doc, [model.selection("SOLID", "Split_1_1_2")], [model.selection("FACE", "Filling_1_1")])
90 model.do()
91 # move groups to the end once again
92 Part_1_doc.moveFeature(Group_1.feature(), Split_2.feature())
93 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
94 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
95 Part_1_doc.moveFeature(Group_4.feature(), Group_3.feature())
96 Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature())
97 Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature())
98 model.end()
99
100 # groups related to original box should be split
101 selectionList = Group_1.feature().selectionList("group_list")
102 assert(selectionList.size() == 4)
103 assert(aFactory.validate(Group_1.feature()))
104
105 selectionList = Group_2.feature().selectionList("group_list")
106 assert(selectionList.size() == 16)
107 assert(aFactory.validate(Group_2.feature()))
108
109 selectionList = Group_3.feature().selectionList("group_list")
110 # one of edges should disappear, due to its belonging to the face of the filling
111 assert(selectionList.size() == 18)
112 assert(aFactory.validate(Group_3.feature()))
113
114 # groups related to the copied box should be split correspondingly
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() == 6)
121 assert(aFactory.validate(Group_5.feature()))
122
123 selectionList = Group_6.feature().selectionList("group_list")
124 assert(selectionList.size() == 5)
125 assert(aFactory.validate(Group_6.feature()))
126
127 assert(model.checkPythonDump())