Salome HOME
Rename tests for moving groups
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove05.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 # Faces and edges of a box has been collected to groups. After that, the box has been copied.
23 # Check that groups moved to the end contain corresponding results.
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/Right][Box_1_1/Bottom]"), 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/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")]
36 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
37 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 15, 2)
38 model.do()
39 # move groups to the end
40 Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_1.feature())
41 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
42 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
43 model.end()
44
45 from ModelAPI import *
46
47 aFactory = ModelAPI_Session.get().validators()
48 # check group 1: all solids in compound should be selected
49 selectionList = Group_1.feature().selectionList("group_list")
50 assert(selectionList.size() == 2)
51 assert(aFactory.validate(Group_1.feature()))
52 # check group 2: number of faces is multiplied twice than original
53 selectionList = Group_2.feature().selectionList("group_list")
54 assert(selectionList.size() == 12)
55 assert(aFactory.validate(Group_2.feature()))
56 # check group 3: number of edges is multiplied twice than original
57 selectionList = Group_3.feature().selectionList("group_list")
58 assert(selectionList.size() == 24)
59 assert(aFactory.validate(Group_3.feature()))
60
61 model.begin()
62 LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 15, 2, model.selection("EDGE", "PartSet/OZ"), 15, 2)
63 # move groups to the end
64 Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_2.feature())
65 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
66 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
67 model.end()
68
69 # check group 1: all solids in compound should be selected
70 selectionList = Group_1.feature().selectionList("group_list")
71 assert(selectionList.size() == 8)
72 assert(aFactory.validate(Group_1.feature()))
73 # check group 2: number of faces is multiplied twice than original
74 selectionList = Group_2.feature().selectionList("group_list")
75 assert(selectionList.size() == 48)
76 assert(aFactory.validate(Group_2.feature()))
77 # check group 3: number of edges is multiplied twice than original
78 selectionList = Group_3.feature().selectionList("group_list")
79 assert(selectionList.size() == 96)
80 assert(aFactory.validate(Group_3.feature()))
81
82 model.begin()
83 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_1_1"), model.selection("SOLID", "LinearCopy_2_1_1_2")], model.selection("EDGE", "PartSet/OZ"), 2)
84 # move groups to the end
85 Part_1_doc.moveFeature(Group_1.feature(), AngularCopy_1.feature())
86 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
87 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
88 model.end()
89
90 # check group 1: all solids in compound should be selected
91 selectionList = Group_1.feature().selectionList("group_list")
92 assert(selectionList.size() == 4)
93 assert(aFactory.validate(Group_1.feature()))
94 # check group 2: number of faces is multiplied twice than original
95 selectionList = Group_2.feature().selectionList("group_list")
96 assert(selectionList.size() == 24)
97 assert(aFactory.validate(Group_2.feature()))
98 # check group 3: number of edges is multiplied twice than original
99 selectionList = Group_3.feature().selectionList("group_list")
100 assert(selectionList.size() == 48)
101 assert(aFactory.validate(Group_3.feature()))
102
103 assert(model.checkPythonDump())