ITK  5.3.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  * 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, TSparseOutputImageType>
65 {
66 public:
67  ITK_DISALLOW_COPY_AND_MOVE(FiniteDifferenceSparseImageFilter);
68 
72 
75 
78 
80  using InputImageType = typename Superclass::InputImageType;
81  using SparseOutputImageType = typename Superclass::OutputImageType;
82  using PixelType = typename Superclass::PixelType;
83  using TimeStepType = typename Superclass::TimeStepType;
84  using FiniteDifferenceFunctionType = typename Superclass::FiniteDifferenceFunctionType;
85  // the PixelType is from output image; therefore, it is a pointer
86 
89  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
90 
94  using OutputNodeType = typename SparseOutputImageType::NodeType;
95  using NodeListType = typename SparseOutputImageType::NodeListType;
96 
98  using NodeDataType = typename OutputNodeType::NodeDataType;
99 
103  using NodeValueType = typename OutputNodeType::NodeValueType;
104 
107 
109  void
110  SetSparseFunction(SparseFunctionType * sf);
111 
112  itkSetMacro(PrecomputeFlag, bool);
113  itkGetConstMacro(PrecomputeFlag, bool);
114 
115 protected:
117  ~FiniteDifferenceSparseImageFilter() override = default;
118  void
119  PrintSelf(std::ostream & os, Indent indent) const override;
120 
124  void
125  Initialize() override;
126 
129  void
131  {}
132 
135  virtual NodeDataType
136  DataConstraint(const NodeDataType & data) const
137  {
138  return data;
139  }
140 
141 private:
144  {
145  // this is the first element
146  typename NodeListType::Iterator first;
147  // this is one past the last element
148  typename NodeListType::Iterator last;
149  };
150 
151 protected:
154  GetSplitRegion(ThreadIdType i, ThreadIdType num, ThreadRegionType & splitRegion);
155 
158  void
159  ApplyUpdate(const TimeStepType & dt) override;
160 
163  ApplyUpdateThreaderCallback(void * arg);
164 
165  virtual void
166  ThreadedApplyUpdate(const TimeStepType & dt, const ThreadRegionType & regionToProcess, ThreadIdType threadId);
167 
171  CalculateChange() override;
172 
175  CalculateChangeThreaderCallback(void * arg);
176 
177  virtual TimeStepType
178  ThreadedCalculateChange(const ThreadRegionType & regionToProcess, ThreadIdType threadId);
179 
183  virtual void
184  PrecalculateChange();
185 
188  PrecalculateChangeThreaderCallback(void * arg);
189 
190  virtual void
191  ThreadedPrecalculateChange(const ThreadRegionType & regionToProcess, ThreadIdType threadId);
192 
196  {
199  std::vector<TimeStepType> TimeStepList;
200  std::vector<bool> ValidTimeStepList;
201  };
202 
203 private:
206 
209 
212  typename NodeListType::RegionListType m_RegionList;
213 };
214 } // end namespace itk
215 
216 #ifndef ITK_MANUAL_INSTANTIATION
217 # include "itkFiniteDifferenceSparseImageFilter.hxx"
218 #endif
219 
220 #endif
itk::FiniteDifferenceSparseImageFilter::m_SparseFunction
SparseFunctionType * m_SparseFunction
Definition: itkFiniteDifferenceSparseImageFilter.h:208
itkFiniteDifferenceImageFilter.h
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::IndexType
typename SparseOutputImageType::IndexType IndexType
Definition: itkFiniteDifferenceSparseImageFilter.h:92
itk::FiniteDifferenceSparseImageFunction
This is the base class for function classes that can be used with filters derived from FiniteDifferen...
Definition: itkFiniteDifferenceSparseImageFunction.h:47
itk::FiniteDifferenceSparseImageFilter::ThreadRegionType::last
NodeListType::Iterator last
Definition: itkFiniteDifferenceSparseImageFilter.h:148
itk::FiniteDifferenceSparseImageFilter::m_RegionList
NodeListType::RegionListType m_RegionList
Definition: itkFiniteDifferenceSparseImageFilter.h:212
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct
Definition: itkFiniteDifferenceSparseImageFilter.h:195
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::ValidTimeStepList
std::vector< bool > ValidTimeStepList
Definition: itkFiniteDifferenceSparseImageFilter.h:200
itk::FiniteDifferenceImageFilter< TInputImage, TSparseOutputImage >::TimeStepType
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
Definition: itkFiniteDifferenceImageFilter.h:166
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::FiniteDifferenceSparseImageFilter::TimeStepType
typename Superclass::TimeStepType TimeStepType
Definition: itkFiniteDifferenceSparseImageFilter.h:83
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::NodeDataType
typename OutputNodeType::NodeDataType NodeDataType
Definition: itkFiniteDifferenceSparseImageFilter.h:98
itkFiniteDifferenceSparseImageFunction.h
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::SizeType
typename SparseOutputImageType::SizeType SizeType
Definition: itkFiniteDifferenceSparseImageFilter.h:93
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
Definition: itkThreadSupport.h:82
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::TimeStepList
std::vector< TimeStepType > TimeStepList
Definition: itkFiniteDifferenceSparseImageFilter.h:199
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::SparseOutputImageType
typename Superclass::OutputImageType SparseOutputImageType
Definition: itkFiniteDifferenceSparseImageFilter.h:81
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::FiniteDifferenceSparseImageFilter::m_PrecomputeFlag
bool m_PrecomputeFlag
Definition: itkFiniteDifferenceSparseImageFilter.h:205
itk::ImageToImageFilter< TInputImage, TSparseOutputImage >::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::FiniteDifferenceImageFilter
Definition: itkFiniteDifferenceImageFilter.h:132
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::OutputNodeType
typename SparseOutputImageType::NodeType OutputNodeType
Definition: itkFiniteDifferenceSparseImageFilter.h:94
itk::FiniteDifferenceSparseImageFilter::AllocateUpdateBuffer
void AllocateUpdateBuffer() override
Definition: itkFiniteDifferenceSparseImageFilter.h:130
itk::FiniteDifferenceImageFilter< TInputImage, TSparseOutputImage >::PixelType
OutputPixelType PixelType
Definition: itkFiniteDifferenceImageFilter.h:156
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::NodeListType
typename SparseOutputImageType::NodeListType NodeListType
Definition: itkFiniteDifferenceSparseImageFilter.h:95
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkMultiThreaderBase.h
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::Filter
FiniteDifferenceSparseImageFilter * Filter
Definition: itkFiniteDifferenceSparseImageFilter.h:197
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::NodeValueType
typename OutputNodeType::NodeValueType NodeValueType
Definition: itkFiniteDifferenceSparseImageFilter.h:103
itk::FiniteDifferenceFunction
Definition: itkFiniteDifferenceFunction.h:66
itkSparseImage.h
itk::FiniteDifferenceSparseImageFilter
This class implements a multi-threaded base class for Image to SparseImage finite difference processe...
Definition: itkFiniteDifferenceSparseImageFilter.h:63
itk::FiniteDifferenceSparseImageFilter::DataConstraint
virtual NodeDataType DataConstraint(const NodeDataType &data) const
Definition: itkFiniteDifferenceSparseImageFilter.h:136
itk::FiniteDifferenceSparseImageFilter::ThreadRegionType::first
NodeListType::Iterator first
Definition: itkFiniteDifferenceSparseImageFilter.h:146
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::TimeStep
TimeStepType TimeStep
Definition: itkFiniteDifferenceSparseImageFilter.h:198
itk::FiniteDifferenceSparseImageFilter::ThreadRegionType
Definition: itkFiniteDifferenceSparseImageFilter.h:143