ITK  5.3.0
Insight Toolkit
itkBSplineInterpolationWeightFunction.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 itkBSplineInterpolationWeightFunction_h
19 #define itkBSplineInterpolationWeightFunction_h
20 
21 #include "itkFunctionBase.h"
22 #include "itkContinuousIndex.h"
23 #include "itkArray.h"
24 #include "itkArray2D.h"
25 #include "itkIndexRange.h"
26 #include "itkMath.h"
27 
28 namespace itk
29 {
47 template <typename TCoordRep = float, unsigned int VSpaceDimension = 2, unsigned int VSplineOrder = 3>
48 class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction
49  : public FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>,
50  FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(BSplineInterpolationWeightFunction);
54 
58  FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>;
59 
62 
64  itkNewMacro(Self);
65 
68 
70  static constexpr unsigned int SpaceDimension = VSpaceDimension;
71 
73  static constexpr unsigned int SplineOrder = VSplineOrder;
74 
77 
79  static constexpr unsigned int NumberOfWeights{ WeightsType::Length };
80 
84 
87 
89  static constexpr SizeType SupportSize{ SizeType::Filled(VSplineOrder + 1) };
90  // Declaration here, definition must be outside of class until C++17, see .hxx file for linker definition
91 
94  WeightsType
95  Evaluate(const ContinuousIndexType & index) const override;
96 
105  virtual void
106  Evaluate(const ContinuousIndexType & index, WeightsType & weights, IndexType & startIndex) const;
107 
108 #if !defined(ITK_LEGACY_REMOVE)
109 
110  itkLegacyMacro(SizeType GetSupportSize() const) { return Self::SupportSize; };
111 
113  itkLegacyMacro(unsigned int GetNumberOfWeights() const) { return Self::NumberOfWeights; }
114 #endif
115 
116 protected:
117  BSplineInterpolationWeightFunction() = default;
118  ~BSplineInterpolationWeightFunction() override = default;
119 
120 private:
123 
125  const TableType m_OffsetToIndexTable{ [] {
126  TableType table;
127  // Note: Copied the constexpr value `SupportSize` to a local variable, to prevent a GCC
128  // (Ubuntu 7.5.0-3ubuntu1~18.04) link error, "undefined reference to `SupportSize`", and Clang
129  // (Mac10.13-AppleClang-dbg-x86_64-static) "Undefined symbols for architecture x86_64".
130  const auto supportSize = SupportSize;
131  std::copy_n(ZeroBasedIndexRange<SpaceDimension>(supportSize).cbegin(), NumberOfWeights, table.begin());
132  return table;
133  }() };
134 };
135 } // end namespace itk
138 #ifndef ITK_MANUAL_INSTANTIATION
139 # include "itkBSplineInterpolationWeightFunction.hxx"
140 #endif
141 
142 #endif
itk::BSplineInterpolationWeightFunction
Returns the weights over the support region used for B-spline interpolation/reconstruction.
Definition: itkBSplineInterpolationWeightFunction.h:48
itkIndexRange.h
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:70
itkContinuousIndex.h
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:71
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itkFunctionBase.h
itk::BSplineInterpolationWeightFunction::WeightsType
typename Superclass::OutputType WeightsType
Definition: itkBSplineInterpolationWeightFunction.h:76
itk::Math::UnsignedPower
constexpr TReturnType UnsignedPower(const uintmax_t base, const uintmax_t exponent) noexcept
Definition: itkMath.h:802
itk::FixedArray
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:53
itkArray.h
itk::FunctionBase
Base class for all ITK function objects.
Definition: itkFunctionBase.h:44
itkArray2D.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ContinuousIndex
A templated class holding a point in n-Dimensional image space.
Definition: itkContinuousIndex.h:46
itk::FixedArray::begin
constexpr iterator begin() noexcept
Definition: itkFixedArray.h:336
itk::IndexRange
Definition: itkIndexRange.h:78
itkMath.h