Salome HOME
Updated copyright comment
[modules/shaper.git] / src / SketchPlugin / Test / Test2711.py
1 # Copyright (C) 2018-2024  CEA, EDF
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     Test2711.py
22     Test case for issue #2711 "Crash when calling split"
23 """
24
25 from salome.shaper import model
26 from salome.shaper import geom
27
28 from ModelAPI import *
29 from SketchAPI import *
30
31 model.begin()
32 partSet = model.moduleDocument()
33 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
34 SketchLine_1 = Sketch_1.addLine(-0.4, -0.45, 3.6, -0.45)
35 SketchLine_2 = Sketch_1.addLine(3.6, -0.45, 3.6, 0.2)
36 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
37 SketchLine_3 = Sketch_1.addLine(3.6, 0.2, 0.25, 0.2)
38 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
39 SketchLine_4 = Sketch_1.addLine(0.25, 0.2, 0.25, 3.55)
40 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
41 SketchLine_5 = Sketch_1.addLine(0.25, 3.55, -0.4, 3.55)
42 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
43 SketchLine_6 = Sketch_1.addLine(-0.4, 3.55, -0.4, -0.45)
44 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
45 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint())
46 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_6.result())
47 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
48 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_2.result())
49 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
50 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
51 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_5.result())
52 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 0.65)
53 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_5.result(), 0.65)
54 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_6.result(), 4)
55 SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_1.result(), 4)
56 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "OY"), False)
57 SketchLine_7 = SketchProjection_1.createdFeature()
58 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_6.startPoint(), SketchLine_7.result(), 0.4, True)
59 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "OX"), False)
60 SketchLine_8 = SketchProjection_2.createdFeature()
61 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_3.startPoint(), SketchLine_8.result(), 0.2, True)
62 model.do()
63
64 model.checkSketch(Sketch_1, 0)
65
66 SketchPoint_1 = Sketch_1.addPoint(2, 0.2)
67 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_3.result())
68 model.do()
69
70 model.checkSketch(Sketch_1, 1)
71
72 Sketch_1.addSplit(SketchLine_3, geom.Pnt2d(3, 0.2))
73 model.do()
74
75 model.checkSketch(Sketch_1, 2)
76
77 SketchLine_9 = SketchAPI_Line(model.lastSubFeature(featureToCompositeFeature(Sketch_1.feature()), "SketchLine"))
78 SketchPoint_2 = Sketch_1.addPoint(3, 0.2)
79 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_9.result())
80 model.do()
81
82 model.checkSketch(Sketch_1, 3)
83
84 Sketch_1.addSplit(SketchLine_9, geom.Pnt2d(3.2, 0.2))
85 model.do()
86
87 model.checkSketch(Sketch_1, 4)
88
89 model.end()
90
91 assert(model.checkPythonDump())