[Paraview] vtkPolyData
Alessandro Bellina
bellina at uiuc.edu
Fri Jan 25 21:39:28 EST 2008
Hello again,
I am trying now to display some data that is not structured in cells and
points as a mesh would. This is a vector cloud in 3-D. Reading some of the
other threads I have found this could be done with Programmable Sources, or
vtp files. My only problem is that I am having trouble creating the actual
vectors... so I can assign points but am having issues assigning those
points, end points, to create vectors.
Here is some code, posted in this list before, that I have been using. I
think I need to add the end points as vtkPoints, is that right? Then
populate them in the loop. If anybody could point to how to do this in .vtp
xml file format that would help me even more. Like what structure should the
file have?
Thank you in advance,
Alessandro
---------------------------------------------------------------
#!/usr/bin/env python
from paraview import vtk
import csv
output = self.GetOutput()
points = vtk.vtkPoints()
data = vtk.vtkPoints() #? Is this what I need to be using?
cells = vtk.vtkCellArray()
vectors = vtk.vtkCellArray()
file = open("/home/bellina/workspace/Data/CSphere/test.vtp")
header = csv.reader(file).next() #get the header line
csvReader = csv.DictReader(file, header) #make a dict reader with the header
counter = 0 #need to keep track of the amount of cells
for line in csvReader:
points.InsertNextPoint(float(line['x']), float(line['y']),
float(line['z'])) #add a point change the 'x' etc to what you have in your
header
cells.InsertNextCell(1) #each point has its own cell
cells.InsertCellPoint(counter)
counter += 1
output.SetPoints(points) #need to set points
output.SetVerts(cells) #need to set cells as verts
----------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/paraview/attachments/20080125/d98eebf0/attachment.html
More information about the ParaView
mailing list