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