[vtkusers] Help in writing a python script

Luca Penasa luca.penasa at email.it
Fri Dec 4 06:03:56 EST 2009


hi everybody, im new to the list (and to vtk programming), so please be
patient with my questions :-)

I am trying to write down a script for converting a csv-like file into a
vtk readable file.

Some example rows of the original file:

9.045410 9.358978 2772.13 15 0x01
9.051514 9.358978 2771.82 21 0x01
9.061432 9.361267 2771.79 16 0x01
9.069061 9.358215 2771.79 16 0x01

This is part of the script i wrote for reading this type of csv-like
file:

reader =  csv.reader(infile, delimiter=' ')
newPoints = vtk.vtkPoints()
newline = []
ID = 0

for line in reader:

newline.append(cos(float(line[1])*2*pi/180)*sin(float(line[0])*2*pi/180)*float(line[2])) #X

newline.append(cos(float(line[1])*2*pi/180)*cos(float(line[0])*2*pi/180)*float(line[2])) #Y
    newline.append(sin(float(line[1])*2*pi/180)*float(line[2]))  #Z
    newline.append(float(line[3])) #Intensity
    newPoints.InsertPoint(ID, newline[0], newline[1], newline[2])
    ID = ID+1
infile.close()

After reading the file with csv.reader, i do some arithmetics on the
coordinates and then i put my points in a vtkPoints object..

Now i dont know how to set up a vtk writer for writing out that object
in a vtk-compatible file format (after that i would like to open that
file in Paraview)..
Anybody can help me??

I would like to preserve the 4th column attributes for every point,
couse is the data i am interested in... 


Thousand Thanks!!




-- 
---------------------------
Luca Penasa
Student at Geosciences Dpt.
University of Padua (IT)
luca.penasa at email.it
---------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091204/c98ba069/attachment.htm>


More information about the vtkusers mailing list