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