[vtkusers] New Try - clipping / memory leaks

Andres Barrera andresba at hotmail.com
Mon Sep 15 12:21:20 EDT 2003


Dear VTK List,

I didn't get any yet, and I wonder if I sent my previous e-mail to the right 
address. Basically what I want to do is to run a loop that takes a vtkActor 
(say IN_Actor), generates a new vtkPolyData, and places it to replace the 
original vtkPolyData in IN_Actor. I have tried some different options, but 
I'm getting memory leaks, because I cannot delete the old vtkPolyData. Can 
anyone help me on that? (see previous e-mail below)

  Thanks

        Andres

>
>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
>
>_______________________________________________
>This is the private VTK discussion list. Please keep messages on-topic. 
>Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers

_________________________________________________________________
Get a FREE computer virus scan online from McAfee. 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




More information about the vtkusers mailing list