From: ouv Date: Wed, 22 Jul 2009 10:32:56 +0000 (+0000) Subject: Fix of the problem with vtkRenderer::GetActors() method X-Git-Tag: V4_1_0_maintainance_FINAL~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5ebf47de713468c8b1838c7c904f77e53c6b8922;p=modules%2Fgui.git Fix of the problem with vtkRenderer::GetActors() method --- diff --git a/src/LightApp/LightApp_VTKSelector.cxx b/src/LightApp/LightApp_VTKSelector.cxx index ba984f5cb..ea5829212 100644 --- a/src/LightApp/LightApp_VTKSelector.cxx +++ b/src/LightApp/LightApp_VTKSelector.cxx @@ -111,7 +111,8 @@ LightApp_SVTKDataOwner { if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){ using namespace SVTK; - return Find(aViewWindow->getRenderer()->GetActors(),TIsSameIObject(IO())); + VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors()); + return Find(aCopy.GetActors(),TIsSameIObject(IO())); } return NULL; diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index c4f515be2..a71844066 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -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 ) diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index fbf0db9d1..09392aa87 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -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()) { diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index cfce2dad0..acbbb15ba 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -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(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(anAct)){ diff --git a/src/SVTK/SVTK_Trihedron.cxx b/src/SVTK/SVTK_Trihedron.cxx index f7b2b452e..65f337b33 100644 --- a/src/SVTK/SVTK_Trihedron.cxx +++ b/src/SVTK/SVTK_Trihedron.cxx @@ -22,6 +22,8 @@ #include "SVTK_Trihedron.h" #include "SALOME_Actor.h" +#include "VTKViewer_Algorithm.h" + #include #include #include @@ -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()) { diff --git a/src/SVTK/SVTK_UpdateRateDlg.cxx b/src/SVTK/SVTK_UpdateRateDlg.cxx index ff609a049..5f44c278b 100644 --- a/src/SVTK/SVTK_UpdateRateDlg.cxx +++ b/src/SVTK/SVTK_UpdateRateDlg.cxx @@ -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(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(anActorCollection, diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index 260b55b41..67fc67db4 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -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(anActors, @@ -184,7 +185,8 @@ SVTK_View ::unHighlightAll() { using namespace SVTK; - ForEach(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEach(aCopy.GetActors(), THighlightAction( false )); Repaint(); } @@ -202,7 +204,8 @@ SVTK_View bool theIsUpdate ) { using namespace SVTK; - ForEachIf(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject( 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(getRenderer()->GetActors(), + Find(aCopy.GetActors(), TIsSameEntry(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(getRenderer()->GetActors(), + Find(aCopy.GetActors(), TIsSameIObject(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(getRenderer()->GetActors(), + Find(aCopy.GetActors(), TIsSameIObject(theIObject)); return anActor != NULL && anActor->GetVisibility(); } @@ -305,7 +311,8 @@ SVTK_View const QString& theName) { using namespace SVTK; - ForEachIf(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject(theIObject), TSetFunction (&SALOME_Actor::setName,theName.latin1())); @@ -347,7 +354,8 @@ SVTK_View int theMode) { using namespace SVTK; - ForEachIf(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject(theIObject), TSetFunction (&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(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEach(aCopy.GetActors(), TErase()); Repaint(); } @@ -445,7 +456,8 @@ SVTK_View ::DisplayAll() { using namespace SVTK; - ForEach(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEach(aCopy.GetActors(), TSetVisibility(true)); Repaint(); } @@ -478,7 +490,8 @@ SVTK_View bool theIsUpdate) { using namespace SVTK; - ForEachIf(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject(theIObject), TErase()); if(theIsUpdate) @@ -509,7 +522,8 @@ SVTK_View bool theIsUpdate) { using namespace SVTK; - ForEachIf(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject(theIObject), TSetVisibility(true)); @@ -554,7 +568,8 @@ SVTK_View bool theIsUpdate) { using namespace SVTK; - ForEachIf(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject(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(getRenderer()->GetActors(), + Find(aCopy.GetActors(), TIsSameIObject(theIObject)); if(anActor) return 1.0 - anActor->GetOpacity(); @@ -626,7 +643,8 @@ SVTK_View { vtkFloatingPointType anOpacity = 1.0 - theTrans; using namespace SVTK; - ForEachIf(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject(theIObject), TSetFunction (&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(getRenderer()->GetActors(), + VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); + ForEachIf(aCopy.GetActors(), TIsSameIObject(theIObject), TSetFunction (&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(getRenderer()->GetActors(), + Find(aCopy.GetActors(), TIsSameIObject(theIObject)); if(anActor){ vtkFloatingPointType r,g,b; diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index f1cea87c8..b0ea00292 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -35,6 +35,7 @@ #include "SVTK_MainWindow.h" #include "SVTK_Prs.h" +#include "VTKViewer_Algorithm.h" #include "VTKViewer_ViewModel.h" #include @@ -401,7 +402,8 @@ SVTK_Viewer if(SVTK_ViewWindow* aViewWindow = dynamic_cast(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(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() ) ) { diff --git a/src/VTKViewer/Makefile.am b/src/VTKViewer/Makefile.am index 56a31c934..5d1857ffe 100755 --- a/src/VTKViewer/Makefile.am +++ b/src/VTKViewer/Makefile.am @@ -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 index 000000000..b80ec9cc4 --- /dev/null +++ b/src/VTKViewer/VTKViewer_Algorithm.cxx @@ -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; + } +} diff --git a/src/VTKViewer/VTKViewer_Algorithm.h b/src/VTKViewer/VTKViewer_Algorithm.h index fefcb3a8a..2bf45fc55 100644 --- a/src/VTKViewer/VTKViewer_Algorithm.h +++ b/src/VTKViewer/VTKViewer_Algorithm.h @@ -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) */ diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx index a031b9447..765fcdc36 100755 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -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(aCollection,TSetVisibility(true)); + ActorCollectionCopy aCopy(GetRenderer()->GetActors()); + ForEach(aCopy.GetActors(),TSetVisibility(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(aRen->GetActors(),TUpdateAction()); + ActorCollectionCopy aCopy(aRen->GetActors()); + ForEach(aCopy.GetActors(),TUpdateAction()); aRen->ResetCamera(); diff --git a/src/VTKViewer/VTKViewer_Trihedron.cxx b/src/VTKViewer/VTKViewer_Trihedron.cxx index 067dfecf6..7dcf645a7 100755 --- a/src/VTKViewer/VTKViewer_Trihedron.cxx +++ b/src/VTKViewer/VTKViewer_Trihedron.cxx @@ -21,6 +21,7 @@ // #include "VTKViewer_Trihedron.h" #include "VTKViewer_Actor.h" +#include "VTKViewer_Algorithm.h" // VTK Includes #include @@ -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()) { diff --git a/src/VTKViewer/VTKViewer_Utilities.cxx b/src/VTKViewer/VTKViewer_Utilities.cxx index db666dde9..f9d0a00f1 100755 --- a/src/VTKViewer/VTKViewer_Utilities.cxx +++ b/src/VTKViewer/VTKViewer_Utilities.cxx @@ -21,6 +21,7 @@ // #include "VTKViewer_Utilities.h" #include "VTKViewer_Actor.h" +#include "VTKViewer_Algorithm.h" #include @@ -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())