ITK  4.13.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< typename TInputImageType, typename TSparseOutputImageType >
63 class ITK_TEMPLATE_EXPORT FiniteDifferenceSparseImageFilter:
64  public FiniteDifferenceImageFilter< TInputImageType,
65  TSparseOutputImageType >
66 {
67 public:
71  TInputImageType, TSparseOutputImageType > Superclass;
72 
75 
78 
80  typedef typename Superclass::InputImageType InputImageType;
81  typedef typename Superclass::OutputImageType SparseOutputImageType;
82  typedef typename Superclass::PixelType PixelType;
83  typedef typename Superclass::TimeStepType TimeStepType;
84  typedef typename Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType;
85  // the PixelType is from output image; therefore, it is a pointer
86 
89  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
90 
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 
110  void SetSparseFunction(SparseFunctionType *sf);
111 
112  itkSetMacro(PrecomputeFlag, bool);
113  itkGetConstMacro(PrecomputeFlag, bool);
114 
115 protected:
118  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
119 
123  virtual void Initialize() ITK_OVERRIDE;
124 
127  virtual void AllocateUpdateBuffer() ITK_OVERRIDE {}
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:
145  ThreadIdType GetSplitRegion(ThreadIdType i, ThreadIdType num, ThreadRegionType & splitRegion);
146 
149  virtual void ApplyUpdate(const TimeStepType& dt) ITK_OVERRIDE;
150 
152  static ITK_THREAD_RETURN_TYPE ApplyUpdateThreaderCallback(void *arg);
153 
154  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
155  const ThreadRegionType & regionToProcess,
156  ThreadIdType threadId);
157 
160  virtual TimeStepType CalculateChange() ITK_OVERRIDE;
161 
163  static ITK_THREAD_RETURN_TYPE CalculateChangeThreaderCallback(void *arg);
164 
165  virtual TimeStepType ThreadedCalculateChange
166  (const ThreadRegionType & regionToProcess, ThreadIdType threadId);
167 
171  virtual void PrecalculateChange();
172 
174  static ITK_THREAD_RETURN_TYPE PrecalculateChangeThreaderCallback(void *arg);
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  ITK_DISALLOW_COPY_AND_ASSIGN(FiniteDifferenceSparseImageFilter);
200 };
201 } // end namespace itk
202 
203 #ifndef ITK_MANUAL_INSTANTIATION
204 #include "itkFiniteDifferenceSparseImageFilter.hxx"
205 #endif
206 
207 #endif
virtual NodeDataType DataConstraint(const NodeDataType &data) const
#define ITK_THREAD_RETURN_TYPE
FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType > Superclass
This class implements a multi-threaded base class for Image to SparseImage finite difference processe...
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
This is the base class for function classes that can be used with filters derived from FiniteDifferen...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
FiniteDifferenceSparseImageFunction< SparseOutputImageType > SparseFunctionType
Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType