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

Lisa Sobierajski Avila lisa.avila at kitware.com
Thu Jul 1 10:07:38 EDT 1999


Hello Paul,

This is not really a bug - but rather a side effect of some of the change
made back before the vtk2.3 release to unify the rendering process. Instead
of an actor collection and a volume collection, there is now just a vtkProp
collection (which also holds 2D actors). We do continue to provide the
GetActors() method, but it creates a new collection and lets all the props
add items to it (if that prop happens to be or contain actors). The same is
true for the GetVolumes() method. Therefore, you should never modify the
collections that are returned from these methods.

Lisa

At 07:44 PM 6/30/99 -0700, Paul Hsieh wrote:
>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.
>-----------------------------------------------------------------------------
> 



-----------------------------------------------------------------------------
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