diff --git a/.github/workflows/ElastixGitHubActions.yml b/.github/workflows/ElastixGitHubActions.yml index 0d3436b70..730d9de06 100644 --- a/.github/workflows/ElastixGitHubActions.yml +++ b/.github/workflows/ElastixGitHubActions.yml @@ -18,21 +18,21 @@ jobs: - os: ubuntu-18.04 c-compiler: "gcc" cxx-compiler: "g++" - itk-git-tag: "v5.2.0" + itk-git-tag: "v5.3rc02" cmake-build-type: "Release" ANNLib: "libANNlib-5.0.so" ANNLib2: "libANNlib-5.0.so.1" - os: windows-2019 c-compiler: "cl.exe" cxx-compiler: "cl.exe" - itk-git-tag: "v5.2.0" + itk-git-tag: "v5.3rc02" cmake-build-type: "Release" ANNLib: "ANNlib-5.0.dll" vcvars64: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" - os: macos-10.15 c-compiler: "clang" cxx-compiler: "clang++" - itk-git-tag: "v5.2.0" + itk-git-tag: "v5.3rc02" cmake-build-type: "Release" ANNLib: "libANNlib-5.0.1.dylib" ANNLib2: "libANNlib-5.0.dylib" diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ffc80c6a..aa769705a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ if(ELASTIX_USE_OPENCL) endif() # Find ITK. -find_package( ITK 5.2.0 REQUIRED COMPONENTS +find_package( ITK 5.3 REQUIRED COMPONENTS ITKCommon ITKDisplacementField ITKDistanceMap diff --git a/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx b/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx index 9dc6ae407..98c542e55 100644 --- a/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx +++ b/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx @@ -41,6 +41,7 @@ #include "itkImageScanlineConstIterator.h" #include "itkIdentityTransform.h" #include +#include #include #include // For std::copy_n. @@ -291,9 +292,8 @@ AdvancedBSplineDeformableTransform::Tran { /** Allocate memory on the stack: */ const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; typename ParameterIndexArrayType::ValueType indicesArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; ParameterIndexArrayType indices(indicesArray, numberOfWeights, false); OutputPointType outputPoint; @@ -379,9 +379,8 @@ AdvancedBSplineDeformableTransform::GetJ /** Compute the number of affected B-spline parameters. * Allocate memory on the stack. */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; /** Compute the weights. */ IndexType supportIndex; @@ -446,9 +445,7 @@ AdvancedBSplineDeformableTransform::Eval /** Compute the number of affected B-spline parameters. * Allocate memory on the stack. */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; /** Compute the B-spline derivative weights. */ IndexType supportIndex; @@ -504,20 +501,20 @@ AdvancedBSplineDeformableTransform::GetS /** Compute the number of affected B-spline parameters. */ /** Allocate memory on the stack: */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; + + typedef typename WeightsType::ValueType WeightsValueType; /** Array for CoefficientImage values */ - typename WeightsType::ValueType coeffArray[numberOfWeights * SpaceDimension]; - WeightsType coeffs(coeffArray, numberOfWeights * SpaceDimension, false); + std::array coeffs; IndexType supportIndex; this->m_DerivativeWeightsFunctions[0]->ComputeStartIndex(cindex, supportIndex); const RegionType supportRegion(supportIndex, Superclass::m_SupportSize); /** Copy values from coefficient image to linear coeffs array. */ - typename WeightsType::iterator itCoeffsLinear = coeffs.begin(); + auto itCoeffsLinear = coeffs.begin(); for (unsigned int dim = 0; dim < SpaceDimension; ++dim) { ImageScanlineConstIterator itCoef(this->m_CoefficientImages[dim], supportRegion); @@ -544,7 +541,7 @@ AdvancedBSplineDeformableTransform::GetS this->m_DerivativeWeightsFunctions[i]->Evaluate(cindex, supportIndex, weights); /** Create an iterator over the coeffs vector. */ - typename WeightsType::const_iterator itCoeffs = coeffs.begin(); + auto itCoeffs = coeffs.cbegin(); /** Compute the spatial Jacobian sj: * dT_{dim} / dx_i = \sum coefs_{dim} * weights. @@ -610,19 +607,17 @@ AdvancedBSplineDeformableTransform::GetS /** Helper variables. */ /** Allocate memory on the stack: */ const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - WeightsValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; /** Array for CoefficientImage values */ - WeightsValueType coeffArray[numberOfWeights * SpaceDimension]; - WeightsType coeffs(coeffArray, numberOfWeights * SpaceDimension, false); + std::array coeffs; IndexType supportIndex; this->m_SODerivativeWeightsFunctions[0][0]->ComputeStartIndex(cindex, supportIndex); const RegionType supportRegion(supportIndex, Superclass::m_SupportSize); /** Copy values from coefficient image to linear coeffs array. */ - typename WeightsType::iterator itCoeffsLinear = coeffs.begin(); + auto itCoeffsLinear = coeffs.begin(); for (unsigned int dim = 0; dim < SpaceDimension; ++dim) { ImageScanlineConstIterator itCoef(this->m_CoefficientImages[dim], supportRegion); @@ -653,7 +648,7 @@ AdvancedBSplineDeformableTransform::GetS this->m_SODerivativeWeightsFunctions[i][j]->Evaluate(cindex, supportIndex, weights); /** Create an iterator over the coeffs vector. */ - typename WeightsType::const_iterator itCoeffs = coeffs.begin(); + auto itCoeffs = coeffs.cbegin(); /** Compute d^2T_{dim} / dx_i dx_j = \sum coefs_{dim} * weights. */ for (unsigned int dim = 0; dim < SpaceDimension; ++dim) @@ -735,9 +730,8 @@ AdvancedBSplineDeformableTransform::GetJ /** Helper variables. */ /** Allocate memory on the stack: */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; IndexType supportIndex; this->m_DerivativeWeightsFunctions[0]->ComputeStartIndex(cindex, supportIndex); @@ -840,16 +834,14 @@ AdvancedBSplineDeformableTransform::GetJ /** Allocate weight on the stack. */ typedef typename WeightsType::ValueType WeightsValueType; const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - WeightsValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; /** Allocate coefficients on the stack. */ - WeightsValueType coeffArray[numberOfWeights * SpaceDimension]; - WeightsType coeffs(coeffArray, numberOfWeights * SpaceDimension, false); + std::array coeffs; /** Copy values from coefficient image to linear coeffs array. */ // takes considerable amount of time : 27% of this function. // with old region iterator, check with new - typename WeightsType::iterator itCoeffsLinear = coeffs.begin(); + auto itCoeffsLinear = coeffs.begin(); for (unsigned int dim = 0; dim < SpaceDimension; ++dim) { ImageScanlineConstIterator itCoef(this->m_CoefficientImages[dim], supportRegion); @@ -887,7 +879,7 @@ AdvancedBSplineDeformableTransform::GetJ std::copy_n(weights.begin(), numberOfWeights, weightVector + i * numberOfWeights); /** Reset coeffs iterator */ - typename WeightsType::const_iterator itCoeffs = coeffs.begin(); + auto itCoeffs = coeffs.cbegin(); /** Compute the spatial Jacobian sj: * dT_{dim} / dx_i = delta_{dim,i} + \sum coefs_{dim} * weights. @@ -993,9 +985,8 @@ AdvancedBSplineDeformableTransform::GetJ /** Compute the number of affected B-spline parameters. */ /** Allocate memory on the stack: */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; IndexType supportIndex; this->m_SODerivativeWeightsFunctions[0][0]->ComputeStartIndex(cindex, supportIndex); @@ -1119,16 +1110,14 @@ AdvancedBSplineDeformableTransform::GetJ /** Allocate weight on the stack. */ typedef typename WeightsType::ValueType WeightsValueType; const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - WeightsValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; /** Allocate coefficients on the stack. */ - WeightsValueType coeffArray[numberOfWeights * SpaceDimension]; - WeightsType coeffs(coeffArray, numberOfWeights * SpaceDimension, false); + std::array coeffs; /** Copy values from coefficient image to linear coeffs array. */ // takes considerable amount of time : 27% of this function. // with old region iterator, check with new - typename WeightsType::iterator itCoeffsLinear = coeffs.begin(); + auto itCoeffsLinear = coeffs.begin(); for (unsigned int dim = 0; dim < SpaceDimension; ++dim) { ImageScanlineConstIterator itCoef(this->m_CoefficientImages[dim], supportRegion); @@ -1168,7 +1157,7 @@ AdvancedBSplineDeformableTransform::GetJ count++; /** Reset coeffs iterator */ - typename WeightsType::const_iterator itCoeffs = coeffs.begin(); + auto itCoeffs = coeffs.cbegin(); /** Compute the spatial Hessian sh: * d^2T_{dim} / dx_i dx_j = \sum coefs_{dim} * weights. diff --git a/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h b/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h index 985b4e874..f0f419cbb 100644 --- a/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h +++ b/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h @@ -48,14 +48,17 @@ namespace itk */ template class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunctionBase - : public FunctionBase, Array> + : public FunctionBase, + FixedArray> { public: /** Standard class typedefs. */ - typedef BSplineInterpolationWeightFunctionBase Self; - typedef FunctionBase, Array> Superclass; - typedef SmartPointer Pointer; - typedef SmartPointer ConstPointer; + typedef BSplineInterpolationWeightFunctionBase Self; + typedef FunctionBase, + FixedArray> + Superclass; + typedef SmartPointer Pointer; + typedef SmartPointer ConstPointer; /** Run-time type information (and related methods). */ itkTypeMacro(BSplineInterpolationWeightFunctionBase, FunctionBase); @@ -70,7 +73,7 @@ class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunctionBase static constexpr unsigned long NumberOfWeights = Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension); /** OutputType typedef support. */ - typedef Array WeightsType; + typedef FixedArray WeightsType; /** Index and size typedef support. */ typedef Index IndexType; diff --git a/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx b/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx index 4cb76cfbc..18a16366e 100644 --- a/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx +++ b/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx @@ -317,9 +317,7 @@ CyclicBSplineDeformableTransform::GetSpa /** Compute the number of affected B-spline parameters. */ /** Allocate memory on the stack: */ - const SizeValueType numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; IndexType supportIndex; this->m_DerivativeWeightsFunctions[0]->ComputeStartIndex(cindex, supportIndex); diff --git a/Common/Transforms/itkRecursiveBSplineTransform.hxx b/Common/Transforms/itkRecursiveBSplineTransform.hxx index dd4457035..40a35b906 100644 --- a/Common/Transforms/itkRecursiveBSplineTransform.hxx +++ b/Common/Transforms/itkRecursiveBSplineTransform.hxx @@ -50,15 +50,11 @@ auto RecursiveBSplineTransform::TransformPoint(const InputPointType & point) const -> OutputPointType { - /** Define some constants. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - /** Initialize output point. */ OutputPointType outputPoint; /** Allocate weights on the stack: */ - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); + WeightsType weights1D; /** Check if the coefficient image has been set. */ if (!this->m_CoefficientImages[0]) @@ -156,10 +152,8 @@ RecursiveBSplineTransform::GetJacobian( * In contrast to the normal B-spline weights function, the recursive version * returns the individual weights instead of the multiplied ones. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - IndexType supportIndex; + WeightsType weights1D; + IndexType supportIndex; this->m_RecursiveBSplineWeightFunction->Evaluate(cindex, weights1D, supportIndex); /** Recursively compute the first numberOfIndices entries of the Jacobian. @@ -215,10 +209,8 @@ RecursiveBSplineTransform::EvaluateJacobianW * In contrast to the normal B-spline weights function, the recursive version * returns the individual weights instead of the multiplied ones. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - IndexType supportIndex; + WeightsType weights1D; + IndexType supportIndex; this->m_RecursiveBSplineWeightFunction->Evaluate(cindex, weights1D, supportIndex); /** Recursively compute the inner product of the Jacobian and the moving image gradient. @@ -269,11 +261,8 @@ RecursiveBSplineTransform::GetSpatialJacobia } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); @@ -357,13 +346,9 @@ RecursiveBSplineTransform::GetSpatialHessian } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType hessianWeightsArray1D[numberOfWeights]; - WeightsType hessianWeights1D(hessianWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; + WeightsType hessianWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); @@ -477,11 +462,8 @@ RecursiveBSplineTransform::GetJacobianOfSpat } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); @@ -577,13 +559,9 @@ RecursiveBSplineTransform::GetJacobianOfSpat } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType hessianWeightsArray1D[numberOfWeights]; - WeightsType hessianWeights1D(hessianWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; + WeightsType hessianWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index 61b0d8631..576b14e2d 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -1,5 +1,5 @@ variables: - ITKv5_VERSION: v5.2.0 + ITKv5_VERSION: v5.3rc02 ITK_GIT_URL: https://github.com/InsightSoftwareConsortium/ITK ITK_SOURCE_DIR: $(Agent.BuildDirectory)/ITK-source ITK_BINARY_DIR: $(Agent.BuildDirectory)/ITK-build diff --git a/Testing/itkBSplineTransformPointPerformanceTest.cxx b/Testing/itkBSplineTransformPointPerformanceTest.cxx index f7f9740cf..aff4617bb 100644 --- a/Testing/itkBSplineTransformPointPerformanceTest.cxx +++ b/Testing/itkBSplineTransformPointPerformanceTest.cxx @@ -61,9 +61,8 @@ class BSplineTransform_TEST : public AdvancedBSplineDeformableTransform