[vtkusers] Reset scene

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Wed Jun 25 17:56:41 EDT 2003


Hi Chris,
   are you sure you need to delete the RenderWindow? I would think you
could keep the RenderWindow and Renderer, you probably just need to change
what is sent to them.
If you want to display different sets of objects you could just turn on/off
visibility of actors (representing objects) vtkActor->SetVisibility(). This
assumes the objects may be needed again later.
If not you will want to get rid of the objects permanantley. Here is
example code that destroys all actors, (you might want to just delete
specific actors):

    vtkActorCollection *Actors = Renderer->GetActors();
    vtkActor *Actor;
    for( Actors->InitTraversal(); (Actor = Actors->GetNextItem())!=NULL; )
{
        Renderer->RemoveActor( Actor );
    }
    // clear the screen
    Renderer->Clear();  // clear to background colour
   Renderer-Render();

The key bit is RemoveActor, there is also a form of this function:
RemoveActor( i ), where 0 <= i < nActors. I suppose i is in the order the
were added.
As long as your pipeline has been constructed correctly for reference
counting, eg:

...
Renderer-AddActor( actor1 )
actor1->Delete();
...

The call to RemoveActor should decrease the reference count of the actor,
causing the whole 'upstream' pipeline to be destroyed (except for any parts
having other 'downstream' connections).
Dont forget to call Renderer->Render() to see the result after any changes
to the pipeline.

  hope this helps
    Dave Pont



                                                                                                                                                
                    Sepp^ Huber                                                                                                                 
                    <sepp.huber21@       To:     vtkusers at vtk.org                                                                               
                    gmx.at>              cc:                                                                                                    
                    Sent by:             Subject:     [vtkusers] Reset scene                                                                    
                    vtkusers-admin                                                                                                              
                    @vtk.org                                                                                                                    
                                                                                                                                                
                                                                                                                                                
                    26/06/2003                                                                                                                  
                    04:30                                                                                                                       
                                                                                                                                                
                                                                                                                                                




Hi I'm currently developing an application using VTK with C++ under
windows.
After getting some input from a dialog I open a vtkRenderWindow and display
some objects. Now I'd like to be able to reset the scene and display other
objects according to certain settings I make in the dialog.

Unfortunately I wasn't very successful yet. The way I tried was to delete
the vtkRenderWindow object and the vtkRenderWindow object using their
Delete()
methods. Afterwards I tried to create new objects by calling their New()
methods but this all results in a program crash with "stack overflow".
Any help and tips would be greatly appreciated!

Thanks in advance
Chris

--
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!

_______________________________________________
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







More information about the vtkusers mailing list