From 4e54c1cef103a22f5007ebe1002bc230f0fec704 Mon Sep 17 00:00:00 2001 From: ouv Date: Wed, 22 Jul 2009 10:46:42 +0000 Subject: [PATCH] Fix of the problem with vtkRenderer::GetActors() method --- src/SMESHGUI/SMESHGUI.cxx | 8 ++++++-- src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 5 ++++- src/SMESHGUI/SMESHGUI_NodesDlg.cxx | 4 +++- src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 32 ++++++++++++++++++++---------- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 7cbec92d7..5b24c6762 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -96,6 +96,8 @@ #include #include +#include + #include #include #include @@ -4038,7 +4040,8 @@ void SMESHGUI::storeVisualParameters (int savePoint) { if (SVTK_ViewWindow* vtkView = dynamic_cast(views[i])) { - vtkActorCollection* allActors = vtkView->getRenderer()->GetActors(); + VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors()); + vtkActorCollection* allActors = aCopy.GetActors(); allActors->InitTraversal(); while (vtkActor* actor = allActors->GetNextActor()) { @@ -4254,7 +4257,8 @@ void SMESHGUI::restoreVisualParameters (int savePoint) // access later when restoring other parameters SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView(); vtkRenderer* Renderer = vtkView->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); + VTK::ActorCollectionCopy aCopy(Renderer->GetActors()); + vtkActorCollection* theActors = aCopy.GetActors(); theActors->InitTraversal(); bool isFound = false; vtkActor *ac = theActors->GetNextActor(); diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 01e0f8195..80e98c0cf 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -61,6 +61,8 @@ #include +#include + // SALOME KERNEL includes #include @@ -2206,7 +2208,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(); int nbItems = aCollection->GetNumberOfItems(); for (int i=0; i #include +#include #include // SALOME KERNEL includes @@ -423,7 +424,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 f4c7e00ae..0c564af0e 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -49,6 +49,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))) @@ -516,7 +520,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)){ @@ -645,7 +650,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(dynamic_cast(anAct)) @@ -664,7 +670,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) { @@ -741,7 +748,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)){ @@ -841,7 +849,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)){ @@ -907,7 +916,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)){ @@ -925,7 +935,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)){ @@ -1135,7 +1146,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