Back to index

salome-smesh  6.5.0
buildparticules.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # Copyright (C) 2011-2012  CEA/DEN, EDF R&D
00003 #
00004 # This library is free software; you can redistribute it and/or
00005 # modify it under the terms of the GNU Lesser General Public
00006 # License as published by the Free Software Foundation; either
00007 # version 2.1 of the License.
00008 #
00009 # This library is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 # Lesser General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU Lesser General Public
00015 # License along with this library; if not, write to the Free Software
00016 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 #
00018 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00019 #
00020 
00021 import geompy
00022 import salome
00023 salome.salome_init()
00024 theStudy = salome.myStudy
00025 geompy.init_geom(theStudy)
00026 
00027 filename="/home/gboulant/development/projets/salome/SPADDER/spadder/resources/padderexe/REF_spheres.dat.xyz"
00028 file=open(filename,'rb')
00029 
00030 import csv
00031 datalines = csv.reader(file, delimiter=' ')
00032 i=0
00033 for row in datalines:
00034     x=float(row[0])
00035     y=float(row[1])
00036     z=float(row[2])
00037     rayon=float(row[3])/2.
00038 
00039     centre = geompy.MakeVertex(x, y, z)
00040     particule = geompy.MakeSpherePntR(centre, rayon)
00041     geompy.addToStudy( particule, 'p'+str(i) )
00042     i+=1