Skip to content

Commit

Permalink
ENH: Deprecate unused constructor call
Browse files Browse the repository at this point in the history
These constructor signatures are not used, and are
not necessary to implement the behavior.

The derived unused constructors in derived classes (11) are
also be deprecated, when MatrixOffsetTransformBase(const MatrixType &,
const OutputVectorType &) is deprecated:

AffineTransform(const MatrixType & matrix, const OutputVectorType & offset);
ComposeScaleSkewVersor3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
FixedCenterOfRotationAffineTransform(const MatrixType & matrix, const OutputVectorType & offset);
QuaternionRigidTransform(const MatrixType & matrix, const OutputVectorType & offset);
Rigid3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
ScalableAffineTransform(const MatrixType & matrix, const OutputVectorType & offset);
ScaleSkewVersor3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
ScaleVersor3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
Similarity3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
VersorRigid3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
VersorTransform(const MatrixType & matrix, const OutputVectorType & offset);

These 11 constructors all directly or indirectly call
MatrixOffsetTransformBase(const MatrixType &, const OutputVectorType &).
But none of them are tested, it appears that they aren't even
compiled!!! At least not at the CI. And they are all protected, so they
can not be used in the public API.

Disabled GTest that used now deprecated interface.
  • Loading branch information
hjmjohnson committed Jun 18, 2024
1 parent a81ea1e commit 328606b
Show file tree
Hide file tree
Showing 25 changed files with 72 additions and 41 deletions.
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkAffineTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ class ITK_TEMPLATE_EXPORT AffineTransform
* to values specified by the caller. If the arguments are
* omitted, then the AffineTransform is initialized to an identity
* transformation in the appropriate number of dimensions. */
AffineTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] AffineTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
AffineTransform(unsigned int parametersDimension);
AffineTransform();

Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Transform/include/itkAffineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ AffineTransform<TParametersValueType, VDimension>::AffineTransform(unsigned int
: Superclass(parametersDimension)
{}

#if !defined(ITK_LEGACY_REMOVE)
template <typename TParametersValueType, unsigned int VDimension>
AffineTransform<TParametersValueType, VDimension>::AffineTransform(const MatrixType & matrix,
const OutputVectorType & offset)
: Superclass(matrix, offset)
{}
#endif

template <typename TParametersValueType, unsigned int VDimension>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ class ITK_TEMPLATE_EXPORT ComposeScaleSkewVersor3DTransform : public VersorRigid

protected:
ComposeScaleSkewVersor3DTransform();
ComposeScaleSkewVersor3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] ComposeScaleSkewVersor3DTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
ComposeScaleSkewVersor3DTransform(unsigned int parametersDimension);
~ComposeScaleSkewVersor3DTransform() override = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ComposeScaleSkewVersor3DTransform<TParametersValueType>::ComposeScaleSkewVersor3
m_Skew.Fill(0.0);
}

#if !defined(ITK_LEGACY_REMOVE)
// Constructor with arguments
template <typename TParametersValueType>
ComposeScaleSkewVersor3DTransform<TParametersValueType>::ComposeScaleSkewVersor3DTransform(
Expand All @@ -52,6 +53,7 @@ ComposeScaleSkewVersor3DTransform<TParametersValueType>::ComposeScaleSkewVersor3
{
this->ComputeMatrixParameters();
}
#endif

// Directly set the matrix
template <typename TParametersValueType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ class ITK_TEMPLATE_EXPORT FixedCenterOfRotationAffineTransform

protected:
/** Construct an FixedCenterOfRotationAffineTransform object */
FixedCenterOfRotationAffineTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] FixedCenterOfRotationAffineTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
FixedCenterOfRotationAffineTransform(unsigned int outputSpaceDims, unsigned int paramsDims);
FixedCenterOfRotationAffineTransform();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ FixedCenterOfRotationAffineTransform<TParametersValueType, VDimension>::FixedCen
: Superclass(outputSpaceDims, paramsDims)
{}

#if !defined(ITK_LEGACY_REMOVE)
template <typename TParametersValueType, unsigned int VDimension>
FixedCenterOfRotationAffineTransform<TParametersValueType, VDimension>::FixedCenterOfRotationAffineTransform(
const MatrixType & matrix,
const OutputVectorType & offset)
: Superclass(matrix, offset)
{}
#endif

} // namespace itk

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,10 @@ class ITK_TEMPLATE_EXPORT MatrixOffsetTransformBase
* to values specified by the caller. If the arguments are
* omitted, then the MatrixOffsetTransformBase is initialized to an identity
* transformation in the appropriate number of dimensions. */
MatrixOffsetTransformBase(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] MatrixOffsetTransformBase(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
explicit MatrixOffsetTransformBase(unsigned int paramDims = ParametersDimension);

/** Destroy an MatrixOffsetTransformBase object */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ MatrixOffsetTransformBase<TParametersValueType, VInputDimension, VOutputDimensio
this->m_FixedParameters.Fill(0.0);
}


#if !defined(ITK_LEGACY_REMOVE)
template <typename TParametersValueType, unsigned int VInputDimension, unsigned int VOutputDimension>
MatrixOffsetTransformBase<TParametersValueType, VInputDimension, VOutputDimension>::MatrixOffsetTransformBase(
const MatrixType & matrix,
Expand All @@ -51,6 +51,7 @@ MatrixOffsetTransformBase<TParametersValueType, VInputDimension, VOutputDimensio
this->m_FixedParameters.SetSize(VInputDimension);
this->m_FixedParameters.Fill(0.0);
}
#endif

template <typename TParametersValueType, unsigned int VInputDimension, unsigned int VOutputDimension>
void
Expand Down
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkQuaternionRigidTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ class ITK_TEMPLATE_EXPORT QuaternionRigidTransform : public Rigid3DTransform<TPa
ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & jacobian) const override;

protected:
QuaternionRigidTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] QuaternionRigidTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
QuaternionRigidTransform(unsigned int parametersDimension);
QuaternionRigidTransform();
~QuaternionRigidTransform() override = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ QuaternionRigidTransform<TParametersValueType>::QuaternionRigidTransform(unsigne
// std::cos(t/2)
}

#if !defined(ITK_LEGACY_REMOVE)
// Constructor with explicit arguments
template <typename TParametersValueType>
QuaternionRigidTransform<TParametersValueType>::QuaternionRigidTransform(const MatrixType & matrix,
Expand All @@ -47,6 +48,7 @@ QuaternionRigidTransform<TParametersValueType>::QuaternionRigidTransform(const M
{
this->ComputeMatrixParameters();
}
#endif

// Print self
template <typename TParametersValueType>
Expand Down
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkRigid3DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ class ITK_TEMPLATE_EXPORT Rigid3DTransform : public MatrixOffsetTransformBase<TP


protected:
Rigid3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] Rigid3DTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
Rigid3DTransform(unsigned int paramDim);
Rigid3DTransform();
~Rigid3DTransform() override = default;
Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Transform/include/itkRigid3DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ Rigid3DTransform<TParametersValueType>::Rigid3DTransform(unsigned int paramDim)
: Superclass(paramDim)
{}

#if !defined(ITK_LEGACY_REMOVE)
// Constructor with default arguments
template <typename TParametersValueType>
Rigid3DTransform<TParametersValueType>::Rigid3DTransform(const MatrixType & matrix, const OutputVectorType & offset)
: Superclass(matrix, offset)
{}
#endif

// Print self
template <typename TParametersValueType>
Expand Down
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkScalableAffineTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ class ITK_TEMPLATE_EXPORT ScalableAffineTransform : public AffineTransform<TPara
* to values specified by the caller. If the arguments are
* omitted, then the AffineTransform is initialized to an identity
* transformation in the appropriate number of dimensions. */
ScalableAffineTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] ScalableAffineTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
ScalableAffineTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
ScalableAffineTransform(unsigned int parametersDimension);
ScalableAffineTransform();
Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Transform/include/itkScalableAffineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ScalableAffineTransform<TParametersValueType, VDimension>::ScalableAffineTransfo
}
}

#if !defined(ITK_LEGACY_REMOVE)
template <typename TParametersValueType, unsigned int VDimension>
ScalableAffineTransform<TParametersValueType, VDimension>::ScalableAffineTransform(const MatrixType & matrix,
const OutputVectorType & offset)
Expand All @@ -70,6 +71,7 @@ ScalableAffineTransform<TParametersValueType, VDimension>::ScalableAffineTransfo
m_MatrixScale[i] = 1;
}
}
#endif

template <typename TParametersValueType, unsigned int VDimension>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ class ITK_TEMPLATE_EXPORT ScaleSkewVersor3DTransform : public VersorRigid3DTrans

protected:
ScaleSkewVersor3DTransform();
ScaleSkewVersor3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] ScaleSkewVersor3DTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
ScaleSkewVersor3DTransform(unsigned int parametersDimension);
~ScaleSkewVersor3DTransform() override = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ScaleSkewVersor3DTransform<TParametersValueType>::ScaleSkewVersor3DTransform(uns
m_Skew.Fill(0.0);
}

#if !defined(ITK_LEGACY_REMOVE)
// Constructor with arguments
template <typename TParametersValueType>
ScaleSkewVersor3DTransform<TParametersValueType>::ScaleSkewVersor3DTransform(const MatrixType & matrix,
Expand All @@ -48,6 +49,7 @@ ScaleSkewVersor3DTransform<TParametersValueType>::ScaleSkewVersor3DTransform(con
{
this->ComputeMatrixParameters();
}
#endif

// Directly set the matrix
template <typename TParametersValueType>
Expand Down
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkScaleVersor3DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ class ITK_TEMPLATE_EXPORT ScaleVersor3DTransform : public VersorRigid3DTransform

protected:
ScaleVersor3DTransform();
ScaleVersor3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] ScaleVersor3DTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
ScaleVersor3DTransform(unsigned int parametersDimension);
~ScaleVersor3DTransform() override = default;

Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Transform/include/itkScaleVersor3DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ScaleVersor3DTransform<TParametersValueType>::ScaleVersor3DTransform(unsigned in
m_Scale.Fill(1.0);
}

#if !defined(ITK_LEGACY_REMOVE)
// Constructor with arguments
template <typename TParametersValueType>
ScaleVersor3DTransform<TParametersValueType>::ScaleVersor3DTransform(const MatrixType & matrix,
Expand All @@ -45,6 +46,7 @@ ScaleVersor3DTransform<TParametersValueType>::ScaleVersor3DTransform(const Matri
{
this->ComputeMatrixParameters();
}
#endif

// Directly set the matrix
template <typename TParametersValueType>
Expand Down
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkSimilarity3DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ class ITK_TEMPLATE_EXPORT Similarity3DTransform : public VersorRigid3DTransform<
ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & jacobian) const override;

protected:
Similarity3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] Similarity3DTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
Similarity3DTransform(unsigned int paramDim);
Similarity3DTransform();
~Similarity3DTransform() override = default;
Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Transform/include/itkSimilarity3DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ Similarity3DTransform<TParametersValueType>::Similarity3DTransform(unsigned int
, m_Scale(1.0)
{}

#if !defined(ITK_LEGACY_REMOVE)
// Constructor with arguments
template <typename TParametersValueType>
Similarity3DTransform<TParametersValueType>::Similarity3DTransform(const MatrixType & matrix,
const OutputVectorType & offset)
: Superclass(matrix, offset)
, m_Scale(1.0)
{}
#endif

// / Set the parameters to the IdentityTransform
template <typename TParametersValueType>
Expand Down
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkVersorRigid3DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ class ITK_TEMPLATE_EXPORT VersorRigid3DTransform : public VersorTransform<TParam
ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & jacobian) const override;

protected:
VersorRigid3DTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] VersorRigid3DTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
VersorRigid3DTransform(unsigned int paramDim);
VersorRigid3DTransform();
~VersorRigid3DTransform() override = default;
Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Transform/include/itkVersorRigid3DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform(unsigned in
: Superclass(paramDim)
{}

#if !defined(ITK_LEGACY_REMOVE)
// Constructor with arguments
template <typename TParametersValueType>
VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform(const MatrixType & matrix,
const OutputVectorType & offset)
: Superclass(matrix, offset)
{}
#endif

// Set Parameters
template <typename TParametersValueType>
Expand Down
5 changes: 4 additions & 1 deletion Modules/Core/Transform/include/itkVersorTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ class ITK_TEMPLATE_EXPORT VersorTransform : public Rigid3DTransform<TParametersV

protected:
/** Construct an VersorTransform object */
VersorTransform(const MatrixType & matrix, const OutputVectorType & offset);
#if !defined(ITK_LEGACY_REMOVE)
[[deprecated("Removed unused constructor")]] VersorTransform(const MatrixType & matrix,
const OutputVectorType & offset);
#endif
VersorTransform(unsigned int parametersDimension);
VersorTransform();

Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Transform/include/itkVersorTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ VersorTransform<TParametersValueType>::VersorTransform(unsigned int parametersDi
m_Versor.SetIdentity();
}

#if !defined(ITK_LEGACY_REMOVE)
template <typename TParametersValueType>
VersorTransform<TParametersValueType>::VersorTransform(const MatrixType & matrix, const OutputVectorType & offset)
: Superclass(matrix, offset)
{
this->ComputeMatrixParameters(); // called in MatrixOffset baseclass
}
#endif

template <typename TParametersValueType>
void
Expand Down
28 changes: 0 additions & 28 deletions Modules/Core/Transform/test/itkMatrixOffsetTransformBaseGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,3 @@ TEST(MatrixOffsetTransformBase, SetFixedParametersThrowsWhenSizeIsLessThanNDimen
Assert_SetFixedParameters_throws_when_size_is_less_than_NDimensions<3>();
Assert_SetFixedParameters_throws_when_size_is_less_than_NDimensions<4>();
}

// Check that fixed parameters are set to default values during construction.
TEST(MatrixOffsetTransformBase, CreateWithMatrixAndOffset)
{
class DerivedTransform : public itk::MatrixOffsetTransformBase<>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(DerivedTransform);

static auto
Create()
{
// Indirectly call the `MatrixOffsetTransformBase(const MatrixType &, const OutputVectorType &)` constructor.
const itk::SmartPointer<DerivedTransform> ptr = new DerivedTransform(MatrixType(), OutputVectorType());
ptr->UnRegister();
return ptr;
}

private:
// Inherit the constructors of MatrixOffsetTransformBase:
using itk::MatrixOffsetTransformBase<>::MatrixOffsetTransformBase;
};

const auto transform = DerivedTransform::Create();
const DerivedTransform::FixedParametersType expectedFixedParameters(DerivedTransform::InputSpaceDimension, 0);

EXPECT_EQ(transform->GetFixedParameters(), expectedFixedParameters);
}

0 comments on commit 328606b

Please sign in to comment.