Skip to content

Commit

Permalink
STYLE: Let GetInverseTransform() just call Transform::InvertTransform
Browse files Browse the repository at this point in the history
Reduced the amount of duplicate code in the implementation of derived transform
classes.
  • Loading branch information
N-Dekker committed Mar 26, 2024
1 parent 5328c02 commit fb4b463
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 89 deletions.
4 changes: 1 addition & 3 deletions Modules/Core/Transform/include/itkAffineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
AffineTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return this->GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}

template <typename TParametersValueType, unsigned int VDimension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
CenteredAffineTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return this->GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}

} // namespace itk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ template <typename TParametersValueType>
auto
CenteredEuler3DTransform<TParametersValueType>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return this->GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}

// Print self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ template <typename TParametersValueType>
auto
CenteredRigid2DTransform<TParametersValueType>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,7 @@ template <typename TParametersValueType>
auto
CenteredSimilarity2DTransform<TParametersValueType>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

if (this->GetInverse(inv))
{
return inv.GetPointer();
}
return nullptr;
return Superclass::InvertTransform(*this);
}


Expand Down
12 changes: 1 addition & 11 deletions Modules/Core/Transform/include/itkCompositeTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -446,17 +446,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
CompositeTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
/* This method can't be defined in Superclass because of the call to New() */
Pointer inverseTransform = New();

if (this->GetInverse(inverseTransform))
{
return inverseTransform.GetPointer();
}
else
{
return nullptr;
}
return Superclass::InvertTransform(*this);
}


Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Transform/include/itkEuler2DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ template <typename TParametersValueType>
auto
Euler2DTransform<TParametersValueType>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}

// Create and return an inverse transformation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,7 @@ auto
MatrixOffsetTransformBase<TParametersValueType, VInputDimension, VOutputDimension>::GetInverseTransform() const
-> InverseTransformBasePointer
{
auto inv = InverseTransformType::New();

return GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}


Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Transform/include/itkRigid2DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ template <typename TParametersValueType>
auto
Rigid2DTransform<TParametersValueType>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
ScalableAffineTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return this->GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}

template <typename TParametersValueType, unsigned int VDimension>
Expand Down
8 changes: 1 addition & 7 deletions Modules/Core/Transform/include/itkScaleTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
ScaleTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

if (this->GetInverse(inv))
{
return inv.GetPointer();
}
return nullptr;
return Superclass::InvertTransform(*this);
}

template <typename TParametersValueType, unsigned int VDimension>
Expand Down
8 changes: 1 addition & 7 deletions Modules/Core/Transform/include/itkSimilarity2DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,7 @@ template <typename TParametersValueType>
auto
Similarity2DTransform<TParametersValueType>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

if (this->GetInverse(inv))
{
return inv.GetPointer();
}
return nullptr;
return Superclass::InvertTransform(*this);
}


Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Transform/include/itkTranslationTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
TranslationTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inv = New();

return GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}


Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Transform/include/itkv3Rigid3DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ class ITK_TEMPLATE_EXPORT Rigid3DTransform : public itk::Rigid3DTransform<TParam
InverseTransformBasePointer
GetInverseTransform() const override
{
Pointer inv = New();
return this->GetInverse(inv) ? inv.GetPointer() : nullptr;
return Superclass::InvertTransform(*this);
}

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ auto
ConstantVelocityFieldTransform<TParametersValueType, VDimension>::GetInverseTransform() const
-> InverseTransformBasePointer
{
Pointer inverseTransform = New();
if (this->GetInverse(inverseTransform))
{
return inverseTransform.GetPointer();
}
else
{
return nullptr;
}
return Superclass::InvertTransform(*this);
}

template <typename TParametersValueType, unsigned int VDimension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
DisplacementFieldTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inverseTransform = New();

if (this->GetInverse(inverseTransform))
{
return inverseTransform.GetPointer();
}
else
{
return nullptr;
}
return Superclass::InvertTransform(*this);
}

template <typename TParametersValueType, unsigned int VDimension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,7 @@ template <typename TParametersValueType, unsigned int VDimension>
auto
VelocityFieldTransform<TParametersValueType, VDimension>::GetInverseTransform() const -> InverseTransformBasePointer
{
Pointer inverseTransform = New();
if (this->GetInverse(inverseTransform))
{
return inverseTransform.GetPointer();
}
else
{
return nullptr;
}
return Superclass::InvertTransform(*this);
}

template <typename TParametersValueType, unsigned int VDimension>
Expand Down

0 comments on commit fb4b463

Please sign in to comment.