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

Schlottke, Michael M.Schlottke at aia.rwth-aachen.de
Tue Apr 28 02:54:38 EDT 2015


Hi Utkarsh,

Thank you very much for this answer, it clears things up a lot. Am I right to sum this up as a rule of thumb to

“use SetInputConnection whenever possible, resort to SetInputData where it isn’t”

for most use cases?

On a related note, I’ve encountered a few filters with code like this:

//////////////////////////////////////////////////////////////
vtkMyFilter::RequestData(….)
{
  …
  vtkCellDataToPointData* cp = vtkCellDataToPointData::New();
  ...
  vtkUnstructuredGrid* pdata = cp->GetUnstructuredGridOutput();
  pdata->GetPointData()->RemoveArray(“arrayname");                         
  pdata->GetPointData()->Update(); 
  pdata->Update(); // will not compile with VTK6 (******)

  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;
}
//////////////////////////////////////////////////////////////

I am wondering about the line marked with (******). Is it obsolete with VTK6 (as there is no Update() method for non-vtkAlgorithm objects), should I call cp->Update() instead, or is there something entirely different to do to make this code work properly?

Regards,

Michael

> On 27 Apr 2015, at 19:53 , Utkarsh Ayachit <utkarsh.ayachit at kitware.com> wrote:
> 
>> Now I am wondering: ifinside the RequestData method of a filter, do I *ever*
>> need  to use SetInputConnection, and if yes, how?
> 
> 
> Here's an example:
> 
> vtkMyFilter::RequestData(....)
> {
>   vtkDataSet* myinput = vtkDataSet::GetData(inputInformation[0], 0);
> 
>   vtkNew<vtkSomeFilter> filter1;
>   filter1->SetInputData(myinput);
> 
>   vtkNew<vtkSomeFilter> filter2;
>   filter2->SetInputConnection(filter1->GetOutputPort());
>   ...
> 
>   filter2->Update()
> }
> 
> Thus, for internal pipelines, it makes sense to use SetInputConnection.
> 
>> It seems like all filters
>> I’ve had a look at always access the input data object (which I can only
>> pass on using SetInputData, not SetInputConnection), not the input port.
>> However, as a user with little VTK experience it seems like this might
>> “break” the aforementioned pipeline?
> 
> It the example I gave, for example, if you use SetInputData() to pass
> the output of filter1 to filter2, you'll need to call
> filter1->Update() before doing that. Otherwise, filter1 has not
> execute and hence doesn't have valid data to pass to filter2. Unlike
> the old SetInput(), setting the dataset using SetInputData() doesn't
> preserve the pipeline information i.e. filter2 will not update filter1
> just because you called filter2->Update() if SetInputData() is used to
> pass the data.
> 
> Hope that clarifies it a little.



More information about the Paraview-developers mailing list