[vtk-developers] Do I need to delete an object when I create a smart pointer of it?

Mingcheng Chen linyufly at gmail.com
Sun Mar 29 12:11:50 EDT 2015


Hi Jorge,

Thank you very much!

-Mingcheng

On Sun, Mar 29, 2015 at 11:06 AM, Jorge Perez <josp.jorge at gmail.com> wrote:

> Hi, you can read here about that topic
> http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers
>
> HTH
>
> 2015-03-29 18:00 GMT+02:00 Mingcheng Chen <linyufly at gmail.com>:
>
>> Hello,
>>
>> I am always prudent when using VTK, i. e. I never mix the smart pointer
>> and normal pointer of VTK objects.
>>
>> I have a concern. Suppose we have
>>
>> vtkPolyData *mesh = some_function_which_returns_vtkPolyData_star(...);
>> vtkSmartPointer<vtkPolyData> mesh_ptr =
>> vtkSmartPointer<vtkPolyData>(mesh);
>>
>> we should do mesh_ptr->Delete() after, right?
>>
>> However, can we do
>>
>> vtkSmartPointer<vtkPolyData> mesh_ptr =
>> vtkSmartPointer<vtkPolyData>(some_function_which_returns_vtkPolyData_star(...));
>>
>> ?
>>
>> If we do that, how can we delete the reference count to the object before
>> passing it to vtkSmartPointer?
>>
>> Thanks!
>>
>> -Mingcheng
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>
>>
>>
>


-- 
Research Assistant in Graphics Group
University of Illinois at Urbana-Champaign
http://mingchengchen.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150329/33dd1bd3/attachment.html>


More information about the vtk-developers mailing list