00001 #if defined (_MSC_VER) && (_MSC_VER >= 1000)
00002 #pragma once
00003 #endif
00004 #ifndef _INC_BEH_SearchForObject
00005 #define _INC_BEH_SearchForObject
00006
00007 #include "Behavior.h"
00008 #include "Beh_TranslateAll.h"
00009 #include "Beh_UniformScale.h"
00010 #include "Sense_AvgIntensity.h"
00011 #include "Geometric.h"
00012 #include <time.h>
00013
00014 namespace mial{
00015
00029 template<class Type, class TInputImage, int nDims>
00030 class Beh_SearchForObject
00031 : public Behavior<Type, nDims>
00032 {
00033 public:
00034
00035 typedef Beh_SearchForObject Self;
00036 typedef itk::SmartPointer<Self> Pointer;
00037 typedef itk::SmartPointer<const Self> ConstPointer;
00038 typedef itk::WeakPointer<const Self> ConstWeakPointer;
00039
00040 itkNewMacro(Self);
00041
00042 typedef vnl_vector<Type> VectorType;
00043
00044 typedef typename Behavior<Type,nDims>::Error Error;
00046
00049 struct behaviorIn: public Behavior<Type,nDims>::behaviorIn{
00050
00051 typedef behaviorIn Self;
00052 typedef itk::SmartPointer<Self> Pointer;
00053 typedef itk::SmartPointer<const Self> ConstPointer;
00054 typedef itk::WeakPointer<const Self> ConstWeakPointer;
00055 itkNewMacro(Self);
00056
00057
00058
00060 double intensityRequirement;
00061
00063 double duration;
00064
00066 VectorType translateLoc;
00067
00069
00072 bool fillFromStream(std::stringstream &args){
00073 translateLoc = VectorType(nDims);
00074 args>> duration;
00075 args>> intensityRequirement;
00076 for(int i=0;i<nDims;i++){
00077 args >> translateLoc(i);}
00078 return true;};
00079
00080 protected:
00081 behaviorIn(){};
00082 };
00083
00084 virtual bool run(typename Behavior<Type,nDims>::behaviorIn * i, std::stringstream *s);
00085 bool isFinished();
00086
00087 virtual bool update();
00088 virtual void cleanUp();
00089
00091 typename TInputImage::Pointer image;
00092
00094 typename Geometric<Type,nDims>::Pointer geomLayer;
00095
00096 private:
00097 void translate(VectorType &loc);
00098 void scale();
00099
00100 double startTime;
00101 double endTime;
00102 typedef Sense_AvgIntensity<Type, TInputImage,nDims> AvgIntensitySensorType;
00103 typename AvgIntensitySensorType::Pointer avgIntensitySensor;
00104
00105 typedef Beh_TranslateAll<Type,nDims> TranslateBehaviorType;
00106 typedef Beh_UniformScale<Type,nDims> ScaleBehaviorType;
00107
00108 typename TranslateBehaviorType::Pointer translateBehavior;
00109 typename ScaleBehaviorType::Pointer scaleBehavior;
00110
00111 typename behaviorIn::Pointer input;
00112
00113 bool found;
00114
00115 protected:
00116 Beh_SearchForObject();
00117 };
00118 }
00119 #include "Beh_SearchForObject.cxx"
00120 #endif