From 328606b71b63048a98a29d4fa4875db5a8db8c96 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Thu, 13 Jun 2024 13:14:40 -0500 Subject: [PATCH] ENH: Deprecate unused constructor call 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. --- .../Transform/include/itkAffineTransform.h | 5 +++- .../Transform/include/itkAffineTransform.hxx | 2 ++ .../itkComposeScaleSkewVersor3DTransform.h | 5 +++- .../itkComposeScaleSkewVersor3DTransform.hxx | 2 ++ .../itkFixedCenterOfRotationAffineTransform.h | 5 +++- ...tkFixedCenterOfRotationAffineTransform.hxx | 2 ++ .../include/itkMatrixOffsetTransformBase.h | 5 +++- .../include/itkMatrixOffsetTransformBase.hxx | 3 +- .../include/itkQuaternionRigidTransform.h | 5 +++- .../include/itkQuaternionRigidTransform.hxx | 2 ++ .../Transform/include/itkRigid3DTransform.h | 5 +++- .../Transform/include/itkRigid3DTransform.hxx | 2 ++ .../include/itkScalableAffineTransform.h | 5 +++- .../include/itkScalableAffineTransform.hxx | 2 ++ .../include/itkScaleSkewVersor3DTransform.h | 5 +++- .../include/itkScaleSkewVersor3DTransform.hxx | 2 ++ .../include/itkScaleVersor3DTransform.h | 5 +++- .../include/itkScaleVersor3DTransform.hxx | 2 ++ .../include/itkSimilarity3DTransform.h | 5 +++- .../include/itkSimilarity3DTransform.hxx | 2 ++ .../include/itkVersorRigid3DTransform.h | 5 +++- .../include/itkVersorRigid3DTransform.hxx | 2 ++ .../Transform/include/itkVersorTransform.h | 5 +++- .../Transform/include/itkVersorTransform.hxx | 2 ++ .../itkMatrixOffsetTransformBaseGTest.cxx | 28 ------------------- 25 files changed, 72 insertions(+), 41 deletions(-) diff --git a/Modules/Core/Transform/include/itkAffineTransform.h b/Modules/Core/Transform/include/itkAffineTransform.h index 2427b2e451b..f89329daba2 100644 --- a/Modules/Core/Transform/include/itkAffineTransform.h +++ b/Modules/Core/Transform/include/itkAffineTransform.h @@ -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(); diff --git a/Modules/Core/Transform/include/itkAffineTransform.hxx b/Modules/Core/Transform/include/itkAffineTransform.hxx index 974107b8660..fa22c260a75 100644 --- a/Modules/Core/Transform/include/itkAffineTransform.hxx +++ b/Modules/Core/Transform/include/itkAffineTransform.hxx @@ -34,11 +34,13 @@ AffineTransform::AffineTransform(unsigned int : Superclass(parametersDimension) {} +#if !defined(ITK_LEGACY_REMOVE) template AffineTransform::AffineTransform(const MatrixType & matrix, const OutputVectorType & offset) : Superclass(matrix, offset) {} +#endif template void diff --git a/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.h b/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.h index 38e86937f5b..0486c869d3e 100644 --- a/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.h +++ b/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.h @@ -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; diff --git a/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx b/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx index 9395df1586e..ec8327859b0 100644 --- a/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx +++ b/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx @@ -43,6 +43,7 @@ ComposeScaleSkewVersor3DTransform::ComposeScaleSkewVersor3 m_Skew.Fill(0.0); } +#if !defined(ITK_LEGACY_REMOVE) // Constructor with arguments template ComposeScaleSkewVersor3DTransform::ComposeScaleSkewVersor3DTransform( @@ -52,6 +53,7 @@ ComposeScaleSkewVersor3DTransform::ComposeScaleSkewVersor3 { this->ComputeMatrixParameters(); } +#endif // Directly set the matrix template diff --git a/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.h b/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.h index a8317dcb93b..b85cd10fa61 100644 --- a/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.h +++ b/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.h @@ -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(); diff --git a/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.hxx b/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.hxx index a72a2bba903..381785f268a 100644 --- a/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.hxx +++ b/Modules/Core/Transform/include/itkFixedCenterOfRotationAffineTransform.hxx @@ -37,12 +37,14 @@ FixedCenterOfRotationAffineTransform::FixedCen : Superclass(outputSpaceDims, paramsDims) {} +#if !defined(ITK_LEGACY_REMOVE) template FixedCenterOfRotationAffineTransform::FixedCenterOfRotationAffineTransform( const MatrixType & matrix, const OutputVectorType & offset) : Superclass(matrix, offset) {} +#endif } // namespace itk diff --git a/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.h b/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.h index 700615e0b3c..9b76f9d8acb 100644 --- a/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.h +++ b/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.h @@ -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 */ diff --git a/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.hxx b/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.hxx index e4cc6c31f4d..1cb6b4266ea 100644 --- a/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.hxx +++ b/Modules/Core/Transform/include/itkMatrixOffsetTransformBase.hxx @@ -37,7 +37,7 @@ MatrixOffsetTransformBasem_FixedParameters.Fill(0.0); } - +#if !defined(ITK_LEGACY_REMOVE) template MatrixOffsetTransformBase::MatrixOffsetTransformBase( const MatrixType & matrix, @@ -51,6 +51,7 @@ MatrixOffsetTransformBasem_FixedParameters.SetSize(VInputDimension); this->m_FixedParameters.Fill(0.0); } +#endif template void diff --git a/Modules/Core/Transform/include/itkQuaternionRigidTransform.h b/Modules/Core/Transform/include/itkQuaternionRigidTransform.h index 965771a5a4e..1b2ff7731a3 100644 --- a/Modules/Core/Transform/include/itkQuaternionRigidTransform.h +++ b/Modules/Core/Transform/include/itkQuaternionRigidTransform.h @@ -135,7 +135,10 @@ class ITK_TEMPLATE_EXPORT QuaternionRigidTransform : public Rigid3DTransform::QuaternionRigidTransform(unsigne // std::cos(t/2) } +#if !defined(ITK_LEGACY_REMOVE) // Constructor with explicit arguments template QuaternionRigidTransform::QuaternionRigidTransform(const MatrixType & matrix, @@ -47,6 +48,7 @@ QuaternionRigidTransform::QuaternionRigidTransform(const M { this->ComputeMatrixParameters(); } +#endif // Print self template diff --git a/Modules/Core/Transform/include/itkRigid3DTransform.h b/Modules/Core/Transform/include/itkRigid3DTransform.h index b587c8f8639..66315e00dad 100644 --- a/Modules/Core/Transform/include/itkRigid3DTransform.h +++ b/Modules/Core/Transform/include/itkRigid3DTransform.h @@ -156,7 +156,10 @@ class ITK_TEMPLATE_EXPORT Rigid3DTransform : public MatrixOffsetTransformBase::Rigid3DTransform(unsigned int paramDim) : Superclass(paramDim) {} +#if !defined(ITK_LEGACY_REMOVE) // Constructor with default arguments template Rigid3DTransform::Rigid3DTransform(const MatrixType & matrix, const OutputVectorType & offset) : Superclass(matrix, offset) {} +#endif // Print self template diff --git a/Modules/Core/Transform/include/itkScalableAffineTransform.h b/Modules/Core/Transform/include/itkScalableAffineTransform.h index 8a613967703..62575106dd9 100644 --- a/Modules/Core/Transform/include/itkScalableAffineTransform.h +++ b/Modules/Core/Transform/include/itkScalableAffineTransform.h @@ -136,7 +136,10 @@ class ITK_TEMPLATE_EXPORT ScalableAffineTransform : public AffineTransform::ScalableAffineTransfo } } +#if !defined(ITK_LEGACY_REMOVE) template ScalableAffineTransform::ScalableAffineTransform(const MatrixType & matrix, const OutputVectorType & offset) @@ -70,6 +71,7 @@ ScalableAffineTransform::ScalableAffineTransfo m_MatrixScale[i] = 1; } } +#endif template void diff --git a/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.h b/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.h index fe3c83cb3aa..1a84f9580b3 100644 --- a/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.h +++ b/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.h @@ -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; diff --git a/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx b/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx index 3819ab072b5..4b46cc4006f 100644 --- a/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx +++ b/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx @@ -40,6 +40,7 @@ ScaleSkewVersor3DTransform::ScaleSkewVersor3DTransform(uns m_Skew.Fill(0.0); } +#if !defined(ITK_LEGACY_REMOVE) // Constructor with arguments template ScaleSkewVersor3DTransform::ScaleSkewVersor3DTransform(const MatrixType & matrix, @@ -48,6 +49,7 @@ ScaleSkewVersor3DTransform::ScaleSkewVersor3DTransform(con { this->ComputeMatrixParameters(); } +#endif // Directly set the matrix template diff --git a/Modules/Core/Transform/include/itkScaleVersor3DTransform.h b/Modules/Core/Transform/include/itkScaleVersor3DTransform.h index 6ccf7d210cc..b9ceb6b8d7e 100644 --- a/Modules/Core/Transform/include/itkScaleVersor3DTransform.h +++ b/Modules/Core/Transform/include/itkScaleVersor3DTransform.h @@ -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; diff --git a/Modules/Core/Transform/include/itkScaleVersor3DTransform.hxx b/Modules/Core/Transform/include/itkScaleVersor3DTransform.hxx index 2322fc62a88..2f139931e5b 100644 --- a/Modules/Core/Transform/include/itkScaleVersor3DTransform.hxx +++ b/Modules/Core/Transform/include/itkScaleVersor3DTransform.hxx @@ -37,6 +37,7 @@ ScaleVersor3DTransform::ScaleVersor3DTransform(unsigned in m_Scale.Fill(1.0); } +#if !defined(ITK_LEGACY_REMOVE) // Constructor with arguments template ScaleVersor3DTransform::ScaleVersor3DTransform(const MatrixType & matrix, @@ -45,6 +46,7 @@ ScaleVersor3DTransform::ScaleVersor3DTransform(const Matri { this->ComputeMatrixParameters(); } +#endif // Directly set the matrix template diff --git a/Modules/Core/Transform/include/itkSimilarity3DTransform.h b/Modules/Core/Transform/include/itkSimilarity3DTransform.h index 086a1d26647..abd687f8ee2 100644 --- a/Modules/Core/Transform/include/itkSimilarity3DTransform.h +++ b/Modules/Core/Transform/include/itkSimilarity3DTransform.h @@ -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; diff --git a/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx b/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx index b1e13d2d30a..48492334949 100644 --- a/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx +++ b/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx @@ -37,6 +37,7 @@ Similarity3DTransform::Similarity3DTransform(unsigned int , m_Scale(1.0) {} +#if !defined(ITK_LEGACY_REMOVE) // Constructor with arguments template Similarity3DTransform::Similarity3DTransform(const MatrixType & matrix, @@ -44,6 +45,7 @@ Similarity3DTransform::Similarity3DTransform(const MatrixT : Superclass(matrix, offset) , m_Scale(1.0) {} +#endif // / Set the parameters to the IdentityTransform template diff --git a/Modules/Core/Transform/include/itkVersorRigid3DTransform.h b/Modules/Core/Transform/include/itkVersorRigid3DTransform.h index 67470139fa0..5daa91059cf 100644 --- a/Modules/Core/Transform/include/itkVersorRigid3DTransform.h +++ b/Modules/Core/Transform/include/itkVersorRigid3DTransform.h @@ -128,7 +128,10 @@ class ITK_TEMPLATE_EXPORT VersorRigid3DTransform : public VersorTransform::VersorRigid3DTransform(unsigned in : Superclass(paramDim) {} +#if !defined(ITK_LEGACY_REMOVE) // Constructor with arguments template VersorRigid3DTransform::VersorRigid3DTransform(const MatrixType & matrix, const OutputVectorType & offset) : Superclass(matrix, offset) {} +#endif // Set Parameters template diff --git a/Modules/Core/Transform/include/itkVersorTransform.h b/Modules/Core/Transform/include/itkVersorTransform.h index fa12162fd08..13dedf257d8 100644 --- a/Modules/Core/Transform/include/itkVersorTransform.h +++ b/Modules/Core/Transform/include/itkVersorTransform.h @@ -135,7 +135,10 @@ class ITK_TEMPLATE_EXPORT VersorTransform : public Rigid3DTransform::VersorTransform(unsigned int parametersDi m_Versor.SetIdentity(); } +#if !defined(ITK_LEGACY_REMOVE) template VersorTransform::VersorTransform(const MatrixType & matrix, const OutputVectorType & offset) : Superclass(matrix, offset) { this->ComputeMatrixParameters(); // called in MatrixOffset baseclass } +#endif template void diff --git a/Modules/Core/Transform/test/itkMatrixOffsetTransformBaseGTest.cxx b/Modules/Core/Transform/test/itkMatrixOffsetTransformBaseGTest.cxx index 3235368a1da..154bf9ae526 100644 --- a/Modules/Core/Transform/test/itkMatrixOffsetTransformBaseGTest.cxx +++ b/Modules/Core/Transform/test/itkMatrixOffsetTransformBaseGTest.cxx @@ -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 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); -}