Salome HOME
Copyright update 2022
[modules/shaper.git] / src / BuildPlugin / Test / TestCompound_History.py
1 # Copyright (C) 2014-2022  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 email : webmaster.salome@opencascade.com
18 #
19
20 # Test that the history of compound works correctly after movement of groups after this compound feature
21
22 from salome.shaper import model
23 from ModelAPI import *
24 from GeomAPI import *
25
26 model.begin()
27 partSet = model.moduleDocument()
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
31 SketchPoint_1 = Sketch_1.addPoint(-19.03078817733991, 40.92241379310347)
32 SketchLine_1 = Sketch_1.addLine(-0.7463054187192111, 38.55911330049261, -18.03571428571429, 28.48399014778325)
33 SketchCircle_1 = Sketch_1.addCircle(-2.238916256157633, 23.13546798029557, 5.523556488740459)
34 model.do()
35 Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1")])
36 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")])
37 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0)
38 Group_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Edge_1_1/Modified_Vertex&Sketch_1/SketchLine_1_EndVertex"), model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]")]
39 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
40 Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]")])
41 Group_3 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")])
42 Compound_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), model.selection("SOLID", "Extrusion_1_1")]
43 Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
44 model.do()
45 # move groups after the compound
46 Part_1_doc.moveFeature(Group_1.feature(), Compound_1.feature())
47 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
48 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
49 model.end()
50
51 # check groups are correct
52 aFactory = ModelAPI_Session.get().validators()
53 selectionList = Group_1.feature().selectionList("group_list")
54 assert(selectionList.size() == 3)
55 assert(aFactory.validate(Group_1.feature()))
56 for i in range(3):
57   assert(Group_1.groupList().value(i).value().shapeType() == GeomAPI_Shape.VERTEX)
58
59 selectionList = Group_2.feature().selectionList("group_list")
60 assert(selectionList.size() == 2)
61 assert(aFactory.validate(Group_2.feature()))
62 for i in range(2):
63   assert(Group_2.groupList().value(i).value().shapeType() == GeomAPI_Shape.EDGE)
64
65 selectionList = Group_3.feature().selectionList("group_list")
66 assert(selectionList.size() == 1)
67 assert(aFactory.validate(Group_3.feature()))
68 assert(Group_3.groupList().value(0).value().shapeType() == GeomAPI_Shape.SOLID)
69
70 assert(model.checkPythonDump())