Salome HOME
Update unit-tests according to changing of the face modification history
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroup2.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 splitted edges in the group are still correct edges in the group
21 # Based on the CEA report mail 04.12.2018, page 4
22
23 # -*- coding: utf-8 -*-
24
25 from SketchAPI import *
26 from ModelAPI import *
27 from GeomAPI import *
28 from salome.shaper import model
29
30 model.begin()
31 partSet = model.moduleDocument()
32 Part_1 = model.addPart(partSet)
33 Part_1_doc = Part_1.document()
34 param_p = model.addParameter(Part_1_doc, "r", "15")
35 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
36 SketchArc_1 = Sketch_1.addArc(7.5, 7.5, 22.5, 7.499992770095306, 7.499999582962127, 22.5, False)
37 SketchLine_1 = Sketch_1.addLine(7.499999582962127, 22.5, 7.499999582962127, 52.5)
38 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint())
39 SketchLine_2 = Sketch_1.addLine(22.5, 7.499992770095306, 52.5, 7.499992770095306)
40 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint())
41 SketchArc_2 = Sketch_1.addArc(7.5, 7.5, 52.5, 7.499992770095306, 7.499999582962127, 52.5, False)
42 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.center(), SketchArc_2.center())
43 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_2.startPoint())
44 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_1.endPoint())
45 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
46 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
47 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), "r*2")
48 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result())
49 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "r")
50 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], "3*r")
51 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
52 SketchPoint_1 = SketchProjection_1.createdFeature()
53 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchArc_2.center(), "r/2")
54 SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchArc_1.center(), "r/2")
55 model.do()
56 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchArc_2_2f-SketchLine_1r-SketchArc_1_2r")])
57 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchArc_2_2f-SketchLine_1r-SketchArc_1_2r"))
58 SketchCircle_1 = Sketch_2.addCircle(27.71638597484288, 11.4805029721516, 3)
59 SketchCircle_2 = Sketch_2.addCircle(45.03912720992525, 18.6558173277981, 3)
60 SketchLine_3 = Sketch_2.addLine(0, 0, 45.03912720992525, 18.6558173277981)
61 SketchLine_3.setAuxiliary(True)
62 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
63 SketchPoint_2 = SketchProjection_2.createdFeature()
64 SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_3.startPoint(), SketchPoint_2.result())
65 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchLine_3.endPoint())
66 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_3.result(), SketchCircle_1.center())
67 SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_1.results()[1], "r/5")
68 SketchConstraintRadius_4 = Sketch_2.setRadius(SketchCircle_2.results()[1], "r/5")
69 SketchConstraintDistance_1 = Sketch_2.setDistance(SketchLine_3.startPoint(), SketchCircle_1.center(), "2*r", True)
70 SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_1.center(), SketchLine_3.endPoint(), "r*1.25", True)
71 SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False)
72 SketchLine_4 = SketchProjection_3.createdFeature()
73 SketchConstraintAngle_1 = Sketch_2.setAngle(SketchLine_4.result(), SketchLine_3.result(), "r*1.5")
74 model.do()
75 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 10, 0)
76 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], model.selection("EDGE", "PartSet/OZ"), "90.-r*3", 2)
77 Cut_1 = model.addCut(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("COMPOUND", "AngularCopy_1_1")])
78 Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchArc_1_2")])
79 Group_1.setName("edge_int")
80 Group_1.result().setName("edge_int")
81 Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchLine_2")])
82 Group_2.setName("edge_bottom")
83 Group_2.result().setName("edge_bottom")
84 Group_3 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchLine_1")])
85 Group_3.setName("edge_left")
86 Group_3.result().setName("edge_left")
87 Group_4 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchArc_2_2")])
88 Group_4.setName("edge_ext")
89 Group_4.result().setName("edge_ext")
90 model.do()
91 # change parameter "p" to make one ylinder split bottom and left edges
92 param_p.setValue(12)
93 model.end()
94
95 # check that int and ext groups are still edges, bottom and left groups are compounds of edges
96 aFactory = ModelAPI_Session.get().validators()
97
98 for group in [Group_1, Group_4]:
99   assert(aFactory.validate(group.feature()))
100   selectionList = group.feature().selectionList("group_list")
101   assert(selectionList.size() == 1)
102   assert(group.groupList().value(0).value().shapeType() == GeomAPI_Shape.EDGE)
103
104 for group in [Group_2, Group_3]:
105   assert(aFactory.validate(group.feature()))
106   selectionList = group.feature().selectionList("group_list")
107   assert(selectionList.size() == 2)
108   assert(group.groupList().value(0).value().shapeType() == GeomAPI_Shape.EDGE)
109   assert(group.groupList().value(1).value().shapeType() == GeomAPI_Shape.EDGE)
110
111 assert(model.checkPythonDump())