[vtkusers] Questions about vtkDataArray::Initialize()

David Doria daviddoria+vtk at gmail.com
Thu Sep 17 17:58:24 EDT 2009


In vtkPoints.h, there is
virtual void Initialize();

In the implementation, the function looks like this:
void vtkPoints::Initialize()
{
  this->Data->Initialize();
}

Again, in vtkPoints.h there is a member variable:
  vtkDataArray *Data;

I looked in vtkDataArray.h , but there is no Initialize() function.
vtkDataArray is derived from vtkAbstractArray, so I looked at
vtkAbstractArray.h. vtkAbstractArray.h has a pure virtual function
Initialize(). So where is the Initialize() function that is getting called
from vtkPoints?

The reason I started digging into this is the following:

I had a situation like this:

vtkPoints* MyPoints = vtkPoints::New();
for(i = 0; i < 1000; i++)
{
  MyFunction(MyPoints);
}

MyPoints->Delete();
----------

void MyFunction(vtkPoints* MyPoints)
{
MyPoints->Initialize();
//fill MyPoints with points
//do some nearest neighbor lookups using a KDTree
}

I was finding that after a few hundred iterations I was getting some bizarre
results.

I changed the process to look like this:

for(i = 0; i < 1000; i++)
  MyFunction();

------
void MyFunction()
{
vtkPoints* MyPoints = vtkPoints::New();

//fill MyPoints with points
//do some nearest neighbor lookups using a KDTree
MyPoints->Delete();
}

and it works fine through the entire loop.

I thought these should be identical - am I missing something?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090917/6c98bce7/attachment.htm>


More information about the vtkusers mailing list