[Paraview-developers] Replacement of SetInput with SetInputData (VTK5 vs. 6)

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Tue Apr 28 09:58:33 EDT 2015


Michael,

Let me give you some background.

Once upon a time, the way to connect an upstream filter/source to a
downstream filter was via the data object produced by the upstream
filter.
e.g.

  filterDownStream->SetInput(filterUpStream->GetOutput());

This meant that a data object obtained from filter::GetOutput() always
was aware of which source/filter produced it (or can produce it).

Hence methods like "vtkDataObject::Update()" could be used to update
the producer pipeline from a pointer to the output data object. Hence,
in your example, "pdata->Update()" worked.

That has now changed it VTK 6. The data object no longer keeps track
of which producer is producing it. There are several
reasons/advantages for that, but I'll not go into those here. Hence,
while you can still set a data object as an input to a filter, since
the data object doesn't know about its producer, it doesn't have any
information about the upstream pipeline and hence will not update it
on demand when the downstream filter is updated.

A way of fixing your code is as follows:

//////////////////////////////////////////////////////////////
vtkMyFilter::RequestData(….)
{
  …
  vtkCellDataToPointData* cp = vtkCellDataToPointData::New();
  ...

  cp->Update(); // will not compile with VTK6 (******)

  vtkUnstructuredGrid* pdata = cp->GetUnstructuredGridOutput();

  vtkInformation *outInfo = outputVector->GetInformationObject(0);
  vtkUnstructuredGrid *output =
vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
  output->SetPoints(pdata->GetPoints());
  output->CopyStructure(pdata);
  output->GetCellData()->PassData(pdata->GetCellData());

  return 1;
}
//////////////////////////////////////////////////////////////


More information about the Paraview-developers mailing list