[vtkusers] vtkPoints array management

Francois Bertel francois.bertel at kitware.com
Fri Sep 11 12:27:51 EDT 2009


For direct access to the raw pointer of the c array, use
points->GetVoidPointer(0)

ref:
http://www.vtk.org/doc/nightly/html/classvtkPoints.html#6790380ebdd771dd29a9b69a254fb53e

On Fri, Sep 11, 2009 at 12:15 PM, Fred Fred <stan1313 at hotmail.fr> wrote:
> Ok thank you for the tip but this involves a copy of the points, I would
> have appreciated a way of traversing the list of points while avoiding
> copies.
>
>> Date: Fri, 11 Sep 2009 10:20:36 -0400
>> Subject: Re: [vtkusers] vtkPoints array management
>> From: bill.lorensen at gmail.com
>> To: stan1313 at hotmail.fr
>> CC: vtkusers at vtk.org
>>
>> 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
>> >
>> >
>
> ________________________________
> Vous cherchez l'intégrale des clips de Michael Jackson ? Bing ! Trouvez !
> _______________________________________________
> 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
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list