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