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