#define VTKViewer_Algorithm_H
#include <vtkActorCollection.h>
+#include <vtkCollectionIterator.h>
class vtkActor;
TFunction ForEach(vtkActorCollection *theCollection, TFunction theFun)
{
if(theCollection){
- theCollection->InitTraversal();
- while(vtkActor *anAct = theCollection->GetNextActor())
- if(TActor *anActor = dynamic_cast<TActor*>(anAct))
+ vtkCollectionIterator* anIterator = theCollection->NewIterator();
+ while (anIterator->IsDoneWithTraversal()) {
+ if(TActor *anActor = dynamic_cast<TActor*>(anIterator->GetObject()))
theFun(anActor);
+ anIterator->GoToNextItem();
+ }
}
return theFun;
}
TFunction theFun)
{
if(theCollection){
- theCollection->InitTraversal();
- while(vtkActor *anAct = theCollection->GetNextActor())
- if(TActor *anActor = dynamic_cast<TActor*>(anAct))
+ vtkCollectionIterator* anIterator = theCollection->NewIterator();
+ while (anIterator->IsDoneWithTraversal()) {
+ if(TActor *anActor = dynamic_cast<TActor*>(anIterator->GetObject())) {
if(thePredicate(anActor))
theFun(anActor);
+ }
+ anIterator->GoToNextItem();
+ }
}
return theFun;
}
TActor* Find(vtkActorCollection *theCollection, TPredicate thePredicate)
{
if(theCollection){
- theCollection->InitTraversal();
- while(vtkActor *anAct = theCollection->GetNextActor())
- if(TActor *anActor = dynamic_cast<TActor*>(anAct))
+ vtkCollectionIterator* anIterator = theCollection->NewIterator();
+ while (anIterator->IsDoneWithTraversal()) {
+ if(TActor* anActor = dynamic_cast<TActor*>(anIterator->GetObject())) {
if(thePredicate(anActor))
return anActor;
+ }
+ anIterator->GoToNextItem();
+ }
}
return NULL;
}