[vtkusers] Polydata get point coordinates

Eric E. Monson emonson at cs.duke.edu
Fri Oct 15 14:47:50 EDT 2010


Hey Sara,

The method David advised may be the most direct for you, but I just wanted to point out that polyData->GetPoints() should return a vtkPoints object, not just point IDs. You should be able to use one of the GetPoint() variations of vtkPoints to get the coordinates from that, too.

http://www.vtk.org/doc/nightly/html/classvtkPoints.html

-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Oct 15, 2010, at 2:26 PM, David Doria wrote:

> On Fri, Oct 15, 2010 at 2:13 PM, Sara Rolfe <smrolfe at u.washington.edu> wrote:
>> Hello,
>> I'm trying to get the 3D coordinates of polydata points.  I have been
>> used polyData->GetPoints();, which returns the point ID, but not the
>> location.  How can I access this information?
>> Thanks,
>> Sara
> 
> This should do the trick:
> 
> for(vtkIdType i = 0; i < polydata->GetNumberOfPoints(); i++)
>  {
>  double p[3];
>  polydata->GetPoint(i, p);
>  std::cout << "Point " << i << " : " << p[0] << " " << p[1] << " " <<
> p[2] << std::endl;
>  }
> 
> David
> _______________________________________________
> 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




More information about the vtkusers mailing list