[vtkusers] VisibleActorCount ...
Kamran Iranpour
kamran.iranpour at gmail.com
Mon Apr 3 09:13:05 EDT 2006
Hi
I am very newbie in VTK and already having a few problems. I have
the following code:
----------start------------
pointSet = vtkPolyData::New();
freePoints = vtkPoints::New();
zValues = vtkFloatArray::New();
zValues->SetName("z values");
for (int i = 0; i < n; i++) {
pnt[0] = data[i*3];
pnt[1] = data[i*3+1];
pnt[2] = data[i*3+2];
freePoints->InsertPoint(nPoints, pnt);
zValues->InsertValue(nPoints, pnt[2]);
nPoints++;
}
pointSet->GetPointData()->SetScalars(zValues);
zValues->Delete();
pointSet->SetPoints(freePoints);
QString caption = QString("Surface 1");
previewWidget->setDataSet(pointSet); // canvas subclass
previewWidget->Render();
freePoints->Delete();
pointSet->Delete();
---------------end------------
I have a few thousands points (xyz) which I correctly render
and everything is OK if I do that once. But If I chose another set of points
the rendering get slower and slower for a third time and so on.
I have cheked to see if I have a memory leakage somewhere but
I don't see any increase in memory use which makes it more strange
than I first thought.
Then I read something about "VisibleActorCount" and "VisibleVolumeCount"
and checked these values and saw that they increase by three for each time
I render a new set of points. So I used the following to remove these
each time I have new points to render:
-----------------start-----------------
vtkActorCollection *actors = vtkActorCollection::New();
int NumberOfActors = previewWidget->getRenderer()->VisibleActorCount();
actors=previewWidget->getRenderer()->GetActors();
actors->InitTraversal();
for (int i=0; i<NumberOfActors; i++) {
previewWidget->getRenderer()->RemoveActor(actors->GetNextActor());
}
actors->Delete();
----------------end-------------------
(and equally for Volumes)
But still the number of of a visible actors and volumes keep increasing
and after a few times the whole thing crashes.
The question is, am I doing the right thing, removing the actors and
volumes or not and why it keeps increasing.
Thanks in advance for your help
Kamran
More information about the vtkusers
mailing list