Warp exodusII by vector

I am trying to show a deformed mesh that is read in from an exodusII file.
The display of the mesh should update the nodal positions by a vector called “DM”.

I have been successful showing the undeformed mesh and displaying it with a color based on a scalar field in the mesh. To do this I followed the example at the Lorensen github page. However I am really struggling with the use of vtkMultiblockDataSet, the output of vtkExodusIIReader, and vtkWarpVector, which is the suggested route to displaying deformed mesh.

My pipeline is below.

vtkNew<vtkExodusIIReader> exoSource;
exoSource->SetFileName("file.exoII");
exoSource->UpdateInformation();
exoSource->SetTimeStep(0);
exoSource->SetAllArrayStatus(vtkExodusIIReader::NODAL, 1);
exoSource->SetGlobalResultArrayStatus("DM", 1);

vtkNew<vtkWarpVector> meshWarp;
meshWarp->SetInputData(exoSource->GetOutput());
meshWarp->Update();

vtkNew<vtkPolyDataMapper> exoMapper;
exoMapper->SetInputConnection(meshWarp->GetOutputPort());

vtkNew<vtkActor> exoActor;
exoActor->SetMapper(exoMapper);

vtkNew<vtkRenderer> exoRenderer;
exoRenderer->AddActor(exoActor);

The code compiles fine, there are no complaints in the application output, however the renderer displays nothing but the background.

I have also been studying the vtkWarpVector example but I think what I’m missing is how to reconcile the vtkMultiBlockDataSet output by the vtkExodusIIReader with the vtkPolyData input to the vtkWarpVector.

Does anyone have any ideas? Thanks!

I found a solution!

To solve the problem, I had to think about the type of the output from a given stage of the pipeline and match it with the expected input type of the next pipeline stage.

An issue with the above pipeline is vtkExodusIIReader outputs a vtkMultiBlockDataSet while vtkWarpVector expects a vtkPolyData as input. Once I had realized this fundamental nature of vtk, I found vtkCompositePolyDataFilter outputs vtkPolyData and used that as the input to vtkWarpVector, as in the pipeline below.

vtkNew<vtkExodusIIReader> exoSource;
exoSource->SetFileName(“file.exoII”);
exoSource->UpdateInformation();
exoSource->SetTimeStep(0);
exoSource->SetAllArrayStatus(vtkExodusIIReader::NODAL, 1);

vtkNew<vtkCompositeDataGeometryFilter> exoGeometry;
exoGeometry->SetInputConnection(exoSource->GetOutputPort());
exoGeometry->Update();
exoGeometry->GetPointData()->SetActiveVectors(“DM”);

vtkNew<vtkWarpVector> meshWarp;
meshWarp->SetInputData(exoGeometry->GetOutput());
meshWarp->Update();

vtkNew<vtkPolyDataMapper> exoMapper;
exoMapper->SetInputConnection(meshWarp->GetOutputPort());

vtkNew<vtkActor> exoActor;
exoActor->SetMapper(exoMapper);

vtkNew<vtkRenderer> exoRenderer;
exoRenderer->AddActor(exoActor);

With this pipeline, the type of the output of each pipeline stage matches the expected input of the following stage.
Note that in order to successfully ‘Set’ the active vector of the vtkPolyData output by the vtkCompositeDataGeometryFilter, Update() MUST first be called on exoGeometry.