[vtkusers] Correct usage of vtkRectilinearGrid

brownrigg at sunflower.com brownrigg at sunflower.com
Thu Jan 8 12:54:55 EST 2009


Hello VTK community!

I'm hoping someone can tell me the proper way to use a vtkRectilinearGrid.  I have some geospatial data that is structured as a regular grid, and am trying to extract isosurfaces from it using vtkContourFilter. My first attempt was to use a rectilinear grid, as one can associate meaningful coordinates with the grid (eg., units of lon/lat/alt), and the resultant isosurface polygons will reflect those coordinates (this is in contrast to using a vtkImageData, where the polygon vertices are in units of the cell grid).

If I do:
  grid = vtk.vtkRectilinearGrid()
  grid.SetDimensions(XDIM, YDIM, ZDIM)
  grid.SetXCoordinates(xcoords)
  grid.SetYCoordinates(ycoords)
  grid.SetZCoordinates(zcoords)
  grid.GetPointData().SetScalars(dataPoints)
...
  iso = vtk.vtkContourFilter()
  iso.SetInput(grid)
  iso.GenerateValues(6, dataMin, dataMax)

I get nothing!  If I simply replace the definition of "grid" to:

  grid = vtk.vtkImageData() 
  grid.SetDimensions(XDIM, YDIM, ZDIM)
  grid.GetPointData().SetScalars(dataPoints)

and feed that into vtkContourFilter as before, I get my isosurfaces!   I'm sure all the arrays and values used in the rectilinear grid are properly set up.

What am I doing wrong?

Thanks
Rick Brownrigg





More information about the vtkusers mailing list