[vtkusers] Re: Why am I always running low on memory?

Yixun Liu yxliu at fudan.edu.cn
Mon Sep 4 04:43:22 EDT 2006


Hi,
Generally you had better build the pipeline in your object constructor. If you have to AddRenderer() as pressing a button you can use the code I write, which can avoid adding the same renderer twice.

void CMyIADView::MyAddRenderer(vtkRenderer *addedRen)
{
 vtkRendererCollection *renderers = this->renWin->GetRenderers();
 vtkRenderer *ren;
   
 for (renderers->InitTraversal(); (ren = renderers->GetNextItem()); )
 {
  if(ren == addedRen)
   return;
 }

 this->renWin->AddRenderer(addedRen);

}

Cheers,

Yixun Liu




  ----- Original Message ----- 
  From: Rashed Karim 
  To: Yixun Liu ; vtkusers at vtk.org 
  Sent: Monday, September 04, 2006 3:10 PM
  Subject: Re: Why am I always running low on memory?


  Hi Liu, 

  You are right, I am doing renWin -> AddRenderer( ) several times, although not inside a loop. How can I avoid doing this. Everytime I click a button on my program, I am creating a new rendering on the same renderer window and that's why everytime I am doing AddRenderer( ). How can I not do AddRenderer( ) everytime? Any ideas? 

  Thanks for all your help, 

  Regards, 
  Rashed karim 


  On 9/4/06, Yixun Liu <yxliu at fudan.edu.cn > wrote:
    Hi,

    You can delete a filter immediately after its output has been past to its downstream filter. For example filter2->SetInput(filter1->GetOutput()); filter1->Delete();

    Do you put renWin->AddRenderer() in a loop or call renWin->AddRenderer() often. Note that the same renderer will be added many  times in the renWin if you call AddRenderer() in a loop. Two or three renderers will make your program run very slow.

    Cheers,

    Yixun Liu



  -- 
  Rashed 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060904/aaf09448/attachment.htm>


More information about the vtkusers mailing list