Back to index

salome-geom  6.5.0
GEOM_example2.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
00025 #  File   : GEOM_example2.py
00026 #  Author : Paul RASCLE, EDF
00027 #  Module : GEOM
00028 #  $Header: /home/server/cvs/GEOM/GEOM_SRC/src/GEOM_SWIG/GEOM_example2.py,v 1.9.2.2.10.2.14.1 2012-04-13 05:48:08 vsr Exp $
00029 #
00030 import salome
00031 import geompy
00032 import math
00033 
00034 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
00035 myBuilder = salome.myStudy.NewBuilder()
00036 
00037 BasicOp  = geom.GetIBasicOperations(salome.myStudyId)
00038 PrimOp   = geom.GetI3DPrimOperations(salome.myStudyId)
00039 InsertOp = geom.GetIInsertOperations(salome.myStudyId)
00040 TrsfOp   = geom.GetITransformOperations(salome.myStudyId)
00041 
00042 point0  = BasicOp.MakePointXYZ(0.,0.,0.)
00043 pointz1 = BasicOp.MakePointXYZ(0.,0.,1.)
00044 dirz = BasicOp.MakeVectorTwoPnt(point0,pointz1)
00045 
00046 torus1 = PrimOp.MakeTorusPntVecRR(point0,dirz,150.,25.)
00047 id_torus1 = geompy.addToStudy(torus1,"torus1")
00048 
00049 torus2 = InsertOp.MakeCopy(torus1)
00050 
00051 vec1 = BasicOp.MakeVectorDXDYDZ(0.,0.,100.)
00052 torus2 = TrsfOp.TranslateVectorCopy(torus2,vec1)
00053 id_torus2 = geompy.addToStudy(torus2,"torus2")
00054 
00055 cylz1 = PrimOp.MakeCylinderPntVecRH(point0,dirz,25.,100.)
00056 
00057 ind = 0
00058 cyllist = []
00059 while ind < 6:
00060     acyl = InsertOp.MakeCopy(cylz1)
00061     x = 150. * math.cos(ind * math.pi/3.)
00062     y = 150. * math.sin(ind * math.pi/3.)
00063     z = 0.
00064     vec_i = BasicOp.MakeVectorDXDYDZ(x,y,z)
00065     name = "cyl%d"%(ind)
00066     acyl = TrsfOp.TranslateVectorCopy(acyl,vec_i)
00067     id_acyl = geompy.addToStudy(acyl,name)
00068     cyllist.append(acyl)
00069     ind = ind + 1