Salome HOME
Merge remote-tracking branch 'remotes/origin/HigherLevelObjectsHistory'
[modules/shaper.git] / src / FeaturesPlugin / Test / TestFillet_History.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 that the history of Fillet operation works correctly after movement of groups after this Fillet feature:
22 # Faces are modified, edges that were used for fillet are removed
23
24 # -*- coding: utf-8 -*-
25
26 from salome.shaper import model
27 from ModelAPI import *
28 from GeomAPI import *
29 from SketchAPI import *
30
31 model.begin()
32 partSet = model.moduleDocument()
33 Part_1 = model.addPart(partSet)
34 Part_1_doc = Part_1.document()
35 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
36 SketchLine_1 = Sketch_1.addLine(23.0955987576144, 26.85924638608351, -23.50862068965518, 26.85924638608351)
37 SketchLine_2 = Sketch_1.addLine(-23.50862068965518, 26.85924638608351, -23.50862068965518, -11.11713209726581)
38 SketchLine_3 = Sketch_1.addLine(-23.50862068965518, -11.11713209726581, 23.0955987576144, -11.11713209726581)
39 SketchLine_4 = Sketch_1.addLine(23.0955987576144, -11.11713209726581, 23.0955987576144, 26.85924638608351)
40 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
41 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
42 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
43 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
44 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
45 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
46 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
47 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
48 SketchLine_5 = Sketch_1.addLine(2.024890803123894, -11.11713209726581, 23.0955987576144, 26.85924638608351)
49 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
50 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_6")
51 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_3.result())
52 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_5")
53 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
54 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
55 model.do()
56 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3f-SketchLine_4f-SketchLine_5r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_5f")], model.selection(), 10, 0)
57 Group_1_objects = [model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_2/To_Face"), model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_3")]
58 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
59 Group_2_objects = [model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1_2/To_Face]")]
60 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
61 Fillet_1_objects = [model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_2/From_Face]")]
62 Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2)
63 model.do()
64 # move groups after the Fillet
65 Part_1_doc.moveFeature(Group_1.feature(), Fillet_1.feature())
66 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
67 model.end()
68
69 # check groups are correct
70 aFactory = ModelAPI_Session.get().validators()
71 selectionList = Group_1.feature().selectionList("group_list")
72 assert(selectionList.size() == 3)
73 assert(aFactory.validate(Group_1.feature()))
74 for i in range(3):
75   assert(Group_1.groupList().value(i).value().shapeType() == GeomAPI_Shape.FACE)
76
77 selectionList = Group_2.feature().selectionList("group_list")
78 assert(selectionList.size() == 2)
79 assert(aFactory.validate(Group_2.feature()))
80 for i in range(2):
81   assert(Group_2.groupList().value(i).value().shapeType() == GeomAPI_Shape.EDGE)
82
83 assert(model.checkPythonDump())