Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchPlugin / Test / TestOffset2.py
1 # Copyright (C) 2020-2023  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 salome.shaper import model
21
22 SKETCH_DOF = 9
23
24 model.begin()
25 partSet = model.moduleDocument()
26
27 ### Create Sketch
28 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
29
30 ### Create SketchArc
31 SketchArc_1 = Sketch_1.addArc(10, 10, 50, 0, 0, 50, False)
32
33 ### Create SketchLine
34 SketchLine_1 = Sketch_1.addLine(0, 50, -20, 0)
35
36 ### Create SketchLine
37 SketchLine_2 = Sketch_1.addLine(50, 0, -20, 0)
38 Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint())
39 Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint())
40 model.do()
41
42 assert(model.dof(Sketch_1) == SKETCH_DOF)
43
44 ### Create SketchOffset
45 SketchOffset_1_objects = [SketchLine_1.result(), SketchArc_1.results()[1], SketchLine_2.result()]
46 SketchOffset_1 = Sketch_1.addOffset(SketchOffset_1_objects, 13, False)
47 model.do()
48
49 # DoF should not change
50 assert(model.dof(Sketch_1) == SKETCH_DOF)
51 # check number of features
52 assert(len(SketchOffset_1.offset()) == 5)
53 model.testNbSubFeatures(Sketch_1, "SketchPoint", 0)
54 model.testNbSubFeatures(Sketch_1, "SketchLine", 4)
55 model.testNbSubFeatures(Sketch_1, "SketchArc", 4)
56 model.testNbSubFeatures(Sketch_1, "SketchBSpline", 0)
57 model.testNbSubFeatures(Sketch_1, "SketchBSplinePeriodic", 0)
58
59 model.end()
60
61 assert(model.checkPythonDump())