Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ namespace itk
*/
template <typename TCoordRep = float, unsigned int VSpaceDimension = 2, unsigned int VSplineOrder = 3>
class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction
: public FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>, Array<double>>
: public FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>,
FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(BSplineInterpolationWeightFunction);

/** Standard class type aliases. */
using Self = BSplineInterpolationWeightFunction;
using Superclass = FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>, Array<double>>;
using Superclass = FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>,
FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>;

using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
Expand All @@ -70,11 +72,11 @@ class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction
/** Spline order. */
static constexpr unsigned int SplineOrder = VSplineOrder;

/** Number of weights. */
static constexpr unsigned int NumberOfWeights{ Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension) };

/** OutputType type alias support. */
using WeightsType = Array<double>;
using WeightsType = typename Superclass::OutputType;

/** Number of weights. */
static constexpr unsigned int NumberOfWeights{ WeightsType::Length };

/** Index and size type alias support. */
using IndexType = Index<VSpaceDimension>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typename BSplineInterpolationWeightFunction<TCoordRep, VSpaceDimension, VSplineO
BSplineInterpolationWeightFunction<TCoordRep, VSpaceDimension, VSplineOrder>::Evaluate(
const ContinuousIndexType & index) const
{
WeightsType weights(Self::NumberOfWeights);
WeightsType weights;
IndexType startIndex;

this->Evaluate(index, weights, startIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ itkBSplineInterpolationWeightFunctionTest(int, char *[])
WeightsType weights1;
WeightsType weights2;

weights1.SetSize(SplineOrder + 1);
weights2.SetSize(SplineOrder + 1);

ContinuousIndexType position1;
ContinuousIndexType position2;

Expand Down Expand Up @@ -151,9 +148,6 @@ itkBSplineInterpolationWeightFunctionTest(int, char *[])
WeightsType weights1;
WeightsType weights2;

weights1.SetSize(SplineOrder + 1);
weights2.SetSize(SplineOrder + 1);

ContinuousIndexType position1;
ContinuousIndexType position2;

Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/wrapping/itkFunctionBase.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ itk_wrap_class("itk::FunctionBase" POINTER)
itk_wrap_template("${ITKM_PD${d}}RGBD" "${ITKT_PD${d}},itk::RGBPixel< double >")
itk_wrap_template("${ITKM_PD${d}}RGBAD" "${ITKT_PD${d}},itk::RGBAPixel< double >")

# Required by BSplineInterpolationWeightFunction
itk_wrap_template("${ITKM_CID2}${ITKM_FAD9}" "${ITKT_CID2}, ${ITKT_FAD9}")
itk_wrap_template("${ITKM_CID3}${ITKM_FAD64}" "${ITKT_CID3}, ${ITKT_FAD64}")

endforeach()

foreach(r ${WRAP_ITK_REAL})
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Transform/include/itkBSplineBaseTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ typename BSplineBaseTransform<TParametersValueType, NDimensions, VSplineOrder>::
BSplineBaseTransform<TParametersValueType, NDimensions, VSplineOrder>::TransformPoint(
const InputPointType & point) const
{
WeightsType weights(WeightsFunctionType::NumberOfWeights);
WeightsType weights;
ParameterIndexArrayType indices(WeightsFunctionType::NumberOfWeights);
OutputPointType outputPoint;
bool inside;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ BSplineDeformableTransform<TParametersValueType, NDimensions, VSplineOrder>::Com
}

// Compute interpolation weights
WeightsType weights(WeightsFunctionType::NumberOfWeights);
WeightsType weights;

IndexType supportIndex;
this->m_WeightsFunction->Evaluate(index, weights, supportIndex);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Transform/include/itkBSplineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ BSplineTransform<TParametersValueType, NDimensions, VSplineOrder>::ComputeJacobi
}

// Compute interpolation weights
WeightsType weights(WeightsFunctionType::NumberOfWeights);
WeightsType weights;

IndexType supportIndex;
this->m_WeightsFunction->Evaluate(index, weights, supportIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ itkBSplineDeformableTransformTest1()
using WeightsType = TransformType::WeightsType;
using IndexArrayType = TransformType::ParameterIndexArrayType;

WeightsType weights(TransformType::NumberOfWeights);
WeightsType weights;
IndexArrayType indices(TransformType::NumberOfWeights);
bool inside;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Transform/test/itkBSplineTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ itkBSplineTransformTest1()
using WeightsType = TransformType::WeightsType;
using IndexArrayType = TransformType::ParameterIndexArrayType;

WeightsType weights(TransformType::NumberOfWeights);
WeightsType weights;
IndexArrayType indices(TransformType::NumberOfWeights);
bool inside;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ ImageToImageMetric<TFixedImage, TMovingImage>::MultiThreadingInitialize()
this->m_BSplineTransformIndicesArray.SetSize(1, 1);
this->m_BSplinePreTransformPointsArray.resize(1);
this->m_WithinBSplineSupportRegionArray.resize(1);
this->m_BSplineTransformWeights.SetSize(1);
this->m_BSplineTransformIndices.SetSize(1);

delete[] this->m_ThreaderBSplineTransformWeights;
Expand All @@ -457,15 +456,13 @@ ImageToImageMetric<TFixedImage, TMovingImage>::MultiThreadingInitialize()
}
else
{
this->m_BSplineTransformWeights.SetSize(this->m_NumBSplineWeights);
this->m_BSplineTransformIndices.SetSize(this->m_NumBSplineWeights);
Comment thread
dzenanz marked this conversation as resolved.
Outdated

this->m_ThreaderBSplineTransformWeights = new BSplineTransformWeightsType[m_NumberOfWorkUnits - 1];
this->m_ThreaderBSplineTransformIndices = new BSplineTransformIndexArrayType[m_NumberOfWorkUnits - 1];

for (ThreadIdType ithread = 0; ithread < m_NumberOfWorkUnits - 1; ++ithread)
{
this->m_ThreaderBSplineTransformWeights[ithread].SetSize(this->m_NumBSplineWeights);
this->m_ThreaderBSplineTransformIndices[ithread].SetSize(this->m_NumBSplineWeights);
}
}
Expand Down Expand Up @@ -797,7 +794,7 @@ ImageToImageMetric<TFixedImage, TMovingImage>::PreComputeTransformValues()
m_Transform->SetParameters(dummyParameters);

// Cycle through each sampled fixed image point
BSplineTransformWeightsType weights(m_NumBSplineWeights);
BSplineTransformWeightsType weights;
BSplineTransformIndexArrayType indices(m_NumBSplineWeights);
bool valid;
MovingImagePointType mappedPoint;
Expand Down
7 changes: 7 additions & 0 deletions Wrapping/WrapITKTypes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ WRAP_TYPE("itk::FixedArray" "FA" "itkFixedArray.h")
ADD_TEMPLATE("${ITKM_SC}${d}" "${ITKT_SC},${d}")
ADD_TEMPLATE("${ITKM_B}${d}" "${ITKT_B},${d}")
endforeach()

# Wrap FixedArray for BSplineInterpolationWeightFunction:
ADD_TEMPLATE("${ITKM_D}9" "${ITKT_D},9")
ADD_TEMPLATE("${ITKM_D}16" "${ITKT_D},16")
ADD_TEMPLATE("${ITKM_UL}16" "${ITKT_UL},16")
Comment thread
dzenanz marked this conversation as resolved.
ADD_TEMPLATE("${ITKM_D}64" "${ITKT_D},64")
ADD_TEMPLATE("${ITKM_UL}64" "${ITKT_UL},64")
END_WRAP_TYPE()
set(itk_Wrap_FixedArray ${WRAPPER_TEMPLATES})

Expand Down