[vtkusers] Using vtkRectilinearGrid for a 1D grid...

Derek Gaston friedmud at gmail.com
Sat Jul 7 21:44:21 EDT 2012


Looking at the documentation for vtkRectilinearGrid it makes it sound like
vtkRectilinearGrid should be able to generate 1D and 0D grids: "Also, you
must supply coordinates in all three directions, even if the dataset
topology is 2D, 1D, or 0D."

However... when I try to use this capability... nothing is getting
rendered.  3D and 2D grids with vtkRectilinear grid are just fine... but 1D
and 0D aren't coming out at all.

Why would I want to use vtkRectilinearGrid for 1D and 0D?  It's because I
have some nice general code to draw cubes/squares/lines/points depending on
user input... and it relies on vtkRectilinearGrid.  Of course I could
specialize 1D and 0D to do something else... but I like the generic
algorithm I have now...

Here's some (python) code along the lines of what I am using:

    x_coord = vtk.vtkFloatArray()
    x_coord.InsertNextValue(0.0)
    x_coord.InsertNextValue(1.0)
    x_coord.InsertNextValue(2.0)

    y_coord = vtk.vtkFloatArray()
    y_coord.InsertNextValue(0.0)

    z_coord = vtk.vtkFloatArray()
    z_coord.InsertNextValue(0.0)

    grid = vtk.vtkRectilinearGrid()
    grid.SetDimensions(3,1,1)
    grid.SetXCoordinates(x_coord)
    grid.SetYCoordinates(y_coord)
    grid.SetZCoordinates(z_coord)

    self.mapper = vtk.vtkDataSetMapper();
    self.mapper.SetInput(grid);

    self.actor = vtk.vtkActor();
    self.actor.SetMapper(self.mapper);
    self.actor.GetProperty().SetPointSize(4)
    self.actor.GetProperty().SetEdgeColor(0,0,0)
    self.actor.GetProperty().SetAmbient(0.3);

And then adding that actor to the renderer, etc...

Thanks for any help!

Derek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120707/b4bb579a/attachment.htm>


More information about the vtkusers mailing list