]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/TestSelectionCircleCenter.py
Salome HOME
Fix for #19707 : fatal error gp_Dir() input vector has zero norm when loading python...
[modules/shaper.git] / src / ModelAPI / Test / TestSelectionCircleCenter.py
1 # Copyright (C) 2014-2020  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 from SketchAPI import *
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchLine_1 = Sketch_1.addLine(15, 10, -10, 10)
30 SketchLine_2 = Sketch_1.addLine(-10, 10, -10, -10)
31 SketchLine_3 = Sketch_1.addLine(-10, -10, 20, -10)
32 SketchLine_4 = Sketch_1.addLine(20, -10, 20, 5)
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
34 SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2")
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
36 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
37 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
38 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
39 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
40 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
41 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
42 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
43 SketchArc_1 = Sketch_1.addArc(15, 5, 20, 5, 15, 10, False)
44 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_4.endPoint())
45 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
46 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint())
47 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
48 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result())
49 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_4.result())
50 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 20)
51 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_3.result(), 30)
52 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 5)
53 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
54 SketchProjection_1.setName("SketchProjection_3")
55 SketchProjection_1.result().setName("SketchProjection_3")
56 SketchPoint_1 = SketchProjection_1.createdFeature()
57 SketchPoint_1.setName("SketchPoint_3")
58 SketchPoint_1.result().setName("SketchPoint_3")
59 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_2.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates(), 10)
60 SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_2.endPoint(), SketchAPI_Point(SketchPoint_1).coordinates(), 10)
61 model.do()
62 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchArc_1_2f")], model.selection(), 10, 0)
63 Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]")], 10)
64 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Fillet_1_1/MF:Fillet&Extrusion_1_1/To_Face"))
65 SketchLine_5 = Sketch_2.addLine(15, 5, 0, 0)
66 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[Fillet_1_1/MF:Fillet&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2]__cc"), False)
67 SketchProjection_2.setName("SketchProjection_1")
68 SketchProjection_2.result().setName("SketchProjection_1")
69 SketchPoint_2 = SketchProjection_2.createdFeature()
70 SketchPoint_2.setName("SketchPoint_1")
71 SketchPoint_2.result().setName("SketchPoint_1")
72 SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchPoint_2.result())
73 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
74 SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected][Fillet_1_1/MF:Fillet&Extrusion_1_1/To_Face]__cc"), False)
75 SketchProjection_3.setName("SketchProjection_2")
76 SketchProjection_3.result().setName("SketchProjection_2")
77 SketchPoint_3 = SketchProjection_3.createdFeature()
78 SketchPoint_3.setName("SketchPoint_2")
79 SketchPoint_3.result().setName("SketchPoint_2")
80 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchPoint_3.result())
81 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
82 model.end()
83 # check that the second line-point was created on the point, not arc
84 assert(len(SketchPoint_3.feature().results()) == 1)
85 assert(SketchPoint_3.feature().firstResult().shape().isVertex())