Salome HOME
9a5c5a925dadac7d93291bfeaddc36052888534b
[modules/shaper.git] / src / SketchPlugin / Test / TestSplitLine.py
1 # Copyright (C) 2018-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 from SketchAPI import *
21
22 from salome.shaper import model
23 from salome.shaper import geom
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchLine_1 = Sketch_1.addLine(-38.2842712474619, 18.28427124746191, -10, -10)
31 SketchLine_2 = Sketch_1.addLine(-10, -10, -10, 20)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
33 SketchLine_3 = Sketch_1.addLine(-10, 20, -25, 5)
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
35 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_1.result())
36 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40)
37 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()])
38 [SketchLine_4, SketchLine_5] = SketchConstraintMirror_1.mirrored()
39 model.do()
40
41 model.testNbSubFeatures(Sketch_1, "SketchLine", 5)
42 model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 3)
43 model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1)
44 model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 1)
45
46 #perform split
47 SketchSplit = Sketch_1.addSplit(SketchLine_1, geom.Pnt2d(-12, -8))
48 SketchSplit.execute()
49 model.do()
50
51 model.testNbSubFeatures(Sketch_1, "SketchLine", 6)
52 model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 5)
53 model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1)
54 model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 0)
55
56 model.end()
57
58 assert(model.checkPythonDump())