Salome HOME
541412c12a824f9ec515b57e0e36c76afbb2393b
[modules/shaper.git] / src / SketchPlugin / Test / Test2341.py
1 # Copyright (C) 2014-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     Test2341.py
22     Test case for issue #2341 "SIGSEGV when trying to move a point of a projected axis"
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.defaultPlane("XOY"))
34 SketchLine_1 = Sketch_1.addLine(-5.830951894848558, -7.5, -11, -7.5)
35 SketchLine_2 = Sketch_1.addLine(-11, -7.5, -11, -10)
36 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
37 SketchLine_3 = Sketch_1.addLine(-11, -10, 11, -10)
38 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
39 SketchLine_4 = Sketch_1.addLine(11, -10, 11, -7.5)
40 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
41 SketchLine_5 = Sketch_1.addLine(11, -7.5, 5.8309518948453, -7.5)
42 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
43 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
44 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
45 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_5.result())
46 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
47 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_2.result())
48 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 2.5)
49 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 2.5)
50 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 22)
51 SketchConstraintLength_3.setName("SketchConstraintLength_5")
52 SketchLine_6 = Sketch_1.addLine(-6, 12, 6, 12)
53 SketchLine_7 = Sketch_1.addLine(6, 12, 6, 8.121320343559642)
54 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
55 SketchLine_8 = Sketch_1.addLine(-6, 12, -6, 7.365459931328117)
56 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_8.startPoint())
57 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_6.result())
58 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result())
59 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_8.result())
60 SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_6.result(), 12)
61 SketchConstraintLength_4.setName("SketchConstraintLength_6")
62 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
63 SketchPoint_1 = SketchProjection_1.createdFeature()
64 SketchProjection_2 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
65 SketchPoint_2 = SketchProjection_2.createdFeature()
66 SketchProjection_3 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
67 SketchPoint_3 = SketchProjection_3.createdFeature()
68 SketchProjection_4 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
69 SketchPoint_4 = SketchProjection_4.createdFeature()
70 SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Point(SketchPoint_4).coordinates(), SketchLine_4.startPoint(), 10)
71 SketchProjection_5 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
72 SketchPoint_5 = SketchProjection_5.createdFeature()
73 SketchArc_1 = Sketch_1.addArc(0, 0, -5.830951894848558, -7.5, -6, 7.365459931328117, True)
74 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchPoint_5.result(), SketchArc_1.center())
75 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
76 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 9.5)
77 SketchProjection_6 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
78 SketchPoint_6 = SketchProjection_6.createdFeature()
79 SketchArc_2 = Sketch_1.addArc(0, 0, 5.8309518948453, -7.5, 7.693909752490621, 5.572589408930978, False)
80 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_6.result(), SketchArc_2.center())
81 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchArc_2.startPoint())
82 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 9.5)
83 SketchArc_3 = Sketch_1.addArc(0, 0, 1.561361948645558, 3.6826822922052, 3.682682292205201, 1.561361948645557, False)
84 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchArc_3.center())
85 SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_3.results()[1], 4)
86 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_6.endPoint(), SketchArc_1.center(), 6)
87 SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine_3.endPoint(), SketchArc_1.center(), 11)
88 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchArc_1.endPoint())
89 SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchLine_8.startPoint(), SketchLine_2.endPoint(), 22)
90 SketchLine_9 = Sketch_1.addLine(0, 0, 14.14213562373095, 14.14213562373095)
91 SketchLine_9.setAuxiliary(True)
92 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_9.startPoint())
93 SketchProjection_7 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
94 SketchLine_10 = SketchProjection_7.createdFeature()
95 SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_10.result(), SketchLine_9.result(), 45)
96 SketchLine_11 = Sketch_1.addLine(7.693909752490621, 5.572589408930978, 3.682682292205201, 1.561361948645557)
97 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_11.startPoint())
98 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_11.endPoint())
99 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_9.result(), SketchLine_11.result())
100 SketchLine_12 = Sketch_1.addLine(6, 8.121320343559642, 1.561361948645558, 3.6826822922052)
101 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchLine_12.endPoint())
102 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_9.result(), SketchLine_12.result())
103 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_12.startPoint(), SketchLine_7.endPoint())
104 SketchLine_13 = Sketch_1.addLine(3.682682292205201, 1.561361948645557, 1.561361948645558, 3.6826822922052)
105 SketchLine_13.setAuxiliary(True)
106 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_13.startPoint())
107 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchLine_13.endPoint())
108 SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_13.result(), 3)
109 SketchConstraintLength_5.setName("SketchConstraintLength_7")
110 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_3.endPoint(), SketchLine_9.result(), 1.5, True)
111 SketchConstraintLength_6 = Sketch_1.setLength(SketchLine_9.result(), 20)
112 SketchConstraintLength_6.setName("SketchConstraintLength_8")
113 model.do()
114 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchArc_2_2f-SketchLine_11f-SketchArc_3_2r-SketchLine_12r-SketchLine_7r-SketchLine_6r-SketchLine_8f-SketchArc_1_2f")], model.selection(), 3.5, 0)
115 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6"))
116 SketchLine_14 = Sketch_2.addLine(6, 0, -6, 0)
117 SketchProjection_8 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_6_EndVertex"), False)
118 SketchPoint_7 = SketchProjection_8.createdFeature()
119 SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchPoint_7.result())
120 SketchProjection_9 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_6_StartVertex"), False)
121 SketchPoint_8 = SketchProjection_9.createdFeature()
122 SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchPoint_8.result())
123 SketchLine_15 = Sketch_2.addLine(-6, 0, -6, -3.5)
124 SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
125 SketchLine_16 = Sketch_2.addLine(-6, -3.5, -6, -10.5)
126 SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
127 SketchLine_17 = Sketch_2.addLine(5.978225648847096, 0.08643259872215214, 6, -3.5)
128 SketchProjection_10 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/To_Face]"), False)
129 SketchPoint_9 = SketchProjection_10.createdFeature()
130 SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchPoint_9.result())
131 SketchLine_18 = Sketch_2.addLine(6, -3.5, 6, -10.5)
132 SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint())
133 SketchConstraintLength_7 = Sketch_2.setLength(SketchLine_18.result(), 7)
134 SketchConstraintLength_7.setName("SketchConstraintLength_9")
135 SketchProjection_11 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/To_Face]"), False)
136 SketchPoint_10 = SketchProjection_11.createdFeature()
137 SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_10).coordinates(), SketchLine_15.endPoint())
138 SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_18.result())
139 SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_16.result())
140 SketchLine_19 = Sketch_2.addLine(6, -10.5, -6, -10.5)
141 SketchLine_19.setAuxiliary(True)
142 SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_19.startPoint(), SketchLine_18.endPoint())
143 SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_19.endPoint(), SketchLine_16.endPoint())
144 SketchConstraintEqual_1 = Sketch_2.setEqual(SketchLine_18.result(), SketchLine_16.result())
145 SketchProjection_12 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
146 SketchLine_20 = SketchProjection_12.createdFeature()
147 model.do()
148
149 SketchLine_20 = SketchAPI_Line(SketchLine_20)
150 lineStart = [SketchLine_20.startPoint().x(), SketchLine_20.startPoint().y()]
151 lineEnd = [SketchLine_20.endPoint().x(), SketchLine_20.endPoint().y()]
152
153 # Try to move a line provided by projection of OZ axis
154
155 # move start point
156 Sketch_2.move(SketchLine_20.startPoint(), lineStart[0] + 1., lineStart[1] + 1.)
157 model.do()
158 assert(SketchLine_20.startPoint().x() == lineStart[0] and SketchLine_20.startPoint().y() == lineStart[1])
159
160 # move end point
161 Sketch_2.move(SketchLine_20.endPoint(), lineEnd[0] + 1., lineEnd[1] + 1.)
162 model.do()
163 assert(SketchLine_20.endPoint().x() == lineEnd[0] and SketchLine_20.endPoint().y() == lineEnd[1])
164
165 # move whole line
166 Sketch_2.move(SketchLine_20.result(), 50., 50.)
167 model.do()
168 assert(SketchLine_20.startPoint().x() == lineStart[0] and SketchLine_20.startPoint().y() == lineStart[1])
169 assert(SketchLine_20.endPoint().x() == lineEnd[0] and SketchLine_20.endPoint().y() == lineEnd[1])
170
171 model.end()