Fix of the problem with vtkRenderer::GetActors() method

This commit is contained in:
ouv 2009-07-22 10:46:42 +00:00
parent 55510e5ccd
commit 4e54c1cef1
4 changed files with 35 additions and 14 deletions

View File

@ -96,6 +96,8 @@
#include <SVTK_ViewModel.h> #include <SVTK_ViewModel.h>
#include <SVTK_ViewManager.h> #include <SVTK_ViewManager.h>
#include <VTKViewer_Algorithm.h>
#include <SUIT_MessageBox.h> #include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SUIT_FileDlg.h> #include <SUIT_FileDlg.h>
@ -4038,7 +4040,8 @@ void SMESHGUI::storeVisualParameters (int savePoint)
{ {
if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i])) 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(); allActors->InitTraversal();
while (vtkActor* actor = allActors->GetNextActor()) while (vtkActor* actor = allActors->GetNextActor())
{ {
@ -4254,7 +4257,8 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
// access later when restoring other parameters // access later when restoring other parameters
SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView(); SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
vtkRenderer* Renderer = vtkView->getRenderer(); vtkRenderer* Renderer = vtkView->getRenderer();
vtkActorCollection* theActors = Renderer->GetActors(); VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
vtkActorCollection* theActors = aCopy.GetActors();
theActors->InitTraversal(); theActors->InitTraversal();
bool isFound = false; bool isFound = false;
vtkActor *ac = theActors->GetNextActor(); vtkActor *ac = theActors->GetNextActor();

View File

@ -61,6 +61,8 @@
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <VTKViewer_Algorithm.h>
// SALOME KERNEL includes // SALOME KERNEL includes
#include <SALOMEDSClient_Study.hxx> #include <SALOMEDSClient_Study.hxx>
@ -2206,7 +2208,8 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor()
// iterate on all actors in current view window, search for // iterate on all actors in current view window, search for
// any visible actor, that belongs to group or submesh of current mesh // 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(); int nbItems = aCollection->GetNumberOfItems();
for (int i=0; i<nbItems && !isActor; i++) for (int i=0; i<nbItems && !isActor; i++)
{ {

View File

@ -50,6 +50,7 @@
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <VTKViewer_Algorithm.h>
#include <VTKViewer_CellLocationsArray.h> #include <VTKViewer_CellLocationsArray.h>
// SALOME KERNEL includes // SALOME KERNEL includes
@ -423,7 +424,8 @@ bool SMESHGUI_NodesDlg::ClickOnApply()
mySelectionMgr->selectedObjects( aList ); mySelectionMgr->selectedObjects( aList );
if ( aList.Extent() != 1 ) { if ( aList.Extent() != 1 ) {
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() ) { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() ) {
vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors(); VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while ( vtkActor *anAct = aCollection->GetNextActor() ) { while ( vtkActor *anAct = aCollection->GetNextActor() ) {
if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) ) { if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) ) {

View File

@ -49,6 +49,8 @@
#include <SVTK_ViewModel.h> #include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <VTKViewer_Algorithm.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <SalomeApp_Study.h> #include <SalomeApp_Study.h>
@ -143,7 +145,8 @@ namespace SMESH
for ( int iV = 0; iV < views.count(); ++iV ) { for ( int iV = 0; iV < views.count(); ++iV ) {
if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) { if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
vtkRenderer *aRenderer = vtkWnd->getRenderer(); 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 ) { for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
// size of actors changes inside the loop // size of actors changes inside the loop
while (SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i))) 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 ) { for ( int iV = 0; iV < views.count(); ++iV ) {
if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) { if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
vtkRenderer *aRenderer = vtkWnd->getRenderer(); 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 ) { for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
// size of actors changes inside the loop // size of actors changes inside the loop
while(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i))) while(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
@ -516,7 +520,8 @@ namespace SMESH
{ {
if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){ if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
vtkRenderer *aRenderer = aViewWindow->getRenderer(); vtkRenderer *aRenderer = aViewWindow->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){ while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){ if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
@ -645,7 +650,8 @@ namespace SMESH
{ {
if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWnd)) { if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWnd)) {
vtkRenderer *aRenderer = aViewWindow->getRenderer(); vtkRenderer *aRenderer = aViewWindow->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()) while(vtkActor *anAct = aCollection->GetNextActor())
if(dynamic_cast<SMESH_Actor*>(anAct)) if(dynamic_cast<SMESH_Actor*>(anAct))
@ -664,7 +670,8 @@ namespace SMESH
{ {
OK = true; OK = true;
vtkRenderer *aRenderer = aViewWnd->getRenderer(); vtkRenderer *aRenderer = aViewWnd->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
switch (theAction) { switch (theAction) {
@ -741,7 +748,8 @@ namespace SMESH
if( selected.Extent() == 0){ if( selected.Extent() == 0){
vtkRenderer* aRenderer = aWnd->getRenderer(); vtkRenderer* aRenderer = aWnd->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){ while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){ if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
@ -841,7 +849,8 @@ namespace SMESH
PW); PW);
// update actors // update actors
vtkRenderer* aRenderer = aVtkView->getRenderer(); vtkRenderer* aRenderer = aVtkView->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){ while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){ if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
@ -907,7 +916,8 @@ namespace SMESH
void SetPointRepresentation(bool theIsVisible){ void SetPointRepresentation(bool theIsVisible){
if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){ if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){
vtkRenderer *aRenderer = aViewWindow->getRenderer(); vtkRenderer *aRenderer = aViewWindow->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){ while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){ if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
@ -925,7 +935,8 @@ namespace SMESH
if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){ if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){
int anIsAllPickable = (theActor == NULL); int anIsAllPickable = (theActor == NULL);
vtkRenderer *aRenderer = aWnd->getRenderer(); vtkRenderer *aRenderer = aWnd->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){ while(vtkActor *anAct = aCollection->GetNextActor()){
if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){ if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
@ -1135,7 +1146,8 @@ namespace SMESH
if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() ) if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
{ {
vtkRenderer *aRenderer = aWnd->getRenderer(); vtkRenderer *aRenderer = aWnd->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors(); VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal(); aCollection->InitTraversal();
while ( vtkActor *anAct = aCollection->GetNextActor()) while ( vtkActor *anAct = aCollection->GetNextActor())