]> SALOME platform Git repositories - modules/shaper.git/blob - src/CollectionPlugin/Test/TestGroupMove06.py
Salome HOME
Update names of modified faces of the transformation features (Translation, Rotation...
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove06.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.
22 # Copied boxes are involved to Fill operation.
23 # Check the groups of initial boxes moved to the end contain the corresponding
24 # results, but divided.
25
26 from salome.shaper import model
27
28 model.begin()
29 partSet = model.moduleDocument()
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
33 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]"))
34 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Axis_1"), 10, 2)
35 Group_1 = model.addGroup(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_1")])
36 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")]
37 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
38 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]")]
39 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
40 Group_4 = model.addGroup(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_2")])
41 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")]
42 Group_5 = model.addGroup(Part_1_doc, Group_5_objects)
43 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]")]
44 Group_6 = model.addGroup(Part_1_doc, Group_6_objects)
45 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"))
46 Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_1")], [model.selection("SOLID", "LinearCopy_1_1_2"), model.selection("FACE", "Plane_1")])
47 model.do()
48 # move groups to the end
49 Part_1_doc.moveFeature(Group_1.feature(), Fill_1.feature())
50 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
51 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
52 Part_1_doc.moveFeature(Group_4.feature(), Group_3.feature())
53 Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature())
54 Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature())
55 model.end()
56
57 from ModelAPI import *
58
59 aFactory = ModelAPI_Session.get().validators()
60
61 # groups related to original box should be split
62 selectionList = Group_1.feature().selectionList("group_list")
63 assert(selectionList.size() == 3)
64 assert(aFactory.validate(Group_1.feature()))
65
66 selectionList = Group_2.feature().selectionList("group_list")
67 assert(selectionList.size() == 13)
68 assert(aFactory.validate(Group_2.feature()))
69
70 selectionList = Group_3.feature().selectionList("group_list")
71 assert(selectionList.size() == 19)
72 assert(aFactory.validate(Group_3.feature()))
73
74 # groups related to the copied box should contain only the elements connected with the original box
75 selectionList = Group_4.feature().selectionList("group_list")
76 assert(selectionList.size() == 1)
77 assert(aFactory.validate(Group_4.feature()))
78
79 selectionList = Group_5.feature().selectionList("group_list")
80 assert(selectionList.size() == 3)
81 assert(aFactory.validate(Group_5.feature()))
82
83 selectionList = Group_6.feature().selectionList("group_list")
84 assert(selectionList.size() == 3)
85 assert(aFactory.validate(Group_6.feature()))
86
87
88 model.begin()
89 Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Fill_1_1_2/Generated_Edge&Plane_1/Plane_1&Box_1_1/Top"), model.selection("EDGE", "[Fill_1_1_2/Modified_Face&Box_1_1/Right][(Fill_1_1_2/Modified_Face&Box_1_1/Right)(Fill_1_1_2/Modified_Face&Plane_1/Plane_1)(Fill_1_1_2/Modified_Face&Box_1_1/Front)(Fill_1_1_2/Modified_Face&Box_1_1/Top)2(Fill_1_1_2/Modified_Face&Box_1_1/Left)2]")])
90 Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_1_1_2")], [model.selection("FACE", "Filling_1_1")])
91 model.do()
92 # move groups to the end once again
93 Part_1_doc.moveFeature(Group_1.feature(), Fill_2.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() == 4)
104 assert(aFactory.validate(Group_1.feature()))
105
106 selectionList = Group_2.feature().selectionList("group_list")
107 assert(selectionList.size() == 16)
108 assert(aFactory.validate(Group_2.feature()))
109
110 selectionList = Group_3.feature().selectionList("group_list")
111 # one of edges should disappear, due to its belonging to the face of the filling
112 assert(selectionList.size() == 18)
113 assert(aFactory.validate(Group_3.feature()))
114
115 # groups related to the copied box should be split correspondingly
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() == 6)
122 assert(aFactory.validate(Group_5.feature()))
123
124 selectionList = Group_6.feature().selectionList("group_list")
125 assert(selectionList.size() == 5)
126 assert(aFactory.validate(Group_6.feature()))
127
128 assert(model.checkPythonDump())