[vtkusers] Initialising arrays of pointers to vtkPolyData, etc.

David Doria daviddoria+vtk at gmail.com
Mon Dec 7 10:12:55 EST 2009


On Mon, Dec 7, 2009 at 8:55 AM, Marcus Thamson <markie_thomson at yahoo.de>wrote:

> Dear David,
>
> Many thanks!  - that seems to work fine with the vtkSmartPointer's and the
> vtkstd::vector.
>
> As an amateur C programmer (who incrementally learns C++ only on a need-to
> basis), I found the example code (from your link) quite freaky to begin
> with.
> I am now using vtkSmartPointer to make arrays of all the intermediate
> surface objects (vtkDoubleArray, vtkPolyData, vtkPoints, vtkCellArray,
> vtkPolyDataMapper,vtkActor) - I hadn't seen code before where one uses the
> same variable name in a loop over and over, e.g.
>
>  for (is=0; is<Ns;is++) {
> ...
>  vtkSmartPointer<vtkPolyData> surf = vtkSmartPointer<vtkPolyData>::New();
> ...
> }
>
> I guess those pointers really are "smart".  After searching around, it
> appears that vtkSmartPointer's do not even need to be Delete'd at the end of
> the code.
>
> Many thanks,
> MT
>
>
>
I'm glad it helped. We're working on a smart pointer tutorial:
http://www.vtk.org/Wiki/Smart_Pointers

it is certainly not polished/finished, but it may help you get started.

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091207/1dc05cbe/attachment.htm>


More information about the vtkusers mailing list