From b6d3803df30c774673c78b6352ac8bba3a5fed77 Mon Sep 17 00:00:00 2001 From: ouv Date: Wed, 22 Jul 2009 10:44:18 +0000 Subject: [PATCH] Fix of the problem with vtkRenderer::GetActors() method --- src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 5 ++++- src/SMESHGUI/SMESHGUI_NodesDlg.cxx | 4 +++- src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 32 ++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 277dd494b..c8aaf026d 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -60,6 +60,8 @@ #include "SVTK_ViewWindow.h" #include "SVTK_Selector.h" +#include "VTKViewer_Algorithm.h" + #include "utilities.h" // VTK Includes @@ -2157,7 +2159,8 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor() // iterate on all actors in current view window, search for // any visible actor, that belongs to group or submesh of current mesh - vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors(); + VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); for (vtkActor *anAct = aCollection->GetNextActor(); anAct && !isActor; diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index f109a3183..9bc490d46 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -53,6 +53,7 @@ #include "SVTK_Selector.h" #include "SVTK_ViewWindow.h" +#include "VTKViewer_Algorithm.h" #include "VTKViewer_CellLocationsArray.h" #include "SALOME_Actor.h" @@ -453,7 +454,8 @@ bool SMESHGUI_NodesDlg::ClickOnApply() mySelectionMgr->selectedObjects(aList); if (aList.Extent() != 1) { if (SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView()) { - vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors(); + VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while (vtkActor *anAct = aCollection->GetNextActor()) { if (SMESH_Actor *anActor = dynamic_cast(anAct)) { diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index bc9df8f0c..00830c8d0 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -41,6 +41,8 @@ #include #include +#include + #include #include #include @@ -143,7 +145,8 @@ namespace SMESH { for ( int iV = 0; iV < views.count(); ++iV ) { if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) { vtkRenderer *aRenderer = vtkWnd->getRenderer(); - vtkActorCollection *actors = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *actors = aCopy.GetActors(); for (int i = 0; i < actors->GetNumberOfItems(); ++i ) { // size of actors changes inside the loop while (SMESH_Actor *actor = dynamic_cast(actors->GetItemAsObject(i))) @@ -185,7 +188,8 @@ namespace SMESH { for ( int iV = 0; iV < views.count(); ++iV ) { if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) { vtkRenderer *aRenderer = vtkWnd->getRenderer(); - vtkActorCollection *actors = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *actors = aCopy.GetActors(); for (int i = 0; i < actors->GetNumberOfItems(); ++i ) { // size of actors changes inside the loop while(SMESH_Actor *actor = dynamic_cast(actors->GetItemAsObject(i))) @@ -519,7 +523,8 @@ namespace SMESH { { if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){ vtkRenderer *aRenderer = aViewWindow->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ if(SMESH_Actor *anActor = dynamic_cast(anAct)){ @@ -648,7 +653,8 @@ namespace SMESH { { if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWnd)) { vtkRenderer *aRenderer = aViewWindow->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()) if(SMESH_Actor *anActor = dynamic_cast(anAct)) @@ -667,7 +673,8 @@ namespace SMESH { { OK = true; vtkRenderer *aRenderer = aViewWnd->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); switch (theAction) { @@ -744,7 +751,8 @@ namespace SMESH { if( selected.Extent() == 0){ vtkRenderer* aRenderer = aWnd->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ if(SMESH_Actor *anActor = dynamic_cast(anAct)){ @@ -835,7 +843,8 @@ namespace SMESH { PW); // update actors vtkRenderer* aRenderer = aVtkView->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ if(SMESH_Actor *anActor = dynamic_cast(anAct)){ @@ -901,7 +910,8 @@ namespace SMESH { void SetPointRepresentation(bool theIsVisible){ if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){ vtkRenderer *aRenderer = aViewWindow->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ if(SMESH_Actor *anActor = dynamic_cast(anAct)){ @@ -919,7 +929,8 @@ namespace SMESH { if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){ int anIsAllPickable = (theActor == NULL); vtkRenderer *aRenderer = aWnd->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while(vtkActor *anAct = aCollection->GetNextActor()){ if(SALOME_Actor *anActor = dynamic_cast(anAct)){ @@ -1129,7 +1140,8 @@ namespace SMESH { if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() ) { vtkRenderer *aRenderer = aWnd->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection *aCollection = aCopy.GetActors(); aCollection->InitTraversal(); while ( vtkActor *anAct = aCollection->GetNextActor()) -- 2.39.2