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

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


Hi Berk,

Ah, that is good to know. So my typical setup in RequestData for a custom filter should be something like the following:

- connect the first internal filter to the input vtkDataObject using SetInputData()
- use SetInputConnection() to chain up any internal filters I use (if possible)
- finally, store the results in the output vtkDataObject

Is this a good approach to follow under normal circumstances or am I missing something here?

Michael

On 28 Apr 2015, at 15:50 , Berk Geveci <berk.geveci at kitware.com<mailto:berk.geveci at kitware.com>> wrote:

Replace that Update() with cp->Update().

The rule for internal filters is that you should never use SetInputConnection() to connect anything to an external filter from within RequestData(). You don't want internal pipeline executions to propagate to external filters as it may cause all kinds of problems. SetInputData() does not create a pipeline connection so it is safe to use in such circumstances. SetInputConnection() is safe to connect internal filters to each other.

Best,
-berk

On Tue, Apr 28, 2015 at 2:54 AM, Schlottke, Michael <M.Schlottke at aia.rwth-aachen.de<mailto:M.Schlottke at aia.rwth-aachen.de>> wrote:
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<mailto: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.

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com/>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=Paraview-developers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview-developers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20150430/b269a558/attachment-0001.html>


More information about the Paraview-developers mailing list