[vtkusers] Does vtkInformation::Set(DATA_OBJECT, ...) perform a deep copy?

Berk Geveci berk.geveci at kitware.com
Mon Apr 29 09:20:24 EDT 2013


It does a shallow copy. The information object holds a strong reference to
the data object so

outputInfo->Set(vtkDataObject::DATA_OBJECT(),MyDataSet);

so it will increment the reference count of MyDataSet preventing it from
going out of scope.

-berk


On Sun, Apr 28, 2013 at 11:41 AM, Sunrise <helios.corona at gmail.com> wrote:

>  I am wondering if the "Set" method in vtkInformation class performs a
> deep-copy or shallow-copy when I set a DATA_OBJECT into it?
>
> Suppose I have some vtkDataSet and I want to append them into outputInfoof a filter inside its
> RequestData method.
>
> int Filter1::RequestData(...)
> {
>     vtkSmartPointer<vtkSomeReader> myreader =
> vtkSmartPointer<vtkSomeReader>::New();
>     ...
>     vtkDataSet *MyDataSet = Reader->GetOutput();
>     outputInfo->Set(vtkDataObject::DATA_OBJECT(),MyDataSet);
>     ...
> }
>
> at the end of RequestData, both the pointer myreader and its data on the
> heap would be out of scope. Since I made them smart pointers, both pointer
> "myreader" and the data on the heap will be deleted (right?).
>
> But in the next filter of the pipeline (say Filter2 is connected to
> Filter1), I can receive the data in inputInfo
>
> int Filter2::RequestData(...)
> {
>     ...
>     ... inputInfo->Get(vtkDataObject::DATA_OBJECT());
> }
>
> I am wondering why still I can get the data, since data deferenced by
> MyDataSet in previous filter no longer exists?
>
> Does vtkInformation::Set perform a deep copy?
>
> Thank you.
>
> _______________________________________________
> 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://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130429/aa8bd536/attachment.htm>


More information about the vtkusers mailing list