Salome HOME
2691bde319323e08787bce4ba3211f8556db1231
[modules/shaper.git] / src / SketchPlugin / Test / Test3132.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 from GeomAPI import *
22 import math
23
24 ELL_CENTER_X = 10
25 ELL_CENTER_Y = 10
26 ELL_MAJOR_RAD = 30
27 ELL_MINOR_RAD = 15
28 DOF_1 = 5
29 DOF_2 = 9
30
31 model.begin()
32 partSet = model.moduleDocument()
33 Part_1 = model.addPart(partSet)
34 Part_1_doc = Part_1.document()
35 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
36 SketchEllipse_1 = Sketch_1.addEllipse(ELL_CENTER_X, ELL_CENTER_Y, ELL_CENTER_X + math.sqrt(ELL_MAJOR_RAD**2 + ELL_MINOR_RAD**2), ELL_CENTER_Y, ELL_MINOR_RAD)
37 [SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
38 model.do()
39 assert(model.dof(Sketch_1) == DOF_1)
40
41 # trim the ellipse
42 ANGLE = math.pi/4
43 Sketch_1.addTrim(SketchEllipse_1.feature(), GeomAPI_Pnt2d(ELL_CENTER_X + ELL_MAJOR_RAD * math.cos(ANGLE), ELL_CENTER_Y + ELL_MINOR_RAD * math.sin(ANGLE)))
44 model.do()
45 assert(model.dof(Sketch_1) == DOF_1)
46
47 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
48 SketchEllipse_2 = Sketch_2.addEllipse(ELL_CENTER_X, ELL_CENTER_Y, ELL_CENTER_X + math.sqrt(ELL_MAJOR_RAD**2 + ELL_MINOR_RAD**2), ELL_CENTER_Y, ELL_MINOR_RAD)
49 [SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchPoint_12, SketchPoint_13, SketchPoint_14, SketchLine_3, SketchLine_4] = SketchEllipse_2.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
50 SketchLine_5 = Sketch_2.addLine(15.23538168732762, 24.77570901315218, 37.44845404222143, 43.05543771157006)
51 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchEllipse_2.result())
52 SketchLine_6 = Sketch_2.addLine(37.44845404222143, 43.05543771157006, 37.66137837703927, 15.83721541173749)
53 SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
54 SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchEllipse_2.result())
55 model.do()
56 assert(model.dof(Sketch_2) == DOF_2)
57
58 # split the ellipse
59 Sketch_2.addSplit(SketchEllipse_2.feature(), GeomAPI_Pnt2d(ELL_CENTER_X + ELL_MAJOR_RAD * math.cos(ANGLE), ELL_CENTER_Y + ELL_MINOR_RAD * math.sin(ANGLE)))
60 DOF_2 += 3
61 model.do()
62 assert(model.dof(Sketch_2) == DOF_2)
63
64
65 model.end()
66
67 assert(model.checkPythonDump())