Salome HOME
Switch to SSL mode for tests : naive approach
[modules/geom.git] / doc / salome / examples / polyline.py
1 # 2D polyline
2
3 import salome
4 salome.salome_init_without_session()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
8 gg = salome.ImportComponentGUI("GEOM")
9
10 # create vertices
11 p1 = geompy.MakeVertex(70.,  0.,  0.)
12 p2 = geompy.MakeVertex(70., 70., 80.)
13 p3 = geompy.MakeVertex( 0., 70.,  0.)
14
15 #create a vector from two points
16 vector_arc = geompy.MakeVector(p1, p3)
17
18 # create an arc from three points
19 arc = geompy.MakeArc(p1, p2, p3)
20
21 # create a wire
22 wire = geompy.MakeWire([vector_arc, arc])
23
24 # create a planar face
25 isPlanarWanted = 1
26 face = geompy.MakeFace(wire, isPlanarWanted)
27
28 # Create a 2D polyline with Polyline2D interface
29 pl = geompy.Polyline2D()
30 pl.addSection("section 1", GEOM.Polyline, True, [0, 0, 10, 0, 10, 10])
31 polyline1 = pl.result([100, 0, 0, 1, 1, 1, -1, 1, 0])
32
33 pl = geompy.Polyline2D()
34 pl.addSection("section 2", GEOM.Interpolation, False)
35 pl.addPoints([20, 0, 30, 0, 30, 10])
36 polyline2 = pl.result(face)
37
38 # add objects in the study
39 id_face = geompy.addToStudy(face,"Face")
40 id_polyline1 = geompy.addToStudy(polyline1, "Polyline1")
41 id_polyline2 = geompy.addToStudy(polyline2, "Polyline2")
42
43 # display the first polyline and the second polyline with its planar face
44 gg.createAndDisplayGO(id_face)
45 gg.setDisplayMode(id_face,1)
46 gg.setTransparency(id_face,0.5)
47 gg.createAndDisplayGO(id_polyline1)
48 gg.createAndDisplayGO(id_polyline2)