Interactive display the results of a VTK pipeline in 3D

Shows how to display the result of a VTK pipeline on a mesh without modifying the original data.

How to temporarily display the output of a vtk filter

This method avoid the creation of a new Component : the output of a vtk filter can be displayed by only changing the data connection of the initial Component.

The Geometry service getDataPort() and setDataConnection() allow you to temporarily connect the VTK pipeline between the original data and the visualization. The VTK pipeline is added without modifying the initial mesh data, but its results will be seen in the 3D viewers.

This means you can visualize the result of a VTK pipeline while interactively modifying the parameters of your algorithm and without keeping a copy of your initial data.

Example with a clip filter :

vtkSmartPointer <vtkClipDataSet> filter = vtkSmartPointer <vtkClipDataSet>::New();

filter->SetInputConnection(targetMesh->getDataPort());
...
// set the clip function
...
filter->Update();
targetMesh->setDataConnection(filter->GetOutputPort());

The initial mesh is unchanged, every modification of the parameters can be immediately used to interactively check the output difference.

Once the user clicks on Apply, you just need to (deep or not) copy the pipeline output and either

  • use this output to create a new MeshComponent
  • modify the initial point set of the processed component