vtkProgrammableSource doesn't work with StructuredGrids
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
vtkProgrammableSource, used from the python bindings, apparently cannot product valid StructuredGrid datasets. The GetStructuredGridOutput() method returns a StructuredGrid object which cannot be rendered.
The script below illustrates this. This script should create a 25-by-25 grid. However, nothing is rendered, even though the output of the Source appears correct (when 'printed').
By contrast, if I create a StructuredGrid manually and use the same function to create the pointSet, it works fine.
Only tested this on linux so far. The problem is the same on VTK-4.2 & 5.0.0
Below is the example (python) code:
import vtk
source = vtk.vtkProgrammableSource() def Execute(): grid = source.GetStructuredGridOutput() points = vtk.vtkPoints()
nx,ny = 25,25
for i in xrange(nx):
for j in xrange(ny):
points.InsertNextPoint(i/5.0,j/5.0,0.0)
grid.SetDimensions(nx,ny,1)
grid.SetPoints(points)
source.SetExecuteMethod(Execute)
map = vtk.vtkDataSetMapper() map.SetInput(source.GetStructuredGridOutput())
act = vtk.vtkActor() act.SetMapper(map)
ren = vtk.vtkRenderer() ren.AddActor(act)
renwin = vtk.vtkRenderWindow() renwin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renwin) iren.Start()