Salome HOME
98d67b3aecf5f17580eed1d5b35cdb7b7c64871c
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove07.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.
21 # Faces and edges of a box has been collected to groups. After that, the box has been symmetried.
22 # Check that groups moved to the end contain corresponding results.
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 Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("FACE", "Box_1_1/Left"), False)
37 model.do()
38 # move groups to the end
39 Part_1_doc.moveFeature(Group_1.feature(), Symmetry_1.feature())
40 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
41 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
42 model.end()
43
44 from ModelAPI import *
45
46 aFactory = ModelAPI_Session.get().validators()
47 # check group 1: solids should be selected
48 selectionList = Group_1.feature().selectionList("group_list")
49 assert(selectionList.size() == 1)
50 assert(aFactory.validate(Group_1.feature()))
51 # check group 2: number of faces is the same
52 selectionList = Group_2.feature().selectionList("group_list")
53 assert(selectionList.size() == 6)
54 assert(aFactory.validate(Group_2.feature()))
55 # check group 3: number of edges is the same
56 selectionList = Group_3.feature().selectionList("group_list")
57 assert(selectionList.size() == 12)
58 assert(aFactory.validate(Group_3.feature()))
59
60 model.begin()
61 Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Symmetry_1_1")], model.selection("VERTEX", "[Symmetry_1_1/MF:Symmetried&Box_1_1/Front][Symmetry_1_1/MF:Symmetried&Box_1_1/Left][Symmetry_1_1/MF:Symmetried&Box_1_1/Bottom]"), True)
62 model.do()
63 # move groups to the end
64 Part_1_doc.moveFeature(Group_1.feature(), Symmetry_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() == 2)
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() == 12)
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() == 24)
80 assert(aFactory.validate(Group_3.feature()))
81
82 assert(model.checkPythonDump())