From a69cfdfa8bd87ace00c15062f6e80bcad964abf8 Mon Sep 17 00:00:00 2001 From: dmv Date: Thu, 9 Apr 2009 08:56:43 +0000 Subject: [PATCH] IPAL21003 Impossible create group from existing group shown only --- src/VTKViewer/VTKViewer_Algorithm.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/VTKViewer/VTKViewer_Algorithm.h b/src/VTKViewer/VTKViewer_Algorithm.h index fefcb3a8a..7a31b7f57 100644 --- a/src/VTKViewer/VTKViewer_Algorithm.h +++ b/src/VTKViewer/VTKViewer_Algorithm.h @@ -29,6 +29,7 @@ #define VTKViewer_Algorithm_H #include +#include class vtkActor; @@ -41,10 +42,12 @@ namespace VTK TFunction ForEach(vtkActorCollection *theCollection, TFunction theFun) { if(theCollection){ - theCollection->InitTraversal(); - while(vtkActor *anAct = theCollection->GetNextActor()) - if(TActor *anActor = dynamic_cast(anAct)) + vtkCollectionIterator* anIterator = theCollection->NewIterator(); + while (anIterator->IsDoneWithTraversal()) { + if(TActor *anActor = dynamic_cast(anIterator->GetObject())) theFun(anActor); + anIterator->GoToNextItem(); + } } return theFun; } @@ -59,11 +62,14 @@ namespace VTK TFunction theFun) { if(theCollection){ - theCollection->InitTraversal(); - while(vtkActor *anAct = theCollection->GetNextActor()) - if(TActor *anActor = dynamic_cast(anAct)) + vtkCollectionIterator* anIterator = theCollection->NewIterator(); + while (anIterator->IsDoneWithTraversal()) { + if(TActor *anActor = dynamic_cast(anIterator->GetObject())) { if(thePredicate(anActor)) theFun(anActor); + } + anIterator->GoToNextItem(); + } } return theFun; } @@ -76,11 +82,14 @@ namespace VTK TActor* Find(vtkActorCollection *theCollection, TPredicate thePredicate) { if(theCollection){ - theCollection->InitTraversal(); - while(vtkActor *anAct = theCollection->GetNextActor()) - if(TActor *anActor = dynamic_cast(anAct)) + vtkCollectionIterator* anIterator = theCollection->NewIterator(); + while (anIterator->IsDoneWithTraversal()) { + if(TActor* anActor = dynamic_cast(anIterator->GetObject())) { if(thePredicate(anActor)) return anActor; + } + anIterator->GoToNextItem(); + } } return NULL; } -- 2.39.2