ITK  4.9.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 
75 
79  virtual const typename FiniteDifferenceFunctionType::Pointer &GetDifferenceFunction() const ITK_OVERRIDE
80  {
81  return this->m_DifferenceFunction;
82  }
83 
87  virtual void SetDifferenceFunction ( FiniteDifferenceFunctionType *differenceFunction ) ITK_OVERRIDE
88  {
89  itkDebugMacro("setting m_DifferenceFunction to " << differenceFunction);
90  if ( this->m_DifferenceFunction != differenceFunction )
91  {
92  this->m_DifferenceFunction = differenceFunction;
93  this->Modified();
94  }
95  }
97 
98  typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
99 
102  {
103  this->SetState(INITIALIZED);
104  }
105 
108  {
109  this->SetState(UNINITIALIZED);
110  }
111 
113 #if !defined( ITK_WRAPPING_PARSER )
114  itkSetMacro(State, FilterStateType);
115  itkGetConstReferenceMacro(State, FilterStateType);
116 #endif
117 
118 
119 #ifdef ITK_USE_STRICT_CONCEPT_CHECKING
120  // Begin concept checking
121  itkConceptMacro( OutputPixelIsFloatingPointCheck,
123  // End concept checking
124 #endif
125 
127  itkGetConstReferenceMacro(InitTime, TimeProbe);
128  itkGetConstReferenceMacro(ComputeUpdateTime, TimeProbe);
129  itkGetConstReferenceMacro(ApplyUpdateTime, TimeProbe);
130  itkGetConstReferenceMacro(SmoothFieldTime, TimeProbe);
132 
133 protected:
136 
137  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
138 
140  virtual void AllocateUpdateBuffer() ITK_OVERRIDE = 0;
141 
145  virtual void GPUApplyUpdate(const TimeStepType& dt) = 0;
146 
152  virtual TimeStepType GPUCalculateChange() = 0;
153 
157  virtual void CopyInputToOutput() ITK_OVERRIDE = 0;
158 
162  virtual void GPUGenerateData() ITK_OVERRIDE;
163 
175  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
176 
179  virtual bool Halt() ITK_OVERRIDE;
180 
190  virtual bool ThreadedHalt( void *itkNotUsed(threadInfo) ) ITK_OVERRIDE {
191  return this->Halt();
192  }
193 
199  virtual void Initialize() ITK_OVERRIDE {
200  }
201 
208  virtual void InitializeIteration() ITK_OVERRIDE
209  {
210  m_DifferenceFunction->InitializeIteration();
211  }
212 
225  virtual TimeStepType ResolveTimeStep(const std::vector<TimeStepType >& timeStepList,
226  const std::vector< bool >& valid) const ITK_OVERRIDE;
227 
230  virtual void PostProcessOutput() ITK_OVERRIDE {
231  }
232 
235  //unsigned int m_NumberOfIterations;
236 
239  //unsigned int m_ElapsedIterations;
240 
244 
245  double m_RMSChange;
247 
250 
251 private:
252 
253  GPUFiniteDifferenceImageFilter(const Self &) ITK_DELETE_FUNCTION;
254  void operator=(const Self &) ITK_DELETE_FUNCTION;
255 
260 
263 
267 
270 };
271 } // end namespace itk
272 
273 #ifndef ITK_MANUAL_INSTANTIATION
274 #include "itkGPUFiniteDifferenceImageFilter.hxx"
275 #endif
276 
277 #endif
virtual void GPUGenerateData() override
class to abstract the behaviour of the GPU filters.
FiniteDifferenceFunctionType::RadiusType RadiusType
virtual void CopyInputToOutput() override=0
Computes the time passed between two points in code.
Definition: itkTimeProbe.h:44
void PrintSelf(std::ostream &os, Indent indent) const override
virtual const FiniteDifferenceFunctionType::Pointer & GetDifferenceFunction() const override
FiniteDifferenceFunctionType::TimeStepType TimeStepType
NumericTraits< OutputPixelType >::ValueType OutputPixelValueType
Vector< PixelRealType, itkGetStaticConstMacro(ImageDimension) > NeighborhoodScalesType
Base class for GPU Finite Difference Image Filters.
ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
virtual TimeStepType ResolveTimeStep(const std::vector< TimeStepType > &timeStepList, const std::vector< bool > &valid) const override
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
virtual void GenerateInputRequestedRegion() override
GPUInPlaceImageFilter< TInputImage, TOutputImage, TParentImageFilter > GPUSuperclass
virtual bool Halt() override
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 void SetDifferenceFunction(FiniteDifferenceFunctionType *differenceFunction) override
virtual void AllocateUpdateBuffer() override=0
virtual TimeStepType GPUCalculateChange()=0
#define itkConceptMacro(name, concept)