]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix of the problem with vtkRenderer::GetActors() method
authorouv <ouv@opencascade.com>
Wed, 22 Jul 2009 10:32:56 +0000 (10:32 +0000)
committerouv <ouv@opencascade.com>
Wed, 22 Jul 2009 10:32:56 +0000 (10:32 +0000)
14 files changed:
src/LightApp/LightApp_VTKSelector.cxx
src/SVTK/SALOME_Actor.cxx
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_Renderer.cxx
src/SVTK/SVTK_Trihedron.cxx
src/SVTK/SVTK_UpdateRateDlg.cxx
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_ViewModel.cxx
src/VTKViewer/Makefile.am
src/VTKViewer/VTKViewer_Algorithm.cxx [new file with mode: 0644]
src/VTKViewer/VTKViewer_Algorithm.h
src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx
src/VTKViewer/VTKViewer_Trihedron.cxx
src/VTKViewer/VTKViewer_Utilities.cxx

index ba984f5cbc7a78f553dd00546e05495fb55e7a7d..ea5829212ac9ae4b36edfae114aeb0888773805c 100644 (file)
@@ -111,7 +111,8 @@ LightApp_SVTKDataOwner
 {
   if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){
     using namespace SVTK;
-    return Find<SALOME_Actor>(aViewWindow->getRenderer()->GetActors(),TIsSameIObject<SALOME_Actor>(IO()));
+    VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
+    return Find<SALOME_Actor>(aCopy.GetActors(),TIsSameIObject<SALOME_Actor>(IO()));
   }
 
   return NULL;
index c4f515be2d742296c10c193836ef343ea1192675..a7184406692f4b775b9e9165ab63bd98051762dd 100644 (file)
@@ -33,6 +33,7 @@
 #include "SALOME_Actor.h"
 #include "SALOME_InteractiveObject.hxx"
 
+#include "VTKViewer_Algorithm.h"
 #include "VTKViewer_Transform.h"
 #include "VTKViewer_TransformFilter.h"
 #include "VTKViewer_GeometryFilter.h"
@@ -454,7 +455,8 @@ SALOME_Actor
 
   if( !theIsHighlight ) {
     SetPreSelected( false );
-    vtkActorCollection* theActors = aRenderer->GetActors();
+    VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+    vtkActorCollection* theActors = aCopy.GetActors();
     theActors->InitTraversal();
     while( vtkActor *ac = theActors->GetNextActor() )
       if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
@@ -553,7 +555,8 @@ SALOME_Actor
       if( !mySelector->IsSelected( myIO ) ) {
        SetPreSelected( true );
 
-       vtkActorCollection* theActors = aRenderer->GetActors();
+       VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+       vtkActorCollection* theActors = aCopy.GetActors();
        theActors->InitTraversal();
        while( vtkActor *anAct = theActors->GetNextActor() ) {
          if( anAct != this )
index fbf0db9d17902ecb16e190891a4861ef2965269f..09392aa878e00fca3f8041edfb4de02d2ed7d3d8 100644 (file)
@@ -1100,7 +1100,8 @@ SVTK_InteractorStyle
            if(!myShiftState)
              GetSelector()->ClearIObjects();
 
-           vtkActorCollection* aListActors = GetCurrentRenderer()->GetActors();
+           VTK::ActorCollectionCopy aCopy(GetCurrentRenderer()->GetActors());
+           vtkActorCollection* aListActors = aCopy.GetActors();
            aListActors->InitTraversal();
            while(vtkActor* aActor = aListActors->GetNextActor())
              {
index cfce2dad0a3143faa0cc51ddf45f328c07ea0e53..acbbb15ba10ca36134a6174bb918a0730bf338ae 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "SALOME_Actor.h"
 #include "VTKViewer_Actor.h"
+#include "VTKViewer_Algorithm.h"
 #include "VTKViewer_Transform.h"
 #include "VTKViewer_Utilities.h"
 
@@ -156,7 +157,8 @@ SVTK_Renderer
 SVTK_Renderer
 ::~SVTK_Renderer()
 {
-  vtkActorCollection* anActors = GetDevice()->GetActors();
+  VTK::ActorCollectionCopy aCopy(GetDevice()->GetActors());
+  vtkActorCollection* anActors = aCopy.GetActors();
   vtkActorCollection* anActors2 = vtkActorCollection::New();
 
   anActors->InitTraversal();
@@ -309,7 +311,8 @@ SVTK_Renderer
   myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
   AdjustActors();
   
-  vtkActorCollection* anActors = GetDevice()->GetActors();
+  VTK::ActorCollectionCopy aCopy(GetDevice()->GetActors());
+  vtkActorCollection* anActors = aCopy.GetActors();
   anActors->InitTraversal();
   while(vtkActor* anAct = anActors->GetNextActor())
     if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct))
@@ -414,7 +417,8 @@ SVTK_Renderer
       myTrihedron->SetSize( myTrihedronSize );
 
     // iterate through displayed objects and set size if necessary
-    vtkActorCollection* anActors = GetDevice()->GetActors();
+    VTK::ActorCollectionCopy aCopy(GetDevice()->GetActors());
+    vtkActorCollection* anActors = aCopy.GetActors();
     anActors->InitTraversal();
     while(vtkActor* anAct = anActors->GetNextActor()){
       if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
index f7b2b452e12f38c6a2d626d92f226bd4d4b9da82..65f337b33e65a4176a08ffbc8f4ba67edc613499 100644 (file)
@@ -22,6 +22,8 @@
 #include "SVTK_Trihedron.h"
 #include "SALOME_Actor.h"
 
+#include "VTKViewer_Algorithm.h"
+
 #include <vtkObjectFactory.h>
 #include <vtkActorCollection.h>
 #include <vtkRenderer.h>
@@ -44,7 +46,8 @@ int
 SVTK_Trihedron
 ::GetVisibleActorCount(vtkRenderer* theRenderer)
 {
-  vtkActorCollection* aCollection = theRenderer->GetActors();
+  VTK::ActorCollectionCopy aCopy(theRenderer->GetActors());
+  vtkActorCollection* aCollection = aCopy.GetActors();
   aCollection->InitTraversal();
   int aCount = 0;
   while(vtkActor* aProp = aCollection->GetNextActor()) {
index ff609a0499bde619ede93eb1c7ae44e57788f71b..5f44c278b556d53b438ce43d1521fd1bbe37031f 100644 (file)
@@ -105,7 +105,8 @@ namespace
                   vtkFloatingPointType theUpdateRate)
   {
     if(vtkRenderer *aRenderer = theRWInteractor->getRenderer()){
-      if(vtkActorCollection *anActorCollection = aRenderer->GetActors()){
+      VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+      if(vtkActorCollection *anActorCollection = aCopy.GetActors()){
        TRenderTimeMultiplier aMultiplier;
        using namespace VTK;
        aMultiplier = ForEach<vtkActor>(anActorCollection,
@@ -146,7 +147,8 @@ namespace
   GetNumberOfCells(SVTK_RenderWindowInteractor* theRWInteractor)
   {
     if(vtkRenderer *aRenderer = theRWInteractor->getRenderer()){
-      if(vtkActorCollection *anActorCollection = aRenderer->GetActors()){
+      VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+      if(vtkActorCollection *anActorCollection = aCopy.GetActors()){
        TCellsCounter aCounter;
        using namespace VTK;
        aCounter = ForEach<SALOME_Actor>(anActorCollection,
index 260b55b41e3354574f24cb439ac71f44bdcd3314..67fc67db431300dd5a960196e2926a692224fcb2 100644 (file)
@@ -142,7 +142,8 @@ void
 SVTK_SignalHandler
 ::onSelectionChanged()
 {
-  vtkActorCollection* anActors = myMainWindow->getRenderer()->GetActors();
+  VTK::ActorCollectionCopy aCopy(myMainWindow->getRenderer()->GetActors());
+  vtkActorCollection* anActors = aCopy.GetActors();
 
   using namespace SVTK;
   ForEach<SALOME_Actor>(anActors,
@@ -184,7 +185,8 @@ SVTK_View
 ::unHighlightAll() 
 {
   using namespace SVTK;
-  ForEach<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEach<SALOME_Actor>(aCopy.GetActors(),
                        THighlightAction( false ));
   Repaint();
 }
@@ -202,7 +204,8 @@ SVTK_View
             bool theIsUpdate ) 
 {
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>( theIO ),
                          THighlightAction(theIsHighlight));
   Repaint();
@@ -217,8 +220,9 @@ SVTK_View
 ::FindIObject(const char* theEntry) 
 {
   using namespace SVTK;
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(getRenderer()->GetActors(),
+    Find<SALOME_Actor>(aCopy.GetActors(),
                       TIsSameEntry<SALOME_Actor>(theEntry));
   if(anActor != NULL)
     return anActor->getIO();
@@ -273,8 +277,9 @@ SVTK_View
 ::isInViewer(const Handle(SALOME_InteractiveObject)& theIObject)
 {
   using namespace SVTK;
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(getRenderer()->GetActors(),
+    Find<SALOME_Actor>(aCopy.GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   return anActor != NULL;
 }
@@ -288,8 +293,9 @@ SVTK_View
 ::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
 {
   using namespace SVTK;
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(getRenderer()->GetActors(),
+    Find<SALOME_Actor>(aCopy.GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   return anActor != NULL && anActor->GetVisibility();
 }
@@ -305,7 +311,8 @@ SVTK_View
         const QString& theName)
 {
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,const char*,QString>
                          (&SALOME_Actor::setName,theName.latin1()));
@@ -347,7 +354,8 @@ SVTK_View
                 int theMode)
 {
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,int>
                          (&SALOME_Actor::setDisplayMode,theMode));
@@ -360,7 +368,8 @@ void
 SVTK_View
 ::ChangeRepresentationToWireframe()
 {
-  ChangeRepresentationToWireframe(getRenderer()->GetActors());
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ChangeRepresentationToWireframe(aCopy.GetActors());
 }
 
 /*!
@@ -370,7 +379,8 @@ void
 SVTK_View
 ::ChangeRepresentationToSurface()
 {
-  ChangeRepresentationToSurface(getRenderer()->GetActors());
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ChangeRepresentationToSurface(aCopy.GetActors());
 }
 
 /*!
@@ -432,7 +442,8 @@ SVTK_View
 ::EraseAll()
 {   
   using namespace SVTK;
-  ForEach<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEach<SALOME_Actor>(aCopy.GetActors(),
                        TErase());
   Repaint();
 }
@@ -445,7 +456,8 @@ SVTK_View
 ::DisplayAll()
 { 
   using namespace SVTK;
-  ForEach<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEach<SALOME_Actor>(aCopy.GetActors(),
                        TSetVisibility<SALOME_Actor>(true));
   Repaint();
 }
@@ -478,7 +490,8 @@ SVTK_View
        bool theIsUpdate)
 {
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TErase());
   if(theIsUpdate)
@@ -509,7 +522,8 @@ SVTK_View
          bool theIsUpdate)
 {
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetVisibility<SALOME_Actor>(true));
 
@@ -554,7 +568,8 @@ SVTK_View
         bool theIsUpdate)
 {
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TRemoveAction(GetRenderer()));
   if(theIsUpdate)
@@ -582,7 +597,8 @@ SVTK_View
 ::RemoveAll(bool theIsUpdate)
 {
   vtkRenderer* aRenderer = getRenderer();
-  if(vtkActorCollection* anActors = aRenderer->GetActors()){
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  if(vtkActorCollection* anActors = aCopy.GetActors()){
     anActors->InitTraversal();
     while(vtkActor *anAct = anActors->GetNextActor()){
       if(SALOME_Actor* aSAct = SALOME_Actor::SafeDownCast(anAct)){
@@ -605,8 +621,9 @@ SVTK_View
 ::GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject) 
 {
   using namespace SVTK;
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(getRenderer()->GetActors(),
+    Find<SALOME_Actor>(aCopy.GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   if(anActor)
     return 1.0 - anActor->GetOpacity();
@@ -626,7 +643,8 @@ SVTK_View
 {
   vtkFloatingPointType anOpacity = 1.0 - theTrans;
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,vtkFloatingPointType>
                          (&SALOME_Actor::SetOpacity,anOpacity));
@@ -645,7 +663,8 @@ SVTK_View
   vtkFloatingPointType aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.};
 
   using namespace SVTK;
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
+  ForEachIf<SALOME_Actor>(aCopy.GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,const vtkFloatingPointType*>
                          (&SALOME_Actor::SetColor,aColor));
@@ -661,8 +680,9 @@ SVTK_View
 ::GetColor(const Handle(SALOME_InteractiveObject)& theIObject) 
 {
   using namespace SVTK;
+  VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors());
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(getRenderer()->GetActors(),
+    Find<SALOME_Actor>(aCopy.GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   if(anActor){
     vtkFloatingPointType r,g,b;
index f1cea87c8fd0f12a1b0dbaa02c6e3b75c2b957ee..b0ea002929d0d3c8cd02c6a7a1e3cf058e0802de 100644 (file)
@@ -35,6 +35,7 @@
 #include "SVTK_MainWindow.h"
 #include "SVTK_Prs.h"
 
+#include "VTKViewer_Algorithm.h"
 #include "VTKViewer_ViewModel.h"
 
 #include <SALOME_Actor.h>
@@ -401,7 +402,8 @@ SVTK_Viewer
     if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
       if(SVTK_View* aView = aViewWindow->getView()){
        vtkRenderer* aRenderer =  aView->getRenderer();
-       vtkActorCollection* anActorCollection = aRenderer->GetActors();
+       VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+       vtkActorCollection* anActorCollection = aCopy.GetActors();
        anActorCollection->InitTraversal();
        while(vtkActor* anActor = anActorCollection->GetNextActor()){
          if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
@@ -445,7 +447,8 @@ SVTK_Viewer
     if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(getViewManager()->getActiveView()))
       if(SVTK_View* aView = aViewWindow->getView()){
        vtkRenderer* aRenderer =  aView->getRenderer();
-       vtkActorCollection* theActors = aRenderer->GetActors();
+       VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+       vtkActorCollection* theActors = aCopy.GetActors();
        theActors->InitTraversal();
        vtkActor* ac;
        while( ( ac = theActors->GetNextActor() ) ) {
index 56a31c9348352ed9f730ec0d3bb0f9338d1fc581..5d1857ffe70c3816b8d494f650013a6c85be7062 100755 (executable)
@@ -58,6 +58,7 @@ dist_libVTKViewer_la_SOURCES= \
        VTKViewer_Filter.cxx \
        VTKViewer_GeometryFilter.cxx \
        VTKViewer_AppendFilter.cxx \
+       VTKViewer_Algorithm.cxx \
        VTKViewer_InteractorStyle.cxx \
        VTKViewer_RenderWindow.cxx \
        VTKViewer_RenderWindowInteractor.cxx \
diff --git a/src/VTKViewer/VTKViewer_Algorithm.cxx b/src/VTKViewer/VTKViewer_Algorithm.cxx
new file mode 100644 (file)
index 0000000..b80ec9c
--- /dev/null
@@ -0,0 +1,44 @@
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "VTKViewer_Algorithm.h"
+
+namespace VTK
+{
+  ActorCollectionCopy::ActorCollectionCopy( vtkActorCollection* theActorCollection )
+  {
+    myActorCollection = vtkActorCollection::New();
+    theActorCollection->InitTraversal();
+    while(vtkActor* anActor = theActorCollection->GetNextActor())
+      myActorCollection->AddItem(anActor);
+  }
+
+  ActorCollectionCopy::~ActorCollectionCopy()
+  {
+    myActorCollection->Delete();
+    myActorCollection = NULL;
+  }
+
+  vtkActorCollection* ActorCollectionCopy::GetActors() const
+  {
+    return myActorCollection;
+  }
+}
index fefcb3a8a3cdf7293ee3467453277b2412647e0e..2bf45fc556f534cae2188acc3ea9e89cbd0dbffe 100644 (file)
@@ -34,6 +34,32 @@ class vtkActor;
 
 namespace VTK
 {
+  /*!
+   * This object should be used to avoid problems with recurring calls of GetActors() method of the vtkRenderer class.
+   *
+   * Instead of the following instructions:
+   *
+   * vtkRenderer* aRenderer = ...;
+   * vtkActorCollection* anActorCollection = aRenderer->GetActors();
+   * DoSomething( anActorCollection ); // where GetActors() could be called again
+   *
+   * A code like the following should be used:
+   *
+   * vtkRenderer* aRenderer = ...;
+   * vtkActorCollection* anActorCollection = aRenderer->GetActors();
+   * ActorCollectionCopy aCopy( anActorCollection );
+   * DoSomething( aCopy.GetActors() );
+   */
+  struct ActorCollectionCopy
+  {
+    vtkActorCollection* myActorCollection;
+
+    ActorCollectionCopy( vtkActorCollection* theActorCollection );
+    ~ActorCollectionCopy();
+
+    vtkActorCollection* GetActors() const;
+  };
+
   /*!For each actor(for ex: someActor) from \a theCollection(that can be dynamic cast to type TActor)\n
    * Call method \a theFun(someActor)
    */
index a031b94476854fe383d93f85a715a8eaf85c7acc..765fcdc3620da219329dead116e174f8341ad313 100755 (executable)
@@ -495,13 +495,17 @@ void VTKViewer_RenderWindowInteractor::SetDisplayMode(int theMode) {
 /*!Change all actors to wireframe*/
 void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe()
 {
-  ChangeRepresentationToWireframe(GetRenderer()->GetActors());
+  using namespace VTK;
+  ActorCollectionCopy aCopy(GetRenderer()->GetActors());
+  ChangeRepresentationToWireframe(aCopy.GetActors());
 }
 
 /*!Change all actors to surface*/
 void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface()
 {
-  ChangeRepresentationToSurface(GetRenderer()->GetActors());
+  using namespace VTK;
+  ActorCollectionCopy aCopy(GetRenderer()->GetActors());
+  ChangeRepresentationToSurface(aCopy.GetActors());
 }
 
 /*!Change all actors from \a theCollection to wireframe and
@@ -547,8 +551,8 @@ void VTKViewer_RenderWindowInteractor::EraseAll()
 void VTKViewer_RenderWindowInteractor::DisplayAll()
 {
   using namespace VTK;
-  vtkActorCollection* aCollection = GetRenderer()->GetActors();
-  ForEach<VTKViewer_Actor>(aCollection,TSetVisibility<VTKViewer_Actor>(true));
+  ActorCollectionCopy aCopy(GetRenderer()->GetActors());
+  ForEach<VTKViewer_Actor>(aCopy.GetActors(),TSetVisibility<VTKViewer_Actor>(true));
 
   emit RenderWindowModified() ;
 }
@@ -574,8 +578,10 @@ void VTKViewer_RenderWindowInteractor::Remove( VTKViewer_Actor* SActor, bool upd
  */
 void VTKViewer_RenderWindowInteractor::RemoveAll( const bool updateViewer )
 {
+  using namespace VTK;
   vtkRenderer* aRenderer = GetRenderer();
-  vtkActorCollection* anActors = aRenderer->GetActors();
+  ActorCollectionCopy aCopy(aRenderer->GetActors());
+  vtkActorCollection* anActors = aCopy.GetActors();
   if ( anActors )
   {
     anActors->InitTraversal();
@@ -624,7 +630,8 @@ struct TUpdateAction{
 void VTKViewer_RenderWindowInteractor::Update() {
   using namespace VTK;
   vtkRenderer* aRen = GetRenderer();
-  ForEach<vtkActor>(aRen->GetActors(),TUpdateAction());
+  ActorCollectionCopy aCopy(aRen->GetActors());
+  ForEach<vtkActor>(aCopy.GetActors(),TUpdateAction());
 
   aRen->ResetCamera();
 
index 067dfecf689f73778e549b101d9227c373940cc2..7dcf645a7e09bf27ec5a721074adcf6bde536b65 100755 (executable)
@@ -21,6 +21,7 @@
 //
 #include "VTKViewer_Trihedron.h"
 #include "VTKViewer_Actor.h"
+#include "VTKViewer_Algorithm.h"
 
 // VTK Includes
 #include <vtkMath.h>
@@ -442,7 +443,8 @@ int VTKViewer_Trihedron::GetVisibleActorCount(vtkRenderer* theRenderer)
 {
   //TVisibility aVis = GetVisibility();
   //SetVisibility(eOff);
-  vtkActorCollection* aCollection = theRenderer->GetActors();
+  VTK::ActorCollectionCopy aCopy(theRenderer->GetActors());
+  vtkActorCollection* aCollection = aCopy.GetActors();
   aCollection->InitTraversal();
   int aCount = 0;
   while(vtkActor* prop = aCollection->GetNextActor()) {
index db666dde917219326e160de2886ab9da12d76d71..f9d0a00f124ddb3926aab7e0af220eb0b53a2290 100755 (executable)
@@ -21,6 +21,7 @@
 //
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_Actor.h"
+#include "VTKViewer_Algorithm.h"
 
 #include <algorithm>
 
@@ -115,7 +116,8 @@ ComputeVisiblePropBounds(vtkRenderer* theRenderer,
   theBounds[1] = theBounds[3] = theBounds[5] = -VTK_LARGE_FLOAT;
   
   // loop through all props
-  vtkActorCollection* aCollection = theRenderer->GetActors();
+  VTK::ActorCollectionCopy aCopy(theRenderer->GetActors());
+  vtkActorCollection* aCollection = aCopy.GetActors();
   aCollection->InitTraversal();
   while (vtkActor* aProp = aCollection->GetNextActor()) {
     // if it's invisible, or has no geometry, we can skip the rest 
@@ -227,7 +229,8 @@ bool IsBBEmpty(vtkRenderer* theRenderer)
   aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
   
   // iterate through displayed objects and set size if necessary
-  vtkActorCollection* anActors = theRenderer->GetActors();
+  VTK::ActorCollectionCopy aCopy(theRenderer->GetActors());
+  vtkActorCollection* anActors = aCopy.GetActors();
   anActors->InitTraversal();
   bool isAny = false;
   while(vtkActor* anAct = anActors->GetNextActor())
@@ -257,7 +260,8 @@ bool ComputeBBCenter(vtkRenderer* theRenderer, vtkFloatingPointType theCenter[3]
   aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
 
   // iterate through displayed objects and set size if necessary
-  vtkActorCollection* anActors = theRenderer->GetActors();
+  VTK::ActorCollectionCopy aCopy(theRenderer->GetActors());
+  vtkActorCollection* anActors = aCopy.GetActors();
   anActors->InitTraversal();
   bool isAny = false;
   while(vtkActor* anAct = anActors->GetNextActor())