[vtkusers] About the vtk pipeline ...

Sebastien Auclair sxa at fluent.com
Mon Jan 20 16:39:00 EST 2003


Hi again !

NOTE: This is a simple question that may seem conplex when expressed ! I'll
try to make it clear. I provide and code example to illustrate what i mean.

Basicaly, how can we use VTK to manipulate data through VTK's display
features.(scalling, translating, rotating, etc.)
In all the examples that comes with VTK, the pipeline is created, displayed
and destroyed. Of course, in a real OOP scenario, we'd want to do a little
more.

Our question is about the transformation that occurs to an object during the
display phase? How can we get our hands on what's happening to the geometry
of our actors ?
If i scale a cube created from a RectilinearGrid, will the pipeline be
updated entirely? (i.e. Will the grid variable be transformed ?)

Consider this simplified piece of code : (Small pipeline ...)

###################  THIS IS A CLASS FOR REPRESENTING A VOXEL
#################################################
CVoxel::CVoxel(fload minX, fload maxX, float minY, float maxY, float minZ,
float maxZ)
{

     m_xCoords = vtkFloatArray::New();
     m_yCoords = vtkFloatArray::New();
     m_zCoords = vtkFloatArray::New();

     m_xCoords->InsertNextValue(minX); // 0
     m_xCoords->InsertNextValue(maxX); // 10

     m_yCoords->InsertNextValue(minY); // 0
     m_yCoords->InsertNextValue(maxY); // 10

     m_zCoords->InsertNextValue(minZ); // 0
     m_zCoords->InsertNextValue(maxZ); // 10


     m_rgrid = vtkRectilinearGrid::New();
        m_rgrid->SetDimensions(2,2,2);
        m_rgrid->SetXCoordinates(m_xCoords);
        m_rgrid->SetYCoordinates(m_yCoords);
        m_rgrid->SetZCoordinates(m_zCoords);


     m_geom = vtkGeometryFilter::New();
        m_geom->SetInput(m_rgrid);
        m_geom->SetExtent(0,1, 0,1, 0,1);

     m_rgridMapper = vtkPolyDataMapper::New();
     m_rgridMapper->SetInput(m_geom->GetOutput());

     m_actor = vtkLODActor::New();
     m_actor->SetMapper(m_rgridMapper);
     m_actor->GetProperty()->SetRepresentationToSurface();

    RenderThis(this); // A function that manage the Render Window and other
stuff...
}
############################################################################
##########################

Now if in this code, we add an observer (AnyEvent) to the member variable
m_rgrid, will it be triggered if i scale the CUBE with the mouse ?

We need, at some point, to get the same initial minX, maxX, etc. but so that
they correspond to the new geometric reality of the CUBE after being
displayed and then potentially scalled, rotated, resized etc...
We don't just want to display data. We need VTK to help us modify it.

Thanks !





More information about the vtkusers mailing list