ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkGPUFiniteDifferenceImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkGPUFiniteDifferenceImageFilter_h
19 #define __itkGPUFiniteDifferenceImageFilter_h
20 
24 #include "itkTimeProbe.h"
25 
26 namespace itk
27 {
35 template< class TInputImage, class TOutputImage, class TParentImageFilter =
36  FiniteDifferenceImageFilter< TInputImage, TOutputImage > >
38  public GPUInPlaceImageFilter< TInputImage, TOutputImage, TParentImageFilter >
39 {
40 public:
41 
45  typedef TParentImageFilter CPUSuperclass;
48 
51 
53  typedef TInputImage InputImageType;
54  typedef TOutputImage OutputImageType;
55 
57  itkStaticConstMacro(ImageDimension, unsigned int, OutputImageType::ImageDimension);
58 
60  typedef typename TOutputImage::PixelType OutputPixelType;
61  typedef typename TInputImage::PixelType InputPixelType;
63 
67 
72  //typedef typename GPUFiniteDifferenceFunction< TOutputImage >
73  // FiniteDifferenceFunctionType;
74  typedef typename FiniteDifferenceFunctionType::TimeStepType TimeStepType;
75  typedef typename FiniteDifferenceFunctionType::RadiusType RadiusType;
76  typedef typename FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType;
77 
81  itkGetConstReferenceObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType);
82  //itkGetMacro(DifferenceFunction, FiniteDifferenceFunctionType);
84 
88  itkSetObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType);
89 
90  typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
91 
94  itkSetMacro(UseImageSpacing, bool);
95  itkBooleanMacro(UseImageSpacing);
96  itkGetConstReferenceMacro(UseImageSpacing, bool);
98 
101  itkSetMacro(MaximumRMSError, double);
102  itkGetConstReferenceMacro(MaximumRMSError, double);
104 
107  itkSetMacro(RMSChange, double);
108  itkGetConstReferenceMacro(RMSChange, double);
110 
112  void SetStateToInitialized()
113  {
114  this->SetState(INITIALIZED);
115  }
116 
118  void SetStateToUninitialized()
119  {
120  this->SetState(UNINITIALIZED);
121  }
122 
124 #if !defined( CABLE_CONFIGURATION )
125  itkSetMacro(State, FilterStateType);
126  itkGetConstReferenceMacro(State, FilterStateType);
127 #endif
128 
129 
132  itkSetMacro(ManualReinitialization, bool);
133  itkGetConstReferenceMacro(ManualReinitialization, bool);
134  itkBooleanMacro(ManualReinitialization);
136 
137 #ifdef ITK_USE_STRICT_CONCEPT_CHECKING
138 
139  itkConceptMacro( OutputPixelIsFloatingPointCheck,
141 
143 #endif
144 
146  itkGetConstReferenceMacro(InitTime, TimeProbe);
147  itkGetConstReferenceMacro(ComputeUpdateTime, TimeProbe);
148  itkGetConstReferenceMacro(ApplyUpdateTime, TimeProbe);
149  itkGetConstReferenceMacro(SmoothFieldTime, TimeProbe);
151 
152 protected:
155 
156  void PrintSelf(std::ostream & os, Indent indent) const;
157 
159  virtual void AllocateUpdateBuffer() = 0;
160 
164  virtual void GPUApplyUpdate(const TimeStepType& dt) = 0;
165 
171  virtual TimeStepType GPUCalculateChange() = 0;
172 
176  virtual void CopyInputToOutput() = 0;
177 
181  virtual void GPUGenerateData();
182 
194  virtual void GenerateInputRequestedRegion();
195 
198  virtual bool Halt();
199 
209  virtual bool ThreadedHalt( void *itkNotUsed(threadInfo) ) {
210  return this->Halt();
211  }
212 
218  virtual void Initialize() {
219  }
220 
227  virtual void InitializeIteration()
228  {
229  m_DifferenceFunction->InitializeIteration();
230  }
231 
244 virtual TimeStepType ResolveTimeStep(const std::vector<TimeStepType >& timeStepList,
245  const std::vector< bool >& valid) const;
246 
249  virtual void PostProcessOutput() {
250  }
251 
253  itkSetMacro(ElapsedIterations, IdentifierType);
254 
257  //unsigned int m_NumberOfIterations;
258 
261  //unsigned int m_ElapsedIterations;
262 
266 
267  double m_RMSChange;
269 
271  TimeProbe m_InitTime, m_ComputeUpdateTime, m_ApplyUpdateTime, m_SmoothFieldTime;
272 
273 private:
274 
275  GPUFiniteDifferenceImageFilter(const Self &); //purposely not implemented
276  void operator=(const Self &); //purposely not implemented
277 
281  void InitializeFunctionCoefficients();
282 
284  typename FiniteDifferenceFunctionType::Pointer m_DifferenceFunction;
285 
289 
291  FilterStateType m_State;
292 };
293 } // end namespace itk
294 
295 #ifndef ITK_MANUAL_INSTANTIATION
296 #include "itkGPUFiniteDifferenceImageFilter.hxx"
297 #endif
298 
299 #endif
300