Salome HOME
Rename tests for moving groups
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove07.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 symmetried.
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/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 Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("FACE", "Box_1_1/Left"), False)
38 model.do()
39 # move groups to the end
40 Part_1_doc.moveFeature(Group_1.feature(), Symmetry_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: solids should be selected
49 selectionList = Group_1.feature().selectionList("group_list")
50 assert(selectionList.size() == 1)
51 assert(aFactory.validate(Group_1.feature()))
52 # check group 2: number of faces is the same
53 selectionList = Group_2.feature().selectionList("group_list")
54 assert(selectionList.size() == 6)
55 assert(aFactory.validate(Group_2.feature()))
56 # check group 3: number of edges is the same
57 selectionList = Group_3.feature().selectionList("group_list")
58 assert(selectionList.size() == 12)
59 assert(aFactory.validate(Group_3.feature()))
60
61 model.begin()
62 Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Symmetry_1_1")], model.selection("VERTEX", "[Symmetry_1_1/MF:Symmetried_Face&Box_1_1/Front][Symmetry_1_1/MF:Symmetried_Face&Box_1_1/Left][Symmetry_1_1/MF:Symmetried_Face&Box_1_1/Bottom]"), True)
63 model.do()
64 # move groups to the end
65 Part_1_doc.moveFeature(Group_1.feature(), Symmetry_2.feature())
66 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
67 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
68 model.end()
69
70 # check group 1: all solids in compound should be selected
71 selectionList = Group_1.feature().selectionList("group_list")
72 assert(selectionList.size() == 2)
73 assert(aFactory.validate(Group_1.feature()))
74 # check group 2: number of faces is multiplied twice than original
75 selectionList = Group_2.feature().selectionList("group_list")
76 assert(selectionList.size() == 12)
77 assert(aFactory.validate(Group_2.feature()))
78 # check group 3: number of edges is multiplied twice than original
79 selectionList = Group_3.feature().selectionList("group_list")
80 assert(selectionList.size() == 24)
81 assert(aFactory.validate(Group_3.feature()))
82
83 assert(model.checkPythonDump())