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

Schlottke, Michael M.Schlottke at aia.rwth-aachen.de
Thu Apr 30 01:20:33 EDT 2015


Hi Utkarsh,

Thank you for helping me understand better how the VTK pipeline works. Just to be sure: even though the data object is modified (directly, not through an algorithm object) after the call to cp->Update(), I can safely pass it on further (in this case to the output data object) without having to call Update() again on its producer?

Michael

//////////////////////////////////////////
cp->Update();
vtkUnstructuredGrid* pdata = cp->GetUnstructuredGridOutput();
pdata->GetPointData()->RemoveArray(“arrayname");                         
…
// Do I need to call cp->Update() again here?
output->SetPoints(pdata->GetPoints());
//////////////////////////////////////////

> On 28 Apr 2015, at 15:58 , Utkarsh Ayachit <utkarsh.ayachit at kitware.com> wrote:
> 
> 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