1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 # File : GEOM_example3.py
25 # Author : Paul RASCLE, EDF
32 from time import sleep
34 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
35 myBuilder = salome.myStudy.NewBuilder()
37 gg = salome.ImportComponentGUI("GEOM")
39 BasicOp = geom.GetIBasicOperations(salome.myStudyId)
40 PrimOp = geom.GetI3DPrimOperations(salome.myStudyId)
41 InsertOp = geom.GetIInsertOperations(salome.myStudyId)
42 TrsfOp = geom.GetITransformOperations(salome.myStudyId)
44 point0 = BasicOp.MakePointXYZ(0.,0.,0.)
45 pointz1 = BasicOp.MakePointXYZ(0.,0.,1.)
46 dirz = BasicOp.MakeVectorTwoPnt(point0,pointz1)
48 torus1 = PrimOp.MakeTorusPntVecRR(point0,dirz,150.,25.)
49 id_torus1 = geompy.addToStudy(torus1,"torus1")
50 gg.createAndDisplayGO(id_torus1)
52 torus2 = InsertOp.MakeCopy(torus1)
54 vec1 = BasicOp.MakeVectorDXDYDZ(0.,0.,100.)
55 torus2 = TrsfOp.TranslateVectorCopy(torus2,vec1)
56 id_torus2 = geompy.addToStudy(torus2,"torus2")
57 gg.createAndDisplayGO(id_torus2)
59 cylz1 = PrimOp.MakeCylinderPntVecRH(point0,dirz,25.,100.)
65 acyl = InsertOp.MakeCopy(cylz1)
66 x = 150. * math.cos(ind * math.pi/3.)
67 y = 150. * math.sin(ind * math.pi/3.)
69 vec_i = BasicOp.MakeVectorDXDYDZ(x,y,z)
71 acyl = TrsfOp.TranslateVectorCopy(acyl,vec_i)
72 id_acyl = geompy.addToStudy(acyl,name)
73 gg.createAndDisplayGO(id_acyl)
74 shapeList.append(acyl)
75 idList.append(id_acyl)
78 shapeList.append(torus1)
79 shapeList.append(torus2)
80 idList.append(id_torus1)
81 idList.append(id_torus2)
83 cage = geompy.MakeCompound(shapeList)
84 id_cage = geompy.addToStudy(cage,"cage")
85 gg.createAndDisplayGO(id_cage)
102 sg.Display(id_torus1)
103 sg.Display(id_torus2)
106 gg.setTransparency(id_torus1,0.5)
108 gg.setDisplayMode(id_torus1,1)
109 gg.setDisplayMode(id_torus2,1)
110 gg.setDisplayMode(id_acyl,1)
111 #gg.setDisplayMode(id_cage,1)
113 gg.setColor(id_torus1,0,0,255)
114 gg.setColor(id_torus2,255,0,0)
115 gg.setColor(id_acyl,0,255,0)
116 #gg.setColor(id_cage,255,255,0)