Salome HOME
NRI : Correction Module name.
[modules/geom.git] / src / GEOM_SWIG / GEOM_example3.py
1 #==============================================================================
2 #  File      : GEOM_example3.py
3 #  Created   : sam nov 10 00:53:24 CET 2001
4 #  Author    : Paul RASCLE, EDF
5 #  Project   : SALOME
6 #  Copyright : EDF 2001
7 #  $Header$
8 #==============================================================================
9
10 import salome
11 import geompy
12 import math
13 from time import sleep
14
15 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
16 myBuilder = salome.myStudy.NewBuilder()
17
18 gg = salome.ImportComponentGUI("GEOM")
19
20 point0  = geom.MakePointStruct(0.,0.,0.)
21 pointz1 = geom.MakePointStruct(0.,0.,1.)
22 dirz = geom.MakeDirection(pointz1)
23
24 torus1 = geompy.MakeTorus(point0,dirz,150.,25.)
25 id_torus1 = geompy.addToStudy(torus1,"torus1")
26 gg.createAndDisplayGO(id_torus1)
27
28 torus2 = geom.MakeCopy(torus1)
29 torus2 = geom.MakeTranslation(torus2,0.,0.,100.)
30 id_torus2 = geompy.addToStudy(torus2,"torus2")
31 gg.createAndDisplayGO(id_torus2)
32
33 cylz1 = geompy.MakeCylinder(point0,dirz,25.,100.)
34
35 ind = 0
36 shapeList = []
37 idList = []
38 while ind < 6:
39     acyl = geom.MakeCopy(cylz1)
40     x = 150. * math.cos(ind * math.pi/3.)
41     y = 150. * math.sin(ind * math.pi/3.)
42     z = 0.
43     name = "cyl%d"%(ind)
44     acyl = geompy.MakeTranslation(acyl,x,y,z)
45     id_acyl = geompy.addToStudy(acyl,name)
46     gg.createAndDisplayGO(id_acyl)
47     shapeList.append(acyl)
48     idList.append(id_acyl)
49     ind = ind +1
50
51 shapeList.append(torus1)
52 shapeList.append(torus2)
53 idList.append(id_torus1)
54 idList.append(id_torus2)
55
56 iorStringList = []
57 for shape in shapeList:
58     iorStringList.append(shape._get_Name())
59
60 cage = geompy.MakeCompound(iorStringList)
61 id_cage = geompy.addToStudy(cage,"cage")
62 gg.createAndDisplayGO(id_cage)
63
64 from salome import sg
65 sleep(1)
66 sg.EraseAll()
67 for id in idList:
68     sg.DisplayOnly(id)
69     sleep(1)
70 sg.EraseAll()
71 for id in idList:
72     sg.Display(id)
73     sleep(1)
74 for id in idList:
75     sg.Erase(id)
76     sleep(1)
77
78 #sg.Display(id_cage)
79 sg.Display(id_torus1)
80 sg.Display(id_torus2)
81 sg.Display(id_acyl)
82
83 gg.setTransparency(id_torus1,0.5)
84
85 gg.setDisplayMode(id_torus1,1)
86 gg.setDisplayMode(id_torus2,1)
87 gg.setDisplayMode(id_acyl,1)
88 #gg.setDisplayMode(id_cage,1)
89
90 gg.setColor(id_torus1,0,0,255)
91 gg.setColor(id_torus2,255,0,0)
92 gg.setColor(id_acyl,0,255,0)
93 #gg.setColor(id_cage,255,255,0)