<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Berk,
<div class=""><br class="">
</div>
<div class="">Ah, that is good to know. So my typical setup in RequestData for a custom filter should be something like the following:</div>
<div class=""><br class="">
</div>
<div class="">- connect the first internal filter to the input vtkDataObject using SetInputData()</div>
<div class="">- use SetInputConnection() to chain up any internal filters I use (if possible)</div>
<div class="">- finally, store the results in the output vtkDataObject</div>
<div class=""><br class="">
</div>
<div class="">Is this a good approach to follow under normal circumstances or am I missing something here?</div>
<div class=""><br class="">
</div>
<div class="">Michael</div>
<div class=""><br class="">
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 28 Apr 2015, at 15:50 , Berk Geveci <<a href="mailto:berk.geveci@kitware.com" class="">berk.geveci@kitware.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Replace that Update() with cp->Update().
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">-berk</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Tue, Apr 28, 2015 at 2:54 AM, Schlottke, Michael <span dir="ltr" class="">
<<a href="mailto:M.Schlottke@aia.rwth-aachen.de" target="_blank" class="">M.Schlottke@aia.rwth-aachen.de</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Utkarsh,<br class="">
<br class="">
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<br class="">
<br class="">
“use SetInputConnection whenever possible, resort to SetInputData where it isn’t”<br class="">
<br class="">
for most use cases?<br class="">
<br class="">
On a related note, I’ve encountered a few filters with code like this:<br class="">
<br class="">
//////////////////////////////////////////////////////////////<br class="">
vtkMyFilter::RequestData(….)<br class="">
{<br class="">
  …<br class="">
  vtkCellDataToPointData* cp = vtkCellDataToPointData::New();<br class="">
  ...<br class="">
  vtkUnstructuredGrid* pdata = cp->GetUnstructuredGridOutput();<br class="">
  pdata->GetPointData()->RemoveArray(“arrayname");<br class="">
  pdata->GetPointData()->Update();<br class="">
  pdata->Update(); // will not compile with VTK6 (******)<br class="">
<br class="">
  vtkInformation *outInfo = outputVector->GetInformationObject(0);<br class="">
  vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));<br class="">
  output->SetPoints(pdata->GetPoints());<br class="">
  output->CopyStructure(pdata);<br class="">
  output->GetCellData()->PassData(pdata->GetCellData());<br class="">
<br class="">
  return 1;<br class="">
}<br class="">
//////////////////////////////////////////////////////////////<br class="">
<br class="">
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?<br class="">
<br class="">
Regards,<br class="">
<br class="">
Michael<br class="">
<div class="HOEnZb">
<div class="h5"><br class="">
> On 27 Apr 2015, at 19:53 , Utkarsh Ayachit <<a href="mailto:utkarsh.ayachit@kitware.com" class="">utkarsh.ayachit@kitware.com</a>> wrote:<br class="">
><br class="">
>> Now I am wondering: ifinside the RequestData method of a filter, do I *ever*<br class="">
>> need  to use SetInputConnection, and if yes, how?<br class="">
><br class="">
><br class="">
> Here's an example:<br class="">
><br class="">
> vtkMyFilter::RequestData(....)<br class="">
> {<br class="">
>   vtkDataSet* myinput = vtkDataSet::GetData(inputInformation[0], 0);<br class="">
><br class="">
>   vtkNew<vtkSomeFilter> filter1;<br class="">
>   filter1->SetInputData(myinput);<br class="">
><br class="">
>   vtkNew<vtkSomeFilter> filter2;<br class="">
>   filter2->SetInputConnection(filter1->GetOutputPort());<br class="">
>   ...<br class="">
><br class="">
>   filter2->Update()<br class="">
> }<br class="">
><br class="">
> Thus, for internal pipelines, it makes sense to use SetInputConnection.<br class="">
><br class="">
>> It seems like all filters<br class="">
>> I’ve had a look at always access the input data object (which I can only<br class="">
>> pass on using SetInputData, not SetInputConnection), not the input port.<br class="">
>> However, as a user with little VTK experience it seems like this might<br class="">
>> “break” the aforementioned pipeline?<br class="">
><br class="">
> It the example I gave, for example, if you use SetInputData() to pass<br class="">
> the output of filter1 to filter2, you'll need to call<br class="">
> filter1->Update() before doing that. Otherwise, filter1 has not<br class="">
> execute and hence doesn't have valid data to pass to filter2. Unlike<br class="">
> the old SetInput(), setting the dataset using SetInputData() doesn't<br class="">
> preserve the pipeline information i.e. filter2 will not update filter1<br class="">
> just because you called filter2->Update() if SetInputData() is used to<br class="">
> pass the data.<br class="">
><br class="">
> Hope that clarifies it a little.<br class="">
<br class="">
_______________________________________________<br class="">
Powered by <a href="http://www.kitware.com/" target="_blank" class="">www.kitware.com</a><br class="">
<br class="">
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank" class="">
http://www.kitware.com/opensource/opensource.html</a><br class="">
<br class="">
Search the list archives at: <a href="http://markmail.org/search/?q=Paraview-developers" target="_blank" class="">
http://markmail.org/search/?q=Paraview-developers</a><br class="">
<br class="">
Follow this link to subscribe/unsubscribe:<br class="">
<a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank" class="">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>