ITK  4.6.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< typename TInputImage, typename TOutputImage, typename 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 
113  {
114  this->SetState(INITIALIZED);
115  }
116 
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  // Begin concept checking
139  itkConceptMacro( OutputPixelIsFloatingPointCheck,
141  // End concept checking
142 #endif
143 
145  itkGetConstReferenceMacro(InitTime, TimeProbe);
146  itkGetConstReferenceMacro(ComputeUpdateTime, TimeProbe);
147  itkGetConstReferenceMacro(ApplyUpdateTime, TimeProbe);
148  itkGetConstReferenceMacro(SmoothFieldTime, TimeProbe);
150 
151 protected:
154 
155  void PrintSelf(std::ostream & os, Indent indent) const;
156 
158  virtual void AllocateUpdateBuffer() = 0;
159 
163  virtual void GPUApplyUpdate(const TimeStepType& dt) = 0;
164 
170  virtual TimeStepType GPUCalculateChange() = 0;
171 
175  virtual void CopyInputToOutput() = 0;
176 
180  virtual void GPUGenerateData();
181 
193  virtual void GenerateInputRequestedRegion();
194 
197  virtual bool Halt();
198 
208  virtual bool ThreadedHalt( void *itkNotUsed(threadInfo) ) {
209  return this->Halt();
210  }
211 
217  virtual void Initialize() {
218  }
219 
226  virtual void InitializeIteration()
227  {
228  m_DifferenceFunction->InitializeIteration();
229  }
230 
243 virtual TimeStepType ResolveTimeStep(const std::vector<TimeStepType >& timeStepList,
244  const std::vector< bool >& valid) const;
245 
248  virtual void PostProcessOutput() {
249  }
250 
252  itkSetMacro(ElapsedIterations, IdentifierType);
253 
256  //unsigned int m_NumberOfIterations;
257 
260  //unsigned int m_ElapsedIterations;
261 
265 
266  double m_RMSChange;
268 
271 
272 private:
273 
274  GPUFiniteDifferenceImageFilter(const Self &); //purposely not implemented
275  void operator=(const Self &); //purposely not implemented
276 
281 
284 
288 
291 };
292 } // end namespace itk
293 
294 #ifndef ITK_MANUAL_INSTANTIATION
295 #include "itkGPUFiniteDifferenceImageFilter.hxx"
296 #endif
297 
298 #endif
virtual TimeStepType ResolveTimeStep(const std::vector< TimeStepType > &timeStepList, const std::vector< bool > &valid) const
class to abstract the behaviour of the GPU filters.
FiniteDifferenceFunctionType::RadiusType RadiusType
void PrintSelf(std::ostream &os, Indent indent) const
Light weight base class for most itk classes.
Computes the time passed between two points in code.
Definition: itkTimeProbe.h:44
FiniteDifferenceFunctionType::TimeStepType TimeStepType
NumericTraits< OutputPixelType >::ValueType OutputPixelValueType
SmartPointer< Self > Pointer
Base class for GPU Finite Difference Image Filters.
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
GPUFiniteDifferenceFunction< TOutputImage >::DifferenceFunctionType FiniteDifferenceFunctionType
virtual void SetState(FilterStateType _arg)
Base class for GPU filters that take an image as input and overwrite that image as the output...
virtual void GPUApplyUpdate(const TimeStepType &dt)=0
GPUInPlaceImageFilter< TInputImage, TOutputImage, TParentImageFilter > GPUSuperclass
FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType
FiniteDifferenceFunctionType::Pointer m_DifferenceFunction
Control indentation during Print() invocation.
Definition: itkIndent.h:49
NumericTraits< InputPixelType >::ValueType InputPixelValueType
Define additional traits for native types such as int or float.
virtual TimeStepType GPUCalculateChange()=0
#define itkConceptMacro(name, concept)