Salome HOME
PR: synchro V6_main tag mergeto_V7_main_11Feb13
[modules/geom.git] / doc / salome / examples / transformation_operations_ex09.py
1 # Multi Rotation
2
3 import geompy
4 import salome
5 gg = salome.ImportComponentGUI("GEOM")
6 import math
7
8 # create vertices and vectors
9 p0  = geompy.MakeVertex( 0.,  0.,  0.)
10 px  = geompy.MakeVertex(20.,  0.,  0.)
11 py  = geompy.MakeVertex( 0., 20.,  0.)
12 pz  = geompy.MakeVertex( 0.,  0., 20.)
13 pxyz = geompy.MakeVertex( 50., 50., 10.)
14 vz  = geompy.MakeVector(p0, pz)
15 vxy = geompy.MakeVector(px, py)
16 vrot = geompy.MakeVector(p0, pxyz)
17
18 # create an arc
19 arc = geompy.MakeArc(py, pz, px)
20
21 # create a wire
22 wire = geompy.MakeWire([vxy, arc])
23
24 # create a planar face
25 face = geompy.MakeFace(wire, 1)
26
27 # create a prism
28 prism = geompy.MakePrismVecH(face, vz, 20.0)
29
30 # 1. Rotate the prism around the axis vrot 4 times
31
32 # rotation angle = 2 * PI / 4
33 rot1da = geompy.MultiRotate1DNbTimes(prism, vrot, 4)
34
35 # by the given angle of 30 degrees
36 rot1db = geompy.MultiRotate1DByStep(prism, vrot, math.pi/6., 4)
37
38 # 2. Rotate the prism around the axis vrot 4 times
39 #    and translate the result of each rotation 5 times on distance 50
40
41 # rotation angle = 2 * PI / 4
42 rot2da = geompy.MultiRotate2DNbTimes(prism, vrot, 4, 50, 5)
43
44 # by the given angle of 60 degrees
45 rot2db = geompy.MultiRotate2DByStep(prism, vrot, math.pi/3., 4, 50, 5)
46
47 # add objects in the study
48 id_prism = geompy.addToStudy(prism,"Prism")
49 id_rot1da = geompy.addToStudy(rot1da,"Rotation 1D Nb.Times")
50 id_rot1db = geompy.addToStudy(rot1db,"Rotation 1D By Step")
51 id_rot2da = geompy.addToStudy(rot2da,"Rotation 2D Nb.Times")
52 id_rot2db = geompy.addToStudy(rot2db,"Rotation 2D By Step")
53
54 # display the prism and the results of fillet operation
55 gg.createAndDisplayGO(id_prism)
56 gg.setDisplayMode(id_prism,1)
57 gg.createAndDisplayGO(id_rot1da)
58 gg.setDisplayMode(id_rot1da,1)
59 gg.createAndDisplayGO(id_rot1db)
60 gg.setDisplayMode(id_rot1db,1)
61 gg.createAndDisplayGO(id_rot2da)
62 gg.setDisplayMode(id_rot2da,1) 
63 gg.createAndDisplayGO(id_rot2db)
64 gg.setDisplayMode(id_rot2db,1)