[Paraview] Visualising image data

Bruce Jones bruce.david.jones at gmail.com
Thu Jan 22 11:17:13 EST 2015


Hi all,

I'm working on a programmable filter that needs to produce a vtkImageData
object. So far it appears to work, inspection of the properties panel shows
the object has the correct number of points/cells and the data array
contains the correct data. However I cannot get a visualisation with any of
the representations (surface, outline, wireframe etc). Curiously, if i set
the display to my data array then the color bar appears with the correct
values, but still not visualization.

I am using the following code to produce the image data object.

from vtk import *

output = self.GetOutputDataObject(0);

# Create a VTK Grid
grid = vtkImageData()
grid.SetOrigin(0, 0, 0) # default values
dx=10;
grid.SetSpacing(dx, dx, dx)
grid.SetDimensions(5, 8, 10) # number of points in each direction
# print grid.GetNumberOfPoints()
# print grid.GetNumberOfCells()
array = vtkDoubleArray()
array.SetNumberOfComponents(1) # this is 3 for a vector
array.SetNumberOfTuples(grid.GetNumberOfPoints())
for i in range(grid.GetNumberOfPoints()):
    if i < 200:
        array.SetValue(i, 1)
    else:
        array.SetValue(i, 2)

grid.GetPointData().AddArray(array)
# print grid.GetPointData().GetNumberOfArrays()
array.SetName("unit array")
output.ShallowCopy(grid);

Cheers,
Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150122/eebff627/attachment.html>


More information about the ParaView mailing list