diff --git a/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.h b/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.h index 817cd7bb0c2..c997f1e038e 100644 --- a/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.h +++ b/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.h @@ -22,6 +22,7 @@ #include "itkContinuousIndex.h" #include "itkArray.h" #include "itkArray2D.h" +#include "itkIndexRange.h" #include "itkMath.h" namespace itk @@ -112,15 +113,21 @@ class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction #endif protected: - BSplineInterpolationWeightFunction(); + BSplineInterpolationWeightFunction() = default; ~BSplineInterpolationWeightFunction() override = default; private: /** Lookup table type. */ - using TableType = Array2D; + using TableType = FixedArray; /** Table mapping linear offset to indices. */ - TableType m_OffsetToIndexTable; + const TableType m_OffsetToIndexTable{ [] { + TableType table; + // Note: Copied the constexpr value `SupportSize` to a temporary, `SizeType{ SupportSize }`, to prevent a GCC + // (Ubuntu 7.5.0-3ubuntu1~18.04) link error, "undefined reference to `SupportSize`". + std::copy_n(ZeroBasedIndexRange(SizeType{ SupportSize }).cbegin(), NumberOfWeights, table.begin()); + return table; + }() }; }; } // end namespace itk diff --git a/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.hxx b/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.hxx index efdb90703f1..d994599726c 100644 --- a/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.hxx +++ b/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.hxx @@ -23,30 +23,9 @@ #include "itkImage.h" #include "itkMatrix.h" #include "itkMath.h" -#include "itkIndexRange.h" namespace itk { -/** Constructor */ -template -BSplineInterpolationWeightFunction::BSplineInterpolationWeightFunction() -{ - // Initialize offset to index lookup table - m_OffsetToIndexTable.set_size(Self::NumberOfWeights, SpaceDimension); - - constexpr auto supportSize = Self::SupportSize; - unsigned int counter = 0; - - for (const IndexType index : ZeroBasedIndexRange(supportSize)) - { - for (unsigned int j = 0; j < SpaceDimension; ++j) - { - m_OffsetToIndexTable[counter][j] = index[j]; - } - ++counter; - } -} - /** Compute weights for interpolation at continuous index position */ template typename BSplineInterpolationWeightFunction::WeightsType