ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkFiniteDifferenceSparseImageFilter.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 __itkFiniteDifferenceSparseImageFilter_h
19 #define __itkFiniteDifferenceSparseImageFilter_h
20 
23 #include "itkMultiThreader.h"
24 #include "itkSparseImage.h"
25 
26 namespace itk
27 {
62 template< class TInputImageType, class TSparseOutputImageType >
64  public FiniteDifferenceImageFilter< TInputImageType,
65  TSparseOutputImageType >
66 {
67 public:
71  TInputImageType, TSparseOutputImageType > Superclass;
72 
75 
78 
82  typedef typename Superclass::PixelType PixelType;
85  // the PixelType is from output image; therefore, it is a pointer
86 
89  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
90 
92  typedef typename SparseOutputImageType::IndexType IndexType;
93  typedef typename SparseOutputImageType::SizeType SizeType;
94  typedef typename SparseOutputImageType::NodeType OutputNodeType;
95  typedef typename SparseOutputImageType::NodeListType NodeListType;
96 
98  typedef typename OutputNodeType::NodeDataType NodeDataType;
99 
103  typedef typename OutputNodeType::NodeValueType NodeValueType;
104 
108 
111 
112  itkSetMacro(PrecomputeFlag, bool);
113  itkGetConstMacro(PrecomputeFlag, bool);
114 protected:
117  void PrintSelf(std::ostream & os, Indent indent) const;
118 
122  virtual void Initialize();
123 
126  virtual void AllocateUpdateBuffer() {}
127 
130  virtual NodeDataType DataConstraint(const NodeDataType & data) const
131  { return data; }
132 private:
133 
136  // this is the first element
137  typename NodeListType::Iterator first;
138  // this is one past the last element
139  typename NodeListType::Iterator last;
140  };
141 protected:
142 
145 
148  virtual void ApplyUpdate(const TimeStepType& dt);
149 
152 
153  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
154  const ThreadRegionType & regionToProcess,
155  ThreadIdType threadId);
156 
159  virtual TimeStepType CalculateChange();
160 
163 
165  (const ThreadRegionType & regionToProcess, ThreadIdType threadId);
166 
170  virtual void PrecalculateChange();
171 
174 
175  virtual void ThreadedPrecalculateChange
176  (const ThreadRegionType & regionToProcess, ThreadIdType threadId);
177 
180  struct FDThreadStruct {
183  std::vector< TimeStepType > TimeStepList;
184  std::vector< bool > ValidTimeStepList;
185  };
186 private:
187 
190 
193 
196  typename NodeListType::RegionListType m_RegionList;
197 
198  FiniteDifferenceSparseImageFilter(const Self &); //purposely not implemented
199  void operator=(const Self &); //purposely not implemented
200 };
201 } // end namespace itk
202 
203 #ifndef ITK_MANUAL_INSTANTIATION
204 #include "itkFiniteDifferenceSparseImageFilter.hxx"
205 #endif
206 
207 #endif
208