[vtkusers] clipping - memory leaks
Andres Barrera
andresba at hotmail.com
Mon Sep 8 14:10:32 EDT 2003
Dear list,
I want to repeatedly clip a vtkPolyData of a vtkActor, and assign the
result of the operation to the actor. I am doing
clipping( vtkActor* surfaceActor,
vtkImplicitFunction* implicit,
vtkTransform* myTransform)
{ ...
implicit->SetTransform( myTransform);
//CLIPPING
vtkClipPolyData *clipper = vtkClipPolyData::New();
clipper->SetInput ( (vtkPolyData *)
(surfaceActor->GetMapper())->GetInput() );
clipper->SetClipFunction( implicit );
// Replace for the new PolyData.... (leaks memory)
((vtkPolyDataMapper* )
surfaceActor->GetMapper())->SetInput(clipper->GetOutput() );
((vtkPolyDataMapper* ) surfaceActor->GetMapper())->Update();
...
//clean up
clipper ->Delete();
}
That does what I want, but I am not releasing the memory for the old
PolyData. I've tried different ways like:
vtkPolyData* pd = vtkPolyData::New();
pd = clipper->GetOutput() ;
( ( (vtkPolyDataMapper*)surfaceActor->GetMapper() ) ->GetInput()
)->Delete();
( (vtkPolyDataMapper*)surfaceActor->GetMapper() ) ->Update();
( (vtkPolyDataMapper*)surfaceActor->GetMapper() ) ->SetInput(pd) ;
( (vtkPolyDataMapper*)surfaceActor->GetMapper() ) ->Update();
or even replacing the PolyDataMapper, but still my program either does not
compile, leaks memory, or crashes after the clipping loop starts.
Can anyone give me a an idea on how to do that properly?
Thank you all.
Andres
_________________________________________________________________
Need more e-mail storage? Get 10MB with Hotmail Extra Storage.
http://join.msn.com/?PAGE=features/es
More information about the vtkusers
mailing list