Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef VTKViewer_Algorithm_H
00030 #define VTKViewer_Algorithm_H
00031
00032 #include "VTKViewer.h"
00033
00034 #include <vtkActorCollection.h>
00035
00036 class vtkActor;
00037
00038 namespace VTK
00039 {
00056 struct VTKVIEWER_EXPORT ActorCollectionCopy
00057 {
00058 vtkActorCollection* myActorCollection;
00059
00060 ActorCollectionCopy( vtkActorCollection* theActorCollection );
00061 ~ActorCollectionCopy();
00062
00063 vtkActorCollection* GetActors() const;
00064 };
00065
00069 template<typename TActor, typename TFunction>
00070 TFunction ForEach(vtkActorCollection *theCollection, TFunction theFun)
00071 {
00072 if(theCollection){
00073 theCollection->InitTraversal();
00074 while(vtkActor *anAct = theCollection->GetNextActor())
00075 if(TActor *anActor = dynamic_cast<TActor*>(anAct))
00076 theFun(anActor);
00077 }
00078 return theFun;
00079 }
00080
00085 template<typename TActor, typename TPredicate, typename TFunction>
00086 TFunction ForEachIf(vtkActorCollection *theCollection,
00087 TPredicate thePredicate,
00088 TFunction theFun)
00089 {
00090 if(theCollection){
00091 theCollection->InitTraversal();
00092 while(vtkActor *anAct = theCollection->GetNextActor())
00093 if(TActor *anActor = dynamic_cast<TActor*>(anAct))
00094 if(thePredicate(anActor))
00095 theFun(anActor);
00096 }
00097 return theFun;
00098 }
00099
00104 template<typename TActor, typename TPredicate>
00105 TActor* Find(vtkActorCollection *theCollection, TPredicate thePredicate)
00106 {
00107 if(theCollection){
00108 theCollection->InitTraversal();
00109 while(vtkActor *anAct = theCollection->GetNextActor())
00110 if(TActor *anActor = dynamic_cast<TActor*>(anAct))
00111 if(thePredicate(anActor))
00112 return anActor;
00113 }
00114 return NULL;
00115 }
00116
00117 }
00118
00119 #endif