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"
24 #include "itkMultiThreaderBase.h"
25 #include "itkSparseImage.h"
26 
27 namespace itk
28 {
63 template <typename TInputImageType, typename TSparseOutputImageType>
64 class ITK_TEMPLATE_EXPORT FiniteDifferenceSparseImageFilter
65  : public FiniteDifferenceImageFilter<TInputImageType, TSparseOutputImageType>
66 {
67 public:
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
111  SetSparseFunction(SparseFunctionType * sf);
112 
113  itkSetMacro(PrecomputeFlag, bool);
114  itkGetConstMacro(PrecomputeFlag, bool);
115 
116 protected:
118  ~FiniteDifferenceSparseImageFilter() override = default;
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 
142 private:
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 
152 protected:
155  GetSplitRegion(ThreadIdType i, ThreadIdType num, ThreadRegionType & splitRegion);
156 
159  void
160  ApplyUpdate(const TimeStepType & dt) override;
161 
164  ApplyUpdateThreaderCallback(void * arg);
165 
166  virtual void
167  ThreadedApplyUpdate(const TimeStepType & dt, const ThreadRegionType & regionToProcess, ThreadIdType threadId);
168 
172  CalculateChange() override;
173 
176  CalculateChangeThreaderCallback(void * arg);
177 
178  virtual TimeStepType
179  ThreadedCalculateChange(const ThreadRegionType & regionToProcess, ThreadIdType threadId);
180 
184  virtual void
185  PrecalculateChange();
186 
189  PrecalculateChangeThreaderCallback(void * arg);
190 
191  virtual void
192  ThreadedPrecalculateChange(const ThreadRegionType & regionToProcess, ThreadIdType threadId);
193 
197  {
199  TimeStepType TimeStep;
200  std::vector<TimeStepType> TimeStepList;
202  };
203 
204 private:
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
itkFiniteDifferenceImageFilter.h
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::IndexType
typename SparseOutputImageType::IndexType IndexType
Definition: itkFiniteDifferenceSparseImageFilter.h:93
itkBooleanStdVector.h
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:149
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct
Definition: itkFiniteDifferenceSparseImageFilter.h:196
itk::BooleanStdVectorType
std::vector< Boolean > BooleanStdVectorType
Definition: itkBooleanStdVector.h:34
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::TimeStepType
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
Definition: itkFiniteDifferenceImageFilter.h:167
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::ValidTimeStepList
BooleanStdVectorType ValidTimeStepList
Definition: itkFiniteDifferenceSparseImageFilter.h:201
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::NodeDataType
typename OutputNodeType::NodeDataType NodeDataType
Definition: itkFiniteDifferenceSparseImageFilter.h:99
itkFiniteDifferenceSparseImageFunction.h
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::SizeType
typename SparseOutputImageType::SizeType SizeType
Definition: itkFiniteDifferenceSparseImageFilter.h:94
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
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:79
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::TimeStepList
std::vector< TimeStepType > TimeStepList
Definition: itkFiniteDifferenceSparseImageFilter.h:200
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::SparseOutputImageType
typename Superclass::OutputImageType SparseOutputImageType
Definition: itkFiniteDifferenceSparseImageFilter.h:82
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::FiniteDifferenceImageFilter
Definition: itkFiniteDifferenceImageFilter.h:133
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::OutputNodeType
typename SparseOutputImageType::NodeType OutputNodeType
Definition: itkFiniteDifferenceSparseImageFilter.h:95
itk::FiniteDifferenceSparseImageFilter::AllocateUpdateBuffer
void AllocateUpdateBuffer() override
Definition: itkFiniteDifferenceSparseImageFilter.h:131
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::NodeListType
typename SparseOutputImageType::NodeListType NodeListType
Definition: itkFiniteDifferenceSparseImageFilter.h:96
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkMultiThreaderBase.h
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::Filter
FiniteDifferenceSparseImageFilter * Filter
Definition: itkFiniteDifferenceSparseImageFilter.h:198
itk::FiniteDifferenceSparseImageFilter< TInputImage, TSparseOutputImage >::NodeValueType
typename OutputNodeType::NodeValueType NodeValueType
Definition: itkFiniteDifferenceSparseImageFilter.h:104
itkSparseImage.h
itk::FiniteDifferenceSparseImageFilter
This class implements a multi-threaded base class for Image to SparseImage finite difference processe...
Definition: itkFiniteDifferenceSparseImageFilter.h:64
itk::FiniteDifferenceSparseImageFilter::DataConstraint
virtual NodeDataType DataConstraint(const NodeDataType &data) const
Definition: itkFiniteDifferenceSparseImageFilter.h:137
itk::FiniteDifferenceSparseImageFilter::ThreadRegionType::first
NodeListType::Iterator first
Definition: itkFiniteDifferenceSparseImageFilter.h:147
itk::FiniteDifferenceSparseImageFilter::FDThreadStruct::TimeStep
TimeStepType TimeStep
Definition: itkFiniteDifferenceSparseImageFilter.h:199
itk::FiniteDifferenceSparseImageFilter::ThreadRegionType
Definition: itkFiniteDifferenceSparseImageFilter.h:144