Hi Luca,<br><br>In ParaView, you can open directly a CSV file and then do some calculation on your data. I am sure you will find -recent- threads and wikis about that.<br><br>Outside ParaView (for VTK only script), you could to embed your vtkPoints into a vtkPolyData and then plug the PolyData into a PolyDataWriter:<br>
<br>polydata = vtk.vtkPolyData( )<br>polydata.SetPoints( newPoints )<br><br>writer = vtk.vtkPolyDataWriter( )<br>writer.SetInput( polydata )<br>writer.SetFileName( "your_name" )<br>writer.Write( )<br><br>[I wrote it without any warranty and verifications... good luck!]<br>
<br>BTW, isn't there a vtkCSVReader in VTK???<br><br>Jerome<br><br><div class="gmail_quote">2009/12/4 Luca Penasa <span dir="ltr"><<a href="mailto:luca.penasa@email.it">luca.penasa@email.it</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
hi everybody, im new to the list (and to vtk programming), so please be patient with my questions :-)<br>
<br>
I am trying to write down a script for converting a csv-like file into a vtk readable file.<br>
<br>
<i>Some example rows of the original file:</i><br>
<br>
<font size="2">9.045410 9.358978 2772.13 15 0x01</font><br>
<font size="2">9.051514 9.358978 2771.82 21 0x01</font><br>
<font size="2">9.061432 9.361267 2771.79 16 0x01</font><br>
<font size="2">9.069061 9.358215 2771.79 16 0x01</font><br>
<br>
<i>This is part of the script i wrote for reading this type of csv-like file:</i><br>
<br>
<font size="2">reader = csv.reader(infile, delimiter=' ')</font><br>
<font size="2">newPoints = vtk.vtkPoints()</font><br>
<font size="2">newline = []</font><br>
<font size="2">ID = 0</font><br>
<br>
<font size="2">for line in reader:</font><br>
<font size="2"> newline.append(cos(float(line[1])*2*pi/180)*sin(float(line[0])*2*pi/180)*float(line[2])) #X</font><br>
<font size="2"> newline.append(cos(float(line[1])*2*pi/180)*cos(float(line[0])*2*pi/180)*float(line[2])) #Y</font><br>
<font size="2"> newline.append(sin(float(line[1])*2*pi/180)*float(line[2])) #Z</font><br>
<font size="2"> newline.append(float(line[3])) #Intensity</font><br>
<font size="2"> newPoints.InsertPoint(ID, newline[0], newline[1], newline[2])</font><br>
<font size="2"> ID = ID+1</font><br>
<font size="2">infile.close()</font><br>
<br>
After reading the file with csv.reader, i do some arithmetics on the coordinates and then i put my points in a vtkPoints object..<br>
<br>
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)..<br>
Anybody can help me??<br>
<br>
I would like to preserve the 4th column attributes for every point, couse is the data i am interested in... <br>
<br>
<br>
Thousand Thanks!!<br>
<br>
<br>
<br>
<br>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td>
<pre>--
---------------------------
Luca Penasa
Student at Geosciences Dpt.
University of Padua (IT)
<a href="mailto:luca.penasa@email.it" target="_blank">luca.penasa@email.it</a>
---------------------------
</pre>
</td>
</tr>
</tbody></table>
</div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>