Salome HOME
The fix based on DBC mail 04.03.2019. If the selected solid was not modified by the...
[modules/shaper.git] / src / BuildPlugin / Test / TestCompound_History.py
1 # Copyright (C) 2014-2019  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 # -*- coding: utf-8 -*-
23
24 from salome.shaper import model
25 from ModelAPI import *
26 from GeomAPI import *
27
28 model.begin()
29 partSet = model.moduleDocument()
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
33 SketchPoint_1 = Sketch_1.addPoint(-19.03078817733991, 40.92241379310347)
34 SketchLine_1 = Sketch_1.addLine(-0.7463054187192111, 38.55911330049261, -18.03571428571429, 28.48399014778325)
35 SketchCircle_1 = Sketch_1.addCircle(-2.238916256157633, 23.13546798029557, 5.523556488740459)
36 model.do()
37 Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1")])
38 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")])
39 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0)
40 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]")]
41 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
42 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]")])
43 Group_3 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")])
44 Compound_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), model.selection("SOLID", "Extrusion_1_1")]
45 Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
46 model.do()
47 # move groups after the compound
48 Part_1_doc.moveFeature(Group_1.feature(), Compound_1.feature())
49 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
50 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
51 model.end()
52
53 # check groups are correct
54 aFactory = ModelAPI_Session.get().validators()
55 selectionList = Group_1.feature().selectionList("group_list")
56 assert(selectionList.size() == 3)
57 assert(aFactory.validate(Group_1.feature()))
58 for i in range(3):
59   assert(Group_1.groupList().value(i).value().shapeType() == GeomAPI_Shape.VERTEX)
60
61 selectionList = Group_2.feature().selectionList("group_list")
62 assert(selectionList.size() == 2)
63 assert(aFactory.validate(Group_2.feature()))
64 for i in range(2):
65   assert(Group_2.groupList().value(i).value().shapeType() == GeomAPI_Shape.EDGE)
66
67 selectionList = Group_3.feature().selectionList("group_list")
68 assert(selectionList.size() == 1)
69 assert(aFactory.validate(Group_3.feature()))
70 assert(Group_3.groupList().value(0).value().shapeType() == GeomAPI_Shape.SOLID)
71
72 assert(model.checkPythonDump())