[vtkusers] Difference between vtkSmartPointer assignment operator and ShallowCopy

Oleksandr Malyushytsky omalyushytskyvtkuser at gmail.com
Wed Oct 24 20:15:29 EDT 2018


vtkSmartPointer has nothing to do with neither deep or shallow copy.

if you assign vtk object to smartpointer the reference count of vtk object
is incremented,
there is only one vtkObject in the memory. Once smartpointer is released
(going out of scope  for example) vtk object reference count  it was
pointing is decremented.
In another words vtkSmartPointer is like a normal pointer, which adds does
reference couning.

Operations with smartpointer DO NOT copy any data related to the object
they point to.


While deep and shalow copy are always performed with 2 different objects.





On Wed, Oct 24, 2018 at 3:19 PM Berti Krüger <berti_krueger at hotmail.com>
wrote:

> Hello.
>
> I (hopefully) already understand the difference between the ShallowCopy
> and the DeepCopy method (e.g. copying only the pointer vs. copying the
> pointer and the content pointed to).
>
> But what i don't understand yet is, what is the difference between using
> the overloaded assignment operator of vtkSmartPointer and the ShallowCopy
> method, e.g. what is the difference between
>
>
> vtkSmartPointer<vtkPolydata> myStrangePolydata =
> vtkSmartPointer<vtkPolydata>::New();
>
>
> myStrangePolydata = vtkTransmogrifyFilter->GetOutput();
>
>
> and
>
>
> myStangePolydata->ShallowCopy(vtkTransmogrifyFilter->GetOutput();
>
>
>
> Does it make a difference to the reference count of the vtkSmartPointer?
>
>
> Thank you very much in advance.
>
>
> Cheers,
> Berti
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20181024/14a79d7e/attachment.html>


More information about the vtkusers mailing list