ITK  5.0.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 "itkMultiThreaderBase.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:
68  ITK_DISALLOW_COPY_AND_ASSIGN(FiniteDifferenceSparseImageFilter);
69 
73  TInputImageType, TSparseOutputImageType >;
74 
77 
80 
82  using InputImageType = typename Superclass::InputImageType;
83  using SparseOutputImageType = typename Superclass::OutputImageType;
84  using PixelType = typename Superclass::PixelType;
85  using TimeStepType = typename Superclass::TimeStepType;
86  using FiniteDifferenceFunctionType = typename Superclass::FiniteDifferenceFunctionType;
87  // the PixelType is from output image; therefore, it is a pointer
88 
91  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
92 
96  using OutputNodeType = typename SparseOutputImageType::NodeType;
97  using NodeListType = typename SparseOutputImageType::NodeListType;
98 
100  using NodeDataType = typename OutputNodeType::NodeDataType;
101 
105  using NodeValueType = typename OutputNodeType::NodeValueType;
106 
109 
111  void SetSparseFunction(SparseFunctionType *sf);
112 
113  itkSetMacro(PrecomputeFlag, bool);
114  itkGetConstMacro(PrecomputeFlag, bool);
115 
116 protected:
118  ~FiniteDifferenceSparseImageFilter() override = default;
119  void PrintSelf(std::ostream & os, Indent indent) const override;
120 
124  void Initialize() override;
125 
128  void AllocateUpdateBuffer() override {}
129 
132  virtual NodeDataType DataConstraint(const NodeDataType & data) const
133  { return data; }
134 
135 private:
138  // this is the first element
139  typename NodeListType::Iterator first;
140  // this is one past the last element
141  typename NodeListType::Iterator last;
142  };
143 
144 protected:
146  ThreadIdType GetSplitRegion(ThreadIdType i, ThreadIdType num, ThreadRegionType & splitRegion);
147 
150  void ApplyUpdate(const TimeStepType& dt) override;
151 
153  static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ApplyUpdateThreaderCallback(void *arg);
154 
155  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
156  const ThreadRegionType & regionToProcess,
157  ThreadIdType threadId);
158 
161  TimeStepType CalculateChange() override;
162 
164  static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION CalculateChangeThreaderCallback(void *arg);
165 
166  virtual TimeStepType ThreadedCalculateChange
167  (const ThreadRegionType & regionToProcess, ThreadIdType threadId);
168 
172  virtual void PrecalculateChange();
173 
175  static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION PrecalculateChangeThreaderCallback(void *arg);
176 
177  virtual void ThreadedPrecalculateChange
178  (const ThreadRegionType & regionToProcess, ThreadIdType threadId);
179 
182  struct FDThreadStruct {
185  std::vector< TimeStepType > TimeStepList;
186  std::vector< bool > ValidTimeStepList;
187  };
188 
189 private:
192 
195 
198  typename NodeListType::RegionListType m_RegionList;
199 
200 };
201 } // end namespace itk
202 
203 #ifndef ITK_MANUAL_INSTANTIATION
204 #include "itkFiniteDifferenceSparseImageFilter.hxx"
205 #endif
206 
207 #endif
Light weight base class for most itk classes.
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
virtual NodeDataType DataConstraint(const NodeDataType &data) const
This class implements a multi-threaded base class for Image to SparseImage finite difference processe...
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
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