[vtkusers] the question about smart pointer

David Gobbi david.gobbi at gmail.com
Sat Nov 3 12:35:47 EDT 2018


Hi Frank,

Yes, the output is a normal pointer, and the changer just gets the
pointer to the output, it doesn't get a copy of the output.

However: when the changer gets the output, it increments the
reference count of the output.  So now there are two references
to the output: one from the reader, and one from the changer.
So the existence of the output depends on both the reader and
the changer: the output will not destruct until both the reader and
the changer have destructed.

As I stated in my previous email, the important point is that the
reference count is stored within the VTK object itself.  An object
doesn't need a smart pointer in order to have a reference count.
Even a VTK object pointed to by a normal pointer will have a
reference count that can be incremented/decremented by other
VTK objects.

 David

On Fri, Nov 2, 2018 at 6:28 PM Franks <masterwangzx at gmail.com> wrote:

> Thank you for getting back to me. I still have some question about it. As
> to VTK/Tutorials, it may run like you said when I write *vtkSmartPointer
> pd = Reader->GetOutput();* . However, the output is just a normal
> pointer, so it may depend on the reader. I may misunderstand the tutorials,
> you can check out this link
> https://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers (under the title *Getting
> an Object with a Smart Pointer* ). Does the changer get a copy of output?
>
> Thank you for your attention to this matter.
> Frank
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20181103/0d89c1e7/attachment.html>


More information about the vtkusers mailing list