[vtkusers] SetInputData migration VTK 6

Berk Geveci berk.geveci at kitware.com
Tue Jul 22 20:10:39 EDT 2014


It is correct that SetInputData() does not connect the pipeline. To be more
specific, consider 2 examples:

1)

polydata = someFilter->GetOutput();

anotherFilter->SetInputData(polydata)
anotherFilter->Update();

someFilter->Modified();
anotherFilter->Update();

Update() would not propagate a pipeline request to someFilter. So the
output of anotherFilter will not change between the 2 Update() calls.

2)

polydata = giveMePolyData();

anotherFilter->SetInputData(polydata)
anotherFilter->Update();

// modify the polydata somehow
polydata->Modified();

anotherFilter->Update();

In this case, because the polydata changed, the second Update() will
actually have an effect and the output of anotherFilter will change after
the 2nd Update.


So the change to your code will depend on the nature of "polydata". Is it
still the output of a filter? Then you must use SetInputConnection().
Unfortunately, this sometimes means that you need to change function
signatures to pass an (algorithm, port index) pair around instead of a data
object.

If polydata is a stand-alone data object that is modified directly by some
code and as a result its mtime is updated, you can use SetInputData(). Keep
in mind that the producer of the data object is now completely out of the
pipeline and will not see any pipeline updates.

I don't know the details of how data is stored in MRML. If you add a
polydata to a MRML node and expect it to represent the output port of a
filter such that you can do this:

vtkMRMLModelNode->SetAndObservePolyData(vtkTubeFilter->GetOutput())

vtkTubeFilter->SetSomething();

polydata = get_MRML_node_somehow();
polydata->Update(); // should cause vtkTubeFilter to re-execute

The MRML code will have to change to store the algorithm and output port
index instead. There is no longer any way to get from a data object to its
producer. In fact, vtkDataObject is now in a module (library) that doesn't
know anything about algorithms or pipelines.

Best,
-berk






On Tue, Jul 22, 2014 at 7:07 PM, Laurent Chauvin <lchauvin at bwh.harvard.edu>
wrote:

> Hi Sam,
>
> Thank you for your answer.
>
> Here is my pipeline (just an overview):
>
> vtkSplineFilter->SetInputData(polydata)
>
> vtkTubeFilter->SetInputConnection(vtkSplineFilter->GetOutputPort())
>
> vtkMRMLModelNode->SetAndObservePolyData(vtkTubeFilter->GetOutput())
>
> I would like to have one vtkMRMLModelNode with one polydata.
> The problem if I do what you suggested, is all my vtkMRMLModelNodes are
> gonna observe TubeFilter. So when I will modify my polydata and call
> vtkSplineFilter->Update() and vtkTubeFilter->Update(), all my
> vtkMRMLModelNodes will be updated, but I only want the last one to be.
> Should I do a copy of the output of vtkTubeFilter instead ? to avoid they
> all change when I update the TubeFilter ?
>
> Thank you.
> -Laurent
>
>
>
> On Tue, Jul 22, 2014 at 7:02 PM, Sam Raby <rabysam28 at gmail.com> wrote:
>
>> Hi Laurent,
>>
>> After feeding the vtkPolyData into the vtkSplineFilter by SetInputData
>> and setting the parameters of the filter, did you try to manually update
>> the vtkSplineFilter?
>>
>>
>>
>>
>> On Tue, Jul 22, 2014 at 4:55 PM, Laurent Chauvin <
>> lchauvin at bwh.harvard.edu> wrote:
>>
>>> Hello,
>>>
>>> I created a pipeline with a vtkSplineFilter, with a polydata as input.
>>>  However, now that I try to make it compatible with VTK 6, it's not
>>> working anymore.
>>>
>>> I replaced SetInput by SetInputData, and I read that SetInputData
>>> doesn't create the pipeline. That's probably why now, when I update my
>>> polydata, it's not updating the spline.
>>> But I was wondering then how should I do to keep creating the pipeline
>>> then ?
>>>
>>> I read to use SetInputConnection, but I think SetInputConnection take as
>>> argument the OutputPort of another filter, but the spline is the 'entry
>>> point' of my pipeline, taking a polydata as input, and applying some
>>> filters on it.
>>>
>>> How could I do to update the pipeline when modifying the polydata ?
>>>
>>> Thank you.
>>> -Laurent
>>>
>>> --
>>> Laurent Chauvin, MS
>>> Surgical Navigation and Robotics Laboratory, Radiology Department
>>> Brigham And Women's Hospital, Harvard Medical School
>>> http://wiki.ncigt.org/index.php/User:Lchauvin
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>
>>>
>>  The information in this e-mail is intended only for the person to whom
>> it is
>> addressed. If you believe this e-mail was sent to you in error and the
>> e-mail
>> contains patient information, please contact the Partners Compliance
>> HelpLine at
>> http://www.partners.org/complianceline . If the e-mail was sent to you
>> in error
>> but does not contain patient information, please contact the sender and
>> properly
>> dispose of the e-mail.
>>
>
>
>
> --
> Laurent Chauvin, MS
> Surgical Navigation and Robotics Laboratory, Radiology Department
> Brigham And Women's Hospital, Harvard Medical School
> http://wiki.ncigt.org/index.php/User:Lchauvin
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140722/d98ad4fa/attachment.html>


More information about the vtkusers mailing list