[vtkusers] vtkPoints + InsertPoint
David Doria
daviddoria+vtk at gmail.com
Fri Mar 12 09:21:44 EST 2010
On Fri, Mar 12, 2010 at 8:48 AM, Bill Chivas <noo134 at googlemail.com> wrote:
> Thank you for your replies.
>
> To everyone:
> I did some tests and i think there is a bug.
> Let's say i have the following:
>
> vtkPoints *points = vtkPoints::New();
> points->InsertPoint(609836, x, y, z);
> points->InsertPoint(609837, x, y, z);
> points->InsertPoint(609839, x, y, z);
> points->InsertPoint(609838, x, y, z);
>
> The points->GetNumberOfPoints() gives 609840.
> So it supposes that the ids are starting from 0 and it returns (the max_id
> of all points plus 1) ?
>
>
>
I believe the problem is that you are not calling SetNumberOfPoints before
you start inserting points.
This code works for me:
#include <vtkSmartPointer.h>
#include <vtkPoints.h>
int main(int argc, char *argv[])
{
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
points->SetNumberOfPoints(610000);
points->InsertPoint(609836, 1, 2, 3);
points->InsertPoint(609837, 4, 5, 6);
return EXIT_SUCCESS;
}
On a separate note, I strongly recommend using SmartPointer's instead of
regular points (I used it in the example above).
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100312/a1a1bbb6/attachment.htm>
More information about the vtkusers
mailing list