Salome HOME
ba4940c1465bce1d81b1c8a08e51f252f57c3cf2
[modules/geom.git] / doc / salome / examples / basic_geom_objs_ex06.py
1 # Creation of a Curve
2
3 import geompy
4 import salome
5 gg = salome.ImportComponentGUI("GEOM")
6
7 # create vertices and vectors
8 p0 = geompy.MakeVertex(0.  , 0.  , 0.  )
9 p1 = geompy.MakeVertex(50. , 100., 200.)
10 p2 = geompy.MakeVertex(150.,  50., 100.)
11 p3 = geompy.MakeVertex(100., 150., 170.)
12 p4 = geompy.MakeVertex(200., 200., 150.)
13
14 v1 = geompy.MakeVectorDXDYDZ(0, 1, 0)
15 v2 = geompy.MakeVectorDXDYDZ(1, 0, 0)
16
17 # create a polyline from a list of points
18 polyline = geompy.MakePolyline([p0, p1, p2, p3, p4])
19
20 # create a bezier curve from a list of points
21 bezier = geompy.MakeBezier([p0, p1, p2, p3, p4])
22
23 #create a b-spline curve from a list of points
24 interpol = geompy.MakeInterpol([p0, p1, p2, p3, p4], False)
25
26 #create a b-spline curve with defined directions at the ends
27 interpol_tangents = geompy.MakeInterpolWithTangents([p0, p1, p2, p3, p4], v1, v2)
28
29 #create a polyline using parametric definition of the basic points
30 param_polyline = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Polyline, theNewMethod=True)
31
32 # create a bezier curve using parametric definition of the basic points
33 param_bezier = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 20, geompy.GEOM.Bezier, theNewMethod=True)
34
35 #create a b-spline curve using parametric definition of the basic points
36 param_interpol = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Interpolation, theNewMethod=True)
37
38
39 # add objects in the study
40 id_p0       = geompy.addToStudy(p0,       "Point1")
41 id_p1       = geompy.addToStudy(p1,       "Point2")
42 id_p2       = geompy.addToStudy(p2,       "Point3")
43 id_p3       = geompy.addToStudy(p3,       "Point4")
44 id_p4       = geompy.addToStudy(p4,       "Point5")
45 id_v1       = geompy.addToStudy(v1,       "Vector1")
46 id_v2       = geompy.addToStudy(v2,       "Vector2")
47 id_polyline = geompy.addToStudy(polyline, "Polyline")
48 id_bezier   = geompy.addToStudy(bezier,   "Bezier")
49 id_interpol = geompy.addToStudy(interpol, "Interpol")
50 id_interpol_tangents = geompy.addToStudy(interpol_tangents, "Interpol Tangents")
51 id_param_polyline = geompy.addToStudy(param_polyline, "Polyline Parametric")
52 id_param_bezier = geompy.addToStudy(param_bezier, "Bezier Parametric")
53 id_param_interpol = geompy.addToStudy(param_interpol, "Interpol Parametric")
54
55
56 # display the points and the curves
57 gg.createAndDisplayGO(id_p0)
58 gg.createAndDisplayGO(id_p1)
59 gg.createAndDisplayGO(id_p2)
60 gg.createAndDisplayGO(id_p3)
61 gg.createAndDisplayGO(id_p4)
62 gg.createAndDisplayGO(id_polyline)
63 gg.createAndDisplayGO(id_bezier)
64 gg.createAndDisplayGO(id_interpol) 
65 gg.createAndDisplayGO(id_interpol_tangents) 
66 gg.createAndDisplayGO(id_param_polyline)
67 gg.createAndDisplayGO(id_param_bezier)
68 gg.createAndDisplayGO(id_param_interpol)