ITK  6.0.0
Insight Toolkit
itkFiniteDifferenceSparseImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
21#include "itkBooleanStdVector.h"
25#include "itkSparseImage.h"
26
27namespace itk
28{
63template <typename TInputImageType, typename TSparseOutputImageType>
64class ITK_TEMPLATE_EXPORT FiniteDifferenceSparseImageFilter
65 : public FiniteDifferenceImageFilter<TInputImageType, TSparseOutputImageType>
66{
67public:
68 ITK_DISALLOW_COPY_AND_MOVE(FiniteDifferenceSparseImageFilter);
69
73
76
78 itkOverrideGetNameOfClassMacro(FiniteDifferenceSparseImageFilter);
79
81 using typename Superclass::InputImageType;
82 using SparseOutputImageType = typename Superclass::OutputImageType;
83 using typename Superclass::PixelType;
84 using typename Superclass::TimeStepType;
85 using typename Superclass::FiniteDifferenceFunctionType;
86 // the PixelType is from output image; therefore, it is a pointer
87
90 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
91
95 using OutputNodeType = typename SparseOutputImageType::NodeType;
96 using NodeListType = typename SparseOutputImageType::NodeListType;
97
99 using NodeDataType = typename OutputNodeType::NodeDataType;
100
104 using NodeValueType = typename OutputNodeType::NodeValueType;
105
108
110 void
112
113 itkSetMacro(PrecomputeFlag, bool);
114 itkGetConstMacro(PrecomputeFlag, bool);
115
116protected:
119 void
120 PrintSelf(std::ostream & os, Indent indent) const override;
121
125 void
126 Initialize() override;
127
130 void
132 {}
133
136 virtual NodeDataType
137 DataConstraint(const NodeDataType & data) const
138 {
139 return data;
140 }
141
142private:
145 {
146 // this is the first element
147 typename NodeListType::Iterator first;
148 // this is one past the last element
149 typename NodeListType::Iterator last;
150 };
151
152protected:
156
159 void
160 ApplyUpdate(const TimeStepType & dt) override;
161
165
166 virtual void
167 ThreadedApplyUpdate(const TimeStepType & dt, const ThreadRegionType & regionToProcess, ThreadIdType threadId);
168
172 CalculateChange() override;
173
177
178 virtual TimeStepType
179 ThreadedCalculateChange(const ThreadRegionType & regionToProcess, ThreadIdType threadId);
180
184 virtual void
186
190
191 virtual void
192 ThreadedPrecalculateChange(const ThreadRegionType & regionToProcess, ThreadIdType threadId);
193
197 {
200 std::vector<TimeStepType> TimeStepList;
202 };
203
204private:
206 bool m_PrecomputeFlag{};
207
209 SparseFunctionType * m_SparseFunction{};
210
213 typename NodeListType::RegionListType m_RegionList{};
214};
215} // end namespace itk
216
217#ifndef ITK_MANUAL_INSTANTIATION
218# include "itkFiniteDifferenceSparseImageFilter.hxx"
219#endif
220
221#endif
This class implements a multi-threaded base class for Image to SparseImage finite difference processe...
typename SparseOutputImageType::SizeType SizeType
typename OutputNodeType::NodeDataType NodeDataType
virtual void ThreadedPrecalculateChange(const ThreadRegionType &regionToProcess, ThreadIdType threadId)
virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType &regionToProcess, ThreadIdType threadId)
ThreadIdType GetSplitRegion(ThreadIdType i, ThreadIdType num, ThreadRegionType &splitRegion)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION PrecalculateChangeThreaderCallback(void *arg)
void ApplyUpdate(const TimeStepType &dt) override
typename SparseOutputImageType::NodeType OutputNodeType
virtual NodeDataType DataConstraint(const NodeDataType &data) const
typename Superclass::OutputImageType SparseOutputImageType
void SetSparseFunction(SparseFunctionType *sf)
~FiniteDifferenceSparseImageFilter() override=default
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ApplyUpdateThreaderCallback(void *arg)
void PrintSelf(std::ostream &os, Indent indent) const override
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION CalculateChangeThreaderCallback(void *arg)
typename OutputNodeType::NodeValueType NodeValueType
TimeStepType CalculateChange() override
typename SparseOutputImageType::NodeListType NodeListType
typename SparseOutputImageType::IndexType IndexType
virtual void ThreadedApplyUpdate(const TimeStepType &dt, const ThreadRegionType &regionToProcess, ThreadIdType threadId)
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:50
Light weight base class for most itk classes.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
std::vector< Boolean > BooleanStdVectorType