[vtkusers] Array for vtkPoints?

David Gobbi david.gobbi at gmail.com
Fri Nov 26 16:09:41 EST 2010


Hi Ambar,

There is a VTK class called vtkCollection that can hold an array of
vtkObjects, but it has a poor user interface so I can't really recommend it.

Most people use a vector of smart pointers, like this:

vtkstd::vector<vtkSmartPointer<vtkPoints> > pointVector;

You can add to the vector like this:

points = vtkPoints::New();
// add all points
pointVector.push_back(points);
points->Delete();

The "Delete()" is bookkeeping for the garbage collector.  After you push the
points onto pointsVector, the pointsVector owns the reference so you have to
delete the local reference.

  David

On Fri, Nov 26, 2010 at 1:27 PM, Ambar C <ambarc at gmail.com> wrote:

> Hello,
>
> I'm currently coding a project that needs me to keep creating vtkPoint
> objects in a loop as I get data. I don't know how much data I'm going
> to get so I need a way to keep track of all of my different point
> groups. Is there some kind of stack or array in vtk that will allow me
> to keep adding on my points (while creating vtkPoint inside the loop)
> and still having them in scope after the loop? Please feel free to ask
> questions.
>
> Cheers.
> _______________________________________________
> 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/20101126/7beb62b7/attachment.htm>


More information about the vtkusers mailing list