This example shows how to implement support for a particular dataflow framework. Our victim is VTK, a 3D visualization toolkit, which uses a data pipeline to move data from a source to the display (with possible transformations, scene construction etc. on the way). For example, here is an excerpt from a VTK tutorial that sets up a whole source->render window pipeline:

// allocate components
vtkConeSource *cone = vtkConeSource::New();
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
vtkActor *coneActor = vtkActor::New();
vtkRenderer *ren1= vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();

// make the connections
coneMapper->SetInputConnection( cone->GetOutputPort() );
coneActor->SetMapper( coneMapper );
ren1->AddActor( coneActor );
renWin->AddRenderer( ren1 );

Our goal will be to simplify the connection-making code by providing Dataflow support for VTK. With that in place, we will be able to use the following connection code:

// make the connections
connect(*cone, *coneMapper);
connect(*coneMapper, *coneActor);
connect(*coneActor, *ren1);
connect(*ren1, *renWin);

or even more concisely and clearly,

// make the connections
*cone >>= *coneMapper >>= *coneActor >>= *ren1 >>= *renWin;

Once we have the VTK support layer built, we can include it in any VTK application and start using the Dataflow library with VTK objects. In addition to the simpler syntax, this also allows us to use anything built on top of the generic layer - like Dataflow.Blueprint, or the GUI editor currently under development.

Next

Setting up the Tag