[vtkusers] get reference of point array in vtkPolyData

David Doria daviddoria at gmail.com
Wed Nov 14 10:15:40 EST 2012


On Wed, Nov 14, 2012 at 9:54 AM, abusq <albert.busque at gmail.com> wrote:

> Hi everyone, here's my question:
> I have a polydata object with all my points and i would like to get the
> reference of array containing the tuples/points.
> Just like polydata->GetAllPoints(double **) or something...
> Is it possible? and how?
>
> Thanks
>

You can do something like this:


#include <vtkSmartPointer.h>

#include <vtkPoints.h>


int main (int , char *[])

{

  vtkSmartPointer<vtkPoints> points =

    vtkSmartPointer<vtkPoints>::New();


  points->InsertNextPoint(1,2,3);

  points->InsertNextPoint(4,5,6);


  float* data = reinterpret_cast<float*>(points->GetVoidPointer(0));


  for(unsigned int i = 0; i < 6; ++i)

  {

    std::cout << data[i] << " ";

  }


  std::cout << std::endl;

}


David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121114/74612c2d/attachment.htm>


More information about the vtkusers mailing list