ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkDenseFiniteDifferenceImageFilter.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 __itkDenseFiniteDifferenceImageFilter_h
19 #define __itkDenseFiniteDifferenceImageFilter_h
20 
22 #include "itkMultiThreader.h"
23 
24 namespace itk
25 {
68 template< class TInputImage, class TOutputImage >
70  public FiniteDifferenceImageFilter< TInputImage, TOutputImage >
71 {
72 public:
73 
77  TInputImage, TOutputImage > Superclass;
78 
81 
84 
86  typedef typename Superclass::InputImageType InputImageType;
87  typedef typename Superclass::OutputImageType OutputImageType;
88  typedef typename Superclass::FiniteDifferenceFunctionType
90 
93  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
94 
97  typedef typename Superclass::PixelType PixelType;
98 
100  typedef typename Superclass::TimeStepType TimeStepType;
101 
104 
105 #ifdef ITK_USE_CONCEPT_CHECKING
106 
107  itkConceptMacro( OutputTimesDoubleCheck,
109  itkConceptMacro( OutputAdditiveOperatorsCheck,
111  itkConceptMacro( OutputAdditiveAndAssignOperatorsCheck,
113  itkConceptMacro( InputConvertibleToOutputCheck,
115 
117 #endif
118 protected:
120  { m_UpdateBuffer = UpdateBufferType::New(); }
122  void PrintSelf(std::ostream & os, Indent indent) const;
124 
128  virtual void CopyInputToOutput();
129 
133  virtual void ApplyUpdate(const TimeStepType& dt);
134 
137  virtual UpdateBufferType * GetUpdateBuffer()
138  { return m_UpdateBuffer; }
139 
143  virtual TimeStepType CalculateChange();
144 
147  virtual void AllocateUpdateBuffer();
148 
150  typedef typename UpdateBufferType::RegionType ThreadRegionType;
151 
156  virtual
157  void ThreadedApplyUpdate(const TimeStepType& dt,
158  const ThreadRegionType & regionToProcess,
159  ThreadIdType threadId);
160 
165  virtual
166  TimeStepType ThreadedCalculateChange(const ThreadRegionType & regionToProcess,
167  ThreadIdType threadId);
168 
169 private:
170  DenseFiniteDifferenceImageFilter(const Self &); //purposely not implemented
171  void operator=(const Self &); //purposely not implemented
172 
178  std::vector< TimeStepType > TimeStepList;
179  std::vector< bool > ValidTimeStepList;
180  };
181 
184  static ITK_THREAD_RETURN_TYPE ApplyUpdateThreaderCallback(void *arg);
185 
188  static ITK_THREAD_RETURN_TYPE CalculateChangeThreaderCallback(void *arg);
189 
191  typename UpdateBufferType::Pointer m_UpdateBuffer;
192 };
193 } // end namespace itk
194 
195 // Define instantiation macro for this template.
196 #define ITK_TEMPLATE_DenseFiniteDifferenceImageFilter(_, EXPORT, TypeX, TypeY) \
197  namespace itk \
198  { \
199  _( 2 ( class EXPORT DenseFiniteDifferenceImageFilter< ITK_TEMPLATE_2 TypeX > ) ) \
200  namespace Templates \
201  { \
202  typedef DenseFiniteDifferenceImageFilter< ITK_TEMPLATE_2 TypeX > \
203  DenseFiniteDifferenceImageFilter##TypeY; \
204  } \
205  }
206 
207 #if ITK_TEMPLATE_EXPLICIT
208 #include "Templates/itkDenseFiniteDifferenceImageFilter+-.h"
209 #endif
210 
211 #if ITK_TEMPLATE_TXX
212 #include "itkDenseFiniteDifferenceImageFilter.hxx"
213 #endif
214 
215 #endif
216