]> SALOME platform Git repositories - modules/shaper.git/blob - src/CollectionPlugin/Test/TestGroupMove18.py
Salome HOME
Merge branch 'V9_2_2_BR'
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove18.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. Shell operation.
22 # Check the initial groups moved to the end contain the corresponding results.
23
24 from salome.shaper import model
25 from ModelAPI import *
26
27 aFactory = ModelAPI_Session.get().validators()
28
29 def moveGroupsAndVerify(thePart, theLastFeature, theRefNumInGroups):
30     # move groups to the end
31     model.begin()
32     LastFeature = theLastFeature
33     for i in range(thePart.size("Groups")):
34         GroupFeature = thePart.feature(objectToResult(thePart.object("Groups", 0))) # move always the very first group
35         Part_1_doc.moveFeature(GroupFeature, LastFeature)
36         LastFeature = GroupFeature
37     model.end()
38
39     a = 0
40     for i in range(thePart.size("Groups")):
41         GroupFeature = thePart.feature(objectToResult(thePart.object("Groups", i)))
42         assert(aFactory.validate(GroupFeature))
43         assert(GroupFeature.selectionList("group_list").size() == theRefNumInGroups[a])
44         a = a + 1
45
46
47 model.begin()
48 partSet = model.moduleDocument()
49 Part_1 = model.addPart(partSet)
50 Part_1_doc = Part_1.document()
51 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
52 Group_1_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")]
53 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
54 Group_2_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]")]
55 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
56 Group_3_objects = [model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), 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/Bottom]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Bottom]")]
57 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
58 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
59 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Back"))
60 Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")]
61 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
62 Shell_1_objects = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Back"), model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Left"), model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top"), model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Back"), model.selection("FACE", "Partition_1_1_4/Modified_Face&Box_1_1/Front"), model.selection("FACE", "Partition_1_1_4/Modified_Face&Box_1_1/Right")]
63 Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
64 model.do()
65 model.end()
66
67 num_in_groups = [6, 13, 6]
68 moveGroupsAndVerify(Part_1_doc, Shell_1.feature(), num_in_groups)
69
70 assert(model.checkPythonDump())