ITK  4.4.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 
115 protected:
118  void PrintSelf(std::ostream & os, Indent indent) const;
119 
123  virtual void Initialize();
124 
127  virtual void AllocateUpdateBuffer() {}
128 
131  virtual NodeDataType DataConstraint(const NodeDataType & data) const
132  { return data; }
133 
134 private:
137  // this is the first element
138  typename NodeListType::Iterator first;
139  // this is one past the last element
140  typename NodeListType::Iterator last;
141  };
142 
143 protected:
146 
149  virtual void ApplyUpdate(const TimeStepType& dt);
150 
153 
154  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
155  const ThreadRegionType & regionToProcess,
156  ThreadIdType threadId);
157 
160  virtual TimeStepType CalculateChange();
161 
164 
166  (const ThreadRegionType & regionToProcess, ThreadIdType threadId);
167 
171  virtual void PrecalculateChange();
172 
175 
176  virtual void ThreadedPrecalculateChange
177  (const ThreadRegionType & regionToProcess, ThreadIdType threadId);
178 
181  struct FDThreadStruct {
184  std::vector< TimeStepType > TimeStepList;
185  std::vector< bool > ValidTimeStepList;
186  };
187 
188 private:
191 
194 
197  typename NodeListType::RegionListType m_RegionList;
198 
199  FiniteDifferenceSparseImageFilter(const Self &); //purposely not implemented
200  void operator=(const Self &); //purposely not implemented
201 };
202 } // end namespace itk
203 
204 #ifndef ITK_MANUAL_INSTANTIATION
205 #include "itkFiniteDifferenceSparseImageFilter.hxx"
206 #endif
207 
208 #endif
209