Salome HOME
Copyright update 2022
[modules/shaper.git] / src / SketchPlugin / Test / Test2894.py
1 # Copyright (C) 2019-2022  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 """
21     Test2894.py
22     Test case for issue #2894 "SIGSEGV in trim after double-click"
23 """
24
25 from SketchAPI import *
26
27 from salome.shaper import model
28
29 model.begin()
30 partSet = model.moduleDocument()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
34 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
35 SketchPoint_1 = SketchProjection_1.createdFeature()
36 SketchLine_1 = Sketch_1.addLine(5.899967103122234, 12, -6.100032896877766, 12)
37 SketchLine_2 = Sketch_1.addLine(-6.100032896877766, 12, -6.100032896877766, 7.282829028407098)
38 SketchLine_3 = Sketch_1.addLine(5.899967103122234, 8.178211638264205, 5.899967103122234, 12)
39 SketchLine_3.setName("SketchLine_4")
40 SketchLine_3.result().setName("SketchLine_4")
41 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_1.startPoint())
42 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
43 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
44 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
45 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result())
46 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 12)
47 SketchArc_1 = Sketch_1.addArc(0, 0, -6.100032896877766, 7.282829028407098, -5.830951894845431, -7.499999999999899, False)
48 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center())
49 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 9.5)
50 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.startPoint())
51 SketchLine_4 = Sketch_1.addLine(11, -7.5, 5.830951894845414, -7.49999999999991)
52 SketchLine_4.setName("SketchLine_5")
53 SketchLine_4.result().setName("SketchLine_5")
54 SketchLine_5 = Sketch_1.addLine(-11, -7.5, -11, -10)
55 SketchLine_5.setName("SketchLine_6")
56 SketchLine_5.result().setName("SketchLine_6")
57 SketchLine_6 = Sketch_1.addLine(-11, -10, 11, -10)
58 SketchLine_6.setName("SketchLine_7")
59 SketchLine_6.result().setName("SketchLine_7")
60 SketchLine_7 = Sketch_1.addLine(11, -10, 11, -7.5)
61 SketchLine_7.setName("SketchLine_8")
62 SketchLine_7.result().setName("SketchLine_8")
63 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_4.startPoint())
64 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
65 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
66 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result())
67 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_5.result())
68 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result())
69 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_7.result())
70 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_5.result(), 2.5)
71 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_6.result(), 22)
72 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_6.result(), 22, True)
73 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_6.result(), 10, True)
74 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_5.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates(), 11)
75 SketchArc_2 = Sketch_1.addArc(0, 0, 5.830951894845414, -7.49999999999991, 7.627518755950849, 5.663122603973648, False)
76 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_1.results()[1], SketchArc_2.results()[1])
77 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.center(), SketchArc_2.center())
78 SketchLine_8 = Sketch_1.addLine(-5.830951894845431, -7.499999999999899, -11, -7.5)
79 SketchLine_8.setName("SketchLine_9")
80 SketchLine_8.result().setName("SketchLine_9")
81 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
82 SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_4.result(), SketchLine_8.result())
83 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_4.endPoint())
84 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_8.startPoint())
85 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
86 SketchLine_9 = SketchProjection_2.createdFeature()
87 SketchLine_9.setName("SketchLine_11")
88 SketchLine_9.result().setName("SketchLine_11")
89 SketchLine_10 = Sketch_1.addLine(7.627518755950849, 5.663122603973648, 3.634350614531546, 1.669954462554345)
90 SketchLine_10.setName("SketchLine_13")
91 SketchLine_10.result().setName("SketchLine_13")
92 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_10.startPoint(), SketchArc_2.endPoint())
93 SketchLine_11 = Sketch_1.addLine(1.446475147749155, 3.724719682891128, 5.899967103122234, 8.178211638264205)
94 SketchLine_11.setName("SketchLine_14")
95 SketchLine_11.result().setName("SketchLine_14")
96 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_11.endPoint())
97 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_11.result(), SketchLine_10.result())
98 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_11.endPoint(), SketchLine_10.result(), 3, True)
99 SketchLine_12 = Sketch_1.addLine(0, 0, 6.816423472140706, 6.816423472140705)
100 SketchLine_12.setName("SketchLine_12")
101 SketchLine_12.result().setName("SketchLine_12")
102 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_12.startPoint())
103 SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_9.result(), SketchLine_12.result(), 45)
104 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_12.result(), SketchLine_11.result())
105 SketchCircle_1 = Sketch_1.addCircle(0, 0, 4)
106 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center())
107 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchCircle_1.results()[1], 4)
108 model.do()
109
110 # Perform first trim
111 SketchTrim = Sketch_1.addTrim(SketchCircle_1, GeomAPI.GeomAPI_Pnt2d(3.31110220786, 2.24423754741))
112 SketchTrim.execute()
113 model.do()
114
115 # Check trim does not crash if the selected point is not in specified edge
116 aLastArc = model.lastSubFeature(Sketch_1, "SketchArc")
117 SketchTrim = Sketch_1.addTrim(aLastArc, GeomAPI.GeomAPI_Pnt2d(3.31110220786, 2.24423754741))
118 SketchTrim.execute()
119 model.do()
120
121 model.end()
122
123 assert(model.checkPythonDump())