[vtkusers] vtkPoints array management

Bill Lorensen bill.lorensen at gmail.com
Fri Sep 11 10:20:36 EDT 2009


Avoid using GetPoint(id). It calls this->GetData->GetTuple(id). The
comments for GetTuple say it all...
  // Description:
  // Get the data tuple at ith location. Return it as a pointer to an array.
  // Note: this method is not thread-safe, and the pointer is only valid
  // as long as another method invocation to a vtk object is not performed.
  virtual double *GetTuple(vtkIdType i) = 0;

Use
double pts0[3];
points->GetPoint(0, pts0);

double ptsn[3];
points->GetPoint(1, ptsn);

Bill

On Fri, Sep 11, 2009 at 8:52 AM, Fred Fred <stan1313 at hotmail.fr> wrote:
> Look at this men:
>
>   vtkPoints *points = vtkPoints::New();
>   [...some point adding steps...]
>   int numPts = points->GetNumberOfPoints();
>   printf("numPts=%d\n", numPts);
>   double *pts0 = points->GetPoint(0);
>   double *ptsn = points->GetPoint(1);
>   printf("%p %p\n", pts0, ptsn);
>
> which leads:
>
> numPts=11
> 0x19982c40 0x19982c40
>
> Whatever the possibility I Made some mistake anywhere, I can not understand
> how this is possible!
> GetPoint(0) returns the same address as GetPoint(1) while there are 11
> points in the array!!!
>
>
> ________________________________
> Messenger débarque dans Hotmail ! Essayez-le !
> _______________________________________________
> 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