problem with renderer->GetActors()->RemoveAllItems()

Paul Hsieh pahsieh at usgs.gov
Wed Jun 30 22:44:35 EDT 1999


I encountered a minor problem when removing actors from a renderer.
The statement

     renderer->GetActors()->RemoveAllItems();

doesn't seem to work in vtk2.3. However, the statement

    renderer->GetProps()->RemoveAllItems();

does work. This is illustrated by the following sample code.
For both ren1 and ren2, I add an actor and then remove all actors.
However ren1 still reports that it has one actor. ren2 reports
correctly that it has no actor. I am using the "original"
version of vtk2.3 (not nightly download). Thanks.

Paul

//======sample code=====


#include "vtkRenderer.h"
#include "vtkActor.h"
#include <iostream.h>

void main()
{
   vtkRenderer *ren1 = vtkRenderer::New();
   vtkActor *actor1 = vtkActor::New();
   ren1->AddActor(actor1);
   ren1->GetActors()->RemoveAllItems();
   cout << "number of actors in ren1 = "
        << ren1->GetActors()->GetNumberOfItems() << endl;

   vtkRenderer *ren2 = vtkRenderer::New();
   vtkActor *actor2 = vtkActor::New();
   ren2->AddActor(actor2);
   ren2->GetProps()->RemoveAllItems();
   cout << "number of actors in ren2 = "
        << ren2->GetActors()->GetNumberOfItems() << endl;

   ren1->Delete();
   ren2->Delete();
   actor1->Delete();
   actor2->Delete();
}




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list