Salome HOME
Porting to Python 2.6 - add coding page specification for Python scripts
[modules/geom.git] / src / GEOM_SWIG / GEOM_example2.py
1 #! /usr/bin/python
2 #  -*- coding: iso-8859-1 -*-
3 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 #
8 #  This library is free software; you can redistribute it and/or
9 #  modify it under the terms of the GNU Lesser General Public
10 #  License as published by the Free Software Foundation; either
11 #  version 2.1 of the License.
12 #
13 #  This library is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 #  Lesser General Public License for more details.
17 #
18 #  You should have received a copy of the GNU Lesser General Public
19 #  License along with this library; if not, write to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 #
22 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #
24 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
25 #  File   : GEOM_example2.py
26 #  Author : Paul RASCLE, EDF
27 #  Module : GEOM
28 #  $Header$
29 #
30 import salome
31 import geompy
32 import math
33
34 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
35 myBuilder = salome.myStudy.NewBuilder()
36
37 BasicOp  = geom.GetIBasicOperations(salome.myStudyId)
38 PrimOp   = geom.GetI3DPrimOperations(salome.myStudyId)
39 InsertOp = geom.GetIInsertOperations(salome.myStudyId)
40 TrsfOp   = geom.GetITransformOperations(salome.myStudyId)
41
42 point0  = BasicOp.MakePointXYZ(0.,0.,0.)
43 pointz1 = BasicOp.MakePointXYZ(0.,0.,1.)
44 dirz = BasicOp.MakeVectorTwoPnt(point0,pointz1)
45
46 torus1 = PrimOp.MakeTorusPntVecRR(point0,dirz,150.,25.)
47 id_torus1 = geompy.addToStudy(torus1,"torus1")
48
49 torus2 = InsertOp.MakeCopy(torus1)
50
51 vec1 = BasicOp.MakeVectorDXDYDZ(0.,0.,100.)
52 torus2 = TrsfOp.TranslateVectorCopy(torus2,vec1)
53 id_torus2 = geompy.addToStudy(torus2,"torus2")
54
55 cylz1 = PrimOp.MakeCylinderPntVecRH(point0,dirz,25.,100.)
56
57 ind = 0
58 cyllist = []
59 while ind < 6:
60     acyl = InsertOp.MakeCopy(cylz1)
61     x = 150. * math.cos(ind * math.pi/3.)
62     y = 150. * math.sin(ind * math.pi/3.)
63     z = 0.
64     vec_i = BasicOp.MakeVectorDXDYDZ(x,y,z)
65     name = "cyl%d"%(ind)
66     acyl = TrsfOp.TranslateVectorCopy(acyl,vec_i)
67     id_acyl = geompy.addToStudy(acyl,name)
68     cyllist.append(acyl)
69     ind = ind + 1