From 7ec540df3c61a9a78e57c4f74ca4c9fd75a3d000 Mon Sep 17 00:00:00 2001 From: san Date: Fri, 20 Mar 2009 16:29:40 +0000 Subject: [PATCH] Optimizing selection highlighting --- src/VTKViewer/VTKViewer_Algorithm.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/VTKViewer/VTKViewer_Algorithm.h b/src/VTKViewer/VTKViewer_Algorithm.h index b533f149b..4eec97340 100644 --- a/src/VTKViewer/VTKViewer_Algorithm.h +++ b/src/VTKViewer/VTKViewer_Algorithm.h @@ -68,6 +68,28 @@ namespace VTK } return theFun; } + + /*!For each actor(for ex: someActor) from \a theCollection(that can be dynamic cast to type TActor and \n + * method \a thePredicate(someActor) return true) \n + * calls method \a theFun(someActor), otherwise calls \a theAltFun(someActor) + */ + template + TFunction ForEachIfElse(vtkActorCollection *theCollection, + TPredicate thePredicate, + TFunction theFun, + TAltFunction theAltFun) + { + if(theCollection){ + theCollection->InitTraversal(); + while(vtkActor *anAct = theCollection->GetNextActor()) + if(TActor *anActor = dynamic_cast(anAct)) + if(thePredicate(anActor)) + theFun(anActor); + else + theAltFun(anActor); + } + return theFun; + } /*!Find actor from collection, that can be dynamicaly cast to \a TActor, \n *and method \a thePredicate(someActor) return true) \n -- 2.39.2