Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkNarrowBandImageFilterBase_h
00018 #define __itkNarrowBandImageFilterBase_h
00019
00020 #include "itkFiniteDifferenceImageFilter.h"
00021 #include "itkMultiThreader.h"
00022 #include "itkNarrowBand.h"
00023 #include "itkBarrier.h"
00024 #include "itkObjectStore.h"
00025
00026 namespace itk {
00027
00065 template <class TInputImage, class TOutputImage>
00066 class NarrowBandImageFilterBase
00067 : public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
00068 {
00069 public:
00070
00072 typedef NarrowBandImageFilterBase Self;
00073 typedef FiniteDifferenceImageFilter<TInputImage, TOutputImage> Superclass;
00074 typedef SmartPointer<Self> Pointer;
00075 typedef SmartPointer<const Self> ConstPointer;
00076
00078 itkTypeMacro(NarrowBandImageFilterBase, ImageToImageFilter );
00079
00081 typedef typename Superclass::InputImageType InputImageType;
00082 typedef typename Superclass::OutputImageType OutputImageType;
00083 typedef typename Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType;
00084
00087 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00088
00091 typedef typename Superclass::PixelType PixelType;
00092
00094 typedef typename Superclass::TimeStepType TimeStepType;
00095
00097 typedef typename OutputImageType::IndexType IndexType;
00098
00101 typedef typename OutputImageType::ValueType ValueType;
00102
00104 typedef BandNode<IndexType,PixelType> BandNodeType;
00105
00107 typedef NarrowBand<BandNodeType> NarrowBandType;
00108 typedef typename NarrowBandType::Pointer NarrowBandPointer;
00109 typedef typename NarrowBandType::RegionType RegionType;
00110
00112 itkSetMacro( IsoSurfaceValue, ValueType);
00113 itkGetConstMacro( IsoSurfaceValue, ValueType);
00115
00117
00118
00123 void InsertNarrowBandNode (BandNodeType &node)
00124 {
00125 m_NarrowBand->PushBack(node);
00126 this->Modified();
00127 }
00128 void InsertNarrowBandNode (IndexType &index)
00129 {
00130 BandNodeType tmpnode;
00131 tmpnode.m_Index = index;
00132 m_NarrowBand->PushBack(tmpnode);
00133 this->Modified();
00134 }
00135 void InsertNarrowBandNode (IndexType &index, PixelType &value, signed char &nodestate)
00136 {
00137 BandNodeType tmpnode;
00138 tmpnode.m_Data = value;
00139 tmpnode.m_Index = index;
00140 tmpnode.m_NodeState = nodestate;
00142
00143 m_NarrowBand->PushBack(tmpnode);
00144 this->Modified();
00145 }
00146
00150 void SetNarrowBandTotalRadius (float val)
00151 {
00152 if (m_NarrowBand->GetTotalRadius() != val)
00153 {
00154 m_NarrowBand->SetTotalRadius(val);
00155 this->Modified();
00156 }
00157 }
00159
00161 float GetNarrowBandTotalRadius()
00162 {
00163 return m_NarrowBand->GetTotalRadius();
00164 }
00165
00168 void SetNarrowBandInnerRadius (float val)
00169 {
00170 if (m_NarrowBand->GetInnerRadius() != val)
00171 {
00172 m_NarrowBand->SetInnerRadius(val);
00173 this->Modified();
00174 }
00175 }
00177
00179 float GetNarrowBandInnerRadius()
00180 {
00181 return m_NarrowBand->GetInnerRadius();
00182 }
00183
00189 virtual void CreateNarrowBand (){};
00190
00191 virtual void SetNarrowBand(NarrowBandType * ptr)
00192 {
00193 if ( m_NarrowBand != ptr )
00194 {
00195 m_NarrowBand = ptr;
00196 this->Modified();
00197 }
00198 }
00199
00200 virtual void CopyInputToOutput ();
00201
00202 protected:
00203 typename NarrowBandType::Pointer m_NarrowBand;
00204 NarrowBandImageFilterBase()
00205 {
00206 m_NarrowBand = NarrowBandType::New();
00207 m_NarrowBand->SetTotalRadius(4);
00208 m_NarrowBand->SetInnerRadius(2);
00209 m_ReinitializationFrequency = 6;
00210 m_IsoSurfaceValue = 0.0;
00211 m_Step = 0;
00212 m_Touched = false;
00213 m_Barrier = Barrier::New();
00214 }
00215
00216 virtual ~NarrowBandImageFilterBase() {}
00217 void PrintSelf(std::ostream& os, Indent indent) const;
00218
00221 struct ThreadRegionType
00222 {
00223 typename NarrowBandType::Iterator first;
00224 typename NarrowBandType::Iterator last;
00225 };
00226
00229 std::vector<RegionType> m_RegionList;
00230
00233 void GetSplitRegion (int i, ThreadRegionType &splitRegion);
00234
00239 virtual void Initialize();
00240
00245 virtual void InitializeIteration();
00246
00249 virtual void PostProcessOutput();
00250
00251
00252 void ClearNarrowBand ();
00253
00255 void WaitForAll();
00256
00260 virtual void GenerateData();
00261
00262
00263 unsigned int m_ReinitializationFrequency;
00264 unsigned int m_Step;
00265 bool m_Touched;
00266 bool * m_TouchedForThread;
00267 ValueType m_IsoSurfaceValue;
00268
00269 typename Barrier::Pointer m_Barrier;
00270
00271 private:
00272 NarrowBandImageFilterBase(const Self&);
00273 void operator=(const Self&);
00274
00277 struct NarrowBandImageFilterBaseThreadStruct
00278 {
00279 NarrowBandImageFilterBase *Filter;
00280 TimeStepType TimeStep;
00281 TimeStepType *TimeStepList;
00282 bool *ValidTimeStepList;
00283 };
00284
00285
00286
00287
00288
00289
00290 virtual void AllocateUpdateBuffer() {};
00291
00292
00294 static ITK_THREAD_RETURN_TYPE IterateThreaderCallback( void *arg );
00295
00299 virtual void ThreadedIterate(void *arg, int threadId);
00300
00304 virtual void ThreadedApplyUpdate(TimeStepType dt,
00305 const ThreadRegionType ®ionToProcess,
00306 int threadId);
00307 virtual void ApplyUpdate(TimeStepType){}
00308
00312 virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType ®ionToProcess,
00313 int threadId);
00314 virtual TimeStepType CalculateChange() {return 0;}
00316
00317 };
00318
00319 }
00320
00321 #ifndef ITK_MANUAL_INSTANTIATION
00322 #include "itkNarrowBandImageFilterBase.txx"
00323 #endif
00324
00325 #endif
00326