[vtkusers] How to get data ptr from the vtkpolydata?

David Doria daviddoria at gmail.com
Wed Sep 17 07:56:07 EDT 2014


On Wed, Sep 17, 2014 at 7:52 AM, Lin M <majcjc at gmail.com> wrote:

> Thank you for your advice, David.
>
> I made a mistake, m_SkullMesh is a vtkOBJReader and the
> m_SkullMesh->GetOutput() should be a vtkPolyData.
>
> I hope to get the point array of it. The code I wrote before could work
> properly
>
> int meshNum = m_SkullMesh->GetOutput()->GetNumberOfPoints();
> double *skullTemplate = new double[3*meshNum];
> for(int i = 0; i < meshNum; ++i) {
> double* temp = m_SkullMesh->GetOutput()->GetPoint(i);
> skullTemplate[3*i] = temp[0];
> skullTemplate[3*i+1] = temp[1];
> skullTemplate[3*i+2] = temp[2];
> }
>
> But I think it should have a better way to avoid the copy and get the data
> pointer directly. Can you give me some suggestion? Thank you!
>
> Best,
> Lin
>

Again, please post compilable code. My first guess would be that you did
not update the reader before using the data you are expecting from
GetOutput(). Try adding a m_SkullMesh->Update() before the block of code
you've posted.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140917/4cd9630f/attachment.html>


More information about the vtkusers mailing list