Salome HOME
Updated copyright comment
[modules/shaper.git] / src / FeaturesPlugin / Test / TestFillet_History.py
1 # Copyright (C) 2014-2024  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 that the history of Fillet operation works correctly after movement of groups after this Fillet feature:
21 # Faces are modified, edges that were used for fillet are removed
22
23 from salome.shaper import model
24 from ModelAPI import *
25 from GeomAPI import *
26 from SketchAPI 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 SketchLine_1 = Sketch_1.addLine(23.0955987576144, 26.85924638608351, -23.50862068965518, 26.85924638608351)
34 SketchLine_2 = Sketch_1.addLine(-23.50862068965518, 26.85924638608351, -23.50862068965518, -11.11713209726581)
35 SketchLine_3 = Sketch_1.addLine(-23.50862068965518, -11.11713209726581, 23.0955987576144, -11.11713209726581)
36 SketchLine_4 = Sketch_1.addLine(23.0955987576144, -11.11713209726581, 23.0955987576144, 26.85924638608351)
37 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
38 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
39 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
40 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
41 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
42 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
43 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
44 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
45 SketchLine_5 = Sketch_1.addLine(2.024890803123894, -11.11713209726581, 23.0955987576144, 26.85924638608351)
46 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
47 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_6")
48 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_3.result())
49 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_5")
50 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
51 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
52 model.do()
53 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)
54 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")]
55 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
56 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]")]
57 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
58 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]")]
59 Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2)
60 model.do()
61 # move groups after the Fillet
62 Part_1_doc.moveFeature(Group_1.feature(), Fillet_1.feature())
63 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
64 model.end()
65
66 # check groups are correct
67 aFactory = ModelAPI_Session.get().validators()
68 selectionList = Group_1.feature().selectionList("group_list")
69 assert(selectionList.size() == 3)
70 assert(aFactory.validate(Group_1.feature()))
71 for i in range(3):
72   assert(Group_1.groupList().value(i).value().shapeType() == GeomAPI_Shape.FACE)
73
74 selectionList = Group_2.feature().selectionList("group_list")
75 assert(selectionList.size() == 2)
76 assert(aFactory.validate(Group_2.feature()))
77 for i in range(2):
78   assert(Group_2.groupList().value(i).value().shapeType() == GeomAPI_Shape.EDGE)
79
80 assert(model.checkPythonDump())