[vtkusers] cleaning up after vtkActors

Will Schroeder will.schroeder at kitware.com
Fri May 31 15:31:16 EDT 2002


If you are creating 50,000 actors you are asking for trouble. It would be 
best to create your own mapper or filter (similar to vtkGlyph3D) which 
creates the cylinders and spheres, with a single actor.
Will

At 03:50 PM 5/31/2002 +0000, Brian Szender wrote:
>I am rendering a 3d model containing 50,000 sub-pieces of a vtkCylinder 
>and a vtkSphere.  My program works fine for smaller numbers, but when 
>too-many branches are loaded, the computer will continue to tick away 
>memory (I end the program after it reaches 1.5 GB).
>
>I render the cylinders as such (the spheres are done in a like manner):
>
>   vtkCylinderSource *cylinder = vtkCylinderSource::New();
>   cylinder->SetHeight( norm );
>   cylinder->SetRadius( radius );
>   cylinder->SetResolution( 50.0 );
>   cylinder->SetCapping( 1 );
>   vpx = vz;
>   vpy = 0.0;
>   vpz = -vx;
>
>   vtkTransform *trans1 = vtkTransform::New();
>   trans1->RotateWXYZ( angle*(180.0/pai), vpx, vpy, vpz );
>   vtkTransformPolyDataFilter *transpoly1 = vtkTransformPolyDataFilter::New();
>   transpoly1->SetInput( cylinder->GetOutput() );
>   transpoly1->SetTransform( trans1 );
>   vtkTransform *trans2 = vtkTransform::New();
>   trans2->Translate( (sx+ex)/2.0, (sy+ey)/2.0, (sz+ez)/2.0 );
>   vtkTransformPolyDataFilter *transpoly2 = 
> vtkTransformPolyDataFilter::New(); transpoly2->SetInput( 
> transpoly1->GetOutput() );
>   transpoly2->SetTransform( trans2 );
>   vtkPolyDataMapper *cylinderMapper = vtkPolyDataMapper::New();
>   cylinderMapper->SetInput( transpoly2->GetOutput() );
>   vtkActor *cylinderActor = vtkActor::New();
>   cylinderActor->SetMapper( cylinderMapper );
>...
>
>   actors.push_back( cylinderActor );
>   renderer = vtkwindow->getRenderer();
>   renderer->SetBackground( 0, 0, 0 );
>   renderer->AddActor( cylinderActor );
>   cylinder->Delete();
>   cylinderMapper->Delete();
>   trans1->Delete();
>   trans2->Delete();
>   transpoly1->Delete();
>   transpoly2->Delete();
>There is a function:   void ReleaseGraphicsResources(vtkWindow *);
>However, the function requires that I render with a vtkWindow (I am using 
>a FOX-GUI renderering window widget class called FXVTKWindow).
>
>Is there anything I can do to reduce the amount of memory spent on each 
>actor or else recover the memory after each actor is created?
>
>Brian
>
>
>----------
>MSN Photos is the easiest way to share and print your photos: Click Here
>_______________________________________________ This is the private VTK 
>discussion list. Please keep messages on-topic. Check the FAQ at: Follow 
>this link to subscribe/unsubscribe: 
>http://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020531/cbaeee8b/attachment.htm>


More information about the vtkusers mailing list