Salome HOME
Fix of the problem with vtkRenderer::GetActors() method
authorouv <ouv@opencascade.com>
Wed, 22 Jul 2009 10:46:42 +0000 (10:46 +0000)
committerouv <ouv@opencascade.com>
Wed, 22 Jul 2009 10:46:42 +0000 (10:46 +0000)
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_GroupDlg.cxx
src/SMESHGUI/SMESHGUI_NodesDlg.cxx
src/SMESHGUI/SMESHGUI_VTKUtils.cxx

index 7cbec92d7acbae0ffd24009df625e73b4ebf266f..5b24c6762cb2c34e5368e7a4799e36eb2df077ec 100644 (file)
@@ -96,6 +96,8 @@
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewManager.h>
 
+#include <VTKViewer_Algorithm.h>
+
 #include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_FileDlg.h>
@@ -4038,7 +4040,8 @@ void SMESHGUI::storeVisualParameters (int savePoint)
       {
        if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(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();
index 01e0f81950bd932f33150d60a6ab3b5de70b7e45..80e98c0cfe2474c18f935542bdd590c637c2f03e 100644 (file)
@@ -61,6 +61,8 @@
 
 #include <SVTK_ViewWindow.h>
 
+#include <VTKViewer_Algorithm.h>
+
 // SALOME KERNEL includes
 #include <SALOMEDSClient_Study.hxx>
 
@@ -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<nbItems && !isActor; i++)
       {
index 38869ceddb5f899eff69e34afbf1794f092d6fd9..2e00469d6e1fb1d218d2f08a7d551ecdcce975ce 100644 (file)
@@ -50,6 +50,7 @@
 #include <LightApp_SelectionMgr.h>
 
 #include <SVTK_ViewWindow.h>
+#include <VTKViewer_Algorithm.h>
 #include <VTKViewer_CellLocationsArray.h>
 
 // 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<SMESH_Actor*>( anAct ) ) {
index f4c7e00aea9d743219f37206685fd0d4d0525054..0c564af0e21b92c7f657661343ebd9b6d12f1f26 100644 (file)
@@ -49,6 +49,8 @@
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
 
+#include <VTKViewer_Algorithm.h>
+
 #include <LightApp_SelectionMgr.h>
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
@@ -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<SMESH_Actor*>(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<SMESH_Actor*>(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<SMESH_Actor*>(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<SMESH_Actor*>(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<SMESH_Actor*>(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<SMESH_Actor*>(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<SMESH_Actor*>(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<SALOME_Actor*>(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())