What is the usage of the first Parameter of vtkPoints::SetPoint method?

Hi Everyone,

I am coming from a VisIt visualization world, with some experience on VisIt libsim. I am trying to create a curvilinear grid using ParaView catalyst. To do so, I have checked ParaView Catalyst user guide V2.0. In page 28 of this guide, there is a simple code for building curvilinear grids:

vtkStructuredGrid* grid = vtkStructuredGrid::New();
grid->SetExtent(0, 10, 0, 20, 0, 0);
vtkPoints* points = vtkPoints::New();
points->SetNumberOfPoints(11*21);
for(int j=0;j<21;j++)
{
    for(int i=0;i<11;i++)
    {
        points->SetPoint(i+j*11, i, j, 0);
    }
}
grid->SetPoints(points);
points->Delete();

Although the whole sample is clear, but I cannot understand the usage of the first parameter of SetPoint method. There is no explanation about it neither in the user guide nor in online documentations of vtkPoints class:

void vtkPoints::SetPoint	(	vtkIdType 	id,
        double 	x,
        double 	y,
        double 	z 
        )		
Definition at line 288 of file vtkPoints.h.

Can anybody make me clear about it?

Thanks
Chou

Sure easily explained.

You can either create a points and then insert them:

vtkPoints* points = vtkPoints::New();
for (int i=0; i < 10000; ++i)
{
    points->InsertPoint(x, y, z);
}

but this means that there will be some internal reallocation occurring when the points get inserted (append to the end).

Or else you pre-dimension the array before:

points->SetNumberOfPoints(10000);

and then set the points in the particular array location:

for (int i=0; i < 10000; ++i)
{
    points->SetPoint(i, x, y, z);
}

Thanks Mark,

So, this parameter seems to be an index, instead of an Id, right?

Index or Id are the same thing. Later you will refer to these points in your element or cell topology. Eg, your quad element has points (0 5 8 10), which are 0-indexed into the points array.