Skip to content

Commit

Permalink
Use unique_ptr for Transform interface
Browse files Browse the repository at this point in the history
  • Loading branch information
blowekamp committed May 31, 2023
1 parent 5830285 commit c379a9d
Show file tree
Hide file tree
Showing 33 changed files with 81 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Code/Common/include/sitkAffineTransform.h
Expand Up @@ -80,7 +80,7 @@ class SITKCommon_EXPORT AffineTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkBSplineTransform.h
Expand Up @@ -90,7 +90,7 @@ class SITKCommon_EXPORT BSplineTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
Expand Up @@ -96,7 +96,7 @@ class SITKCommon_EXPORT ComposeScaleSkewVersor3DTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkCompositeTransform.h
Expand Up @@ -149,7 +149,7 @@ class SITKCommon_EXPORT CompositeTransform

protected:

void SetPimpleTransform( PimpleTransformBase * ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> &&) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkDisplacementFieldTransform.h
Expand Up @@ -108,7 +108,7 @@ class SITKCommon_EXPORT DisplacementFieldTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkEuler2DTransform.h
Expand Up @@ -74,7 +74,7 @@ class SITKCommon_EXPORT Euler2DTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkEuler3DTransform.h
Expand Up @@ -85,7 +85,7 @@ SITK_RETURN_SELF_TYPE_HEADER ComputeZYXOff () {return this->SetComputeZYX(false)

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkScaleSkewVersor3DTransform.h
Expand Up @@ -91,7 +91,7 @@ class SITKCommon_EXPORT ScaleSkewVersor3DTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkScaleTransform.h
Expand Up @@ -66,7 +66,7 @@ class SITKCommon_EXPORT ScaleTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkScaleVersor3DTransform.h
Expand Up @@ -87,7 +87,7 @@ class SITKCommon_EXPORT ScaleVersor3DTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkSimilarity2DTransform.h
Expand Up @@ -78,7 +78,7 @@ class SITKCommon_EXPORT Similarity2DTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkSimilarity3DTransform.h
Expand Up @@ -85,7 +85,7 @@ SITK_RETURN_SELF_TYPE_HEADER SetMatrix(const std::vector<double> &matrix, double

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/include/sitkTransform.h
Expand Up @@ -255,9 +255,9 @@ class SITKCommon_EXPORT Transform
explicit Transform( PimpleTransformBase *pimpleTransform );

// this method is called to set the private pimpleTransform outside
// of the constructor, derived classes can override it of update the
// the constructor, derived classes can override it of update the
// state.
virtual void SetPimpleTransform( PimpleTransformBase *pimpleTransform );
virtual void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform );

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkTranslationTransform.h
Expand Up @@ -58,7 +58,7 @@ std::vector<double> GetOffset( ) const;

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkVersorRigid3DTransform.h
Expand Up @@ -82,7 +82,7 @@ class SITKCommon_EXPORT VersorRigid3DTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
2 changes: 1 addition & 1 deletion Code/Common/include/sitkVersorTransform.h
Expand Up @@ -78,7 +78,7 @@ class SITKCommon_EXPORT VersorTransform

protected:

void SetPimpleTransform( PimpleTransformBase *pimpleTransform ) override;
void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;

private:

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkAffineTransform.cxx
Expand Up @@ -139,9 +139,9 @@ AffineTransform::Self &AffineTransform::Rotate(int axis1, int axis2, double angl
return *this;
}

void AffineTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void AffineTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkBSplineTransform.cxx
Expand Up @@ -207,9 +207,9 @@ unsigned int BSplineTransform::GetOrder() const
}


void BSplineTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void BSplineTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkComposeScaleSkewVersor3DTransform.cxx
Expand Up @@ -167,9 +167,9 @@ std::vector<double> ComposeScaleSkewVersor3DTransform::GetMatrix( ) const
return this->m_pfGetMatrix();
}

void ComposeScaleSkewVersor3DTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void ComposeScaleSkewVersor3DTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
6 changes: 3 additions & 3 deletions Code/Common/src/sitkCompositeTransform.cxx
Expand Up @@ -66,9 +66,9 @@ CompositeTransform &CompositeTransform::operator=( const CompositeTransform &arg
return *this;
}

void CompositeTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void CompositeTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down Expand Up @@ -214,7 +214,7 @@ void CompositeTransform::InternalInitialization(itk::Transform<double, NDimensio
ctx->AddTransform(tx);

// Call InternalInitialization again with a CompositeTransform the second time.
Self::SetPimpleTransform(new PimpleTransform<CompositeTransformType >(ctx));
Self::SetPimpleTransform(std::make_unique<PimpleTransform<CompositeTransformType >>(ctx));
}


Expand Down
10 changes: 5 additions & 5 deletions Code/Common/src/sitkDisplacementFieldTransform.cxx
Expand Up @@ -236,9 +236,9 @@ DisplacementFieldTransform::SetSmoothingBSplineOnUpdate( const std::vector<unsig
}


void DisplacementFieldTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void DisplacementFieldTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down Expand Up @@ -363,7 +363,7 @@ void DisplacementFieldTransform::InternalSetSmoothingOff( TDisplacementFieldTran
itkNewDisplacement->SetInterpolator( itkDisplacement->GetModifiableInterpolator() );
itkNewDisplacement->SetInverseInterpolator( itkDisplacement->GetModifiableInverseInterpolator() );

this->SetPimpleTransform( new PimpleTransform<NewTransformType>(itkNewDisplacement));
this->SetPimpleTransform( std::make_unique<PimpleTransform<NewTransformType>>(itkNewDisplacement));
}
}

Expand All @@ -390,7 +390,7 @@ void DisplacementFieldTransform::InternalSetSmoothingGaussianOnUpdate( TDisplace
itkNewDisplacement->SetInterpolator( itkDisplacement->GetModifiableInterpolator() );
itkNewDisplacement->SetInverseInterpolator( itkDisplacement->GetModifiableInverseInterpolator() );

this->SetPimpleTransform( new PimpleTransform<NewTransformType>(itkNewDisplacement));
this->SetPimpleTransform( std::make_unique<PimpleTransform<NewTransformType>>(itkNewDisplacement));
}
else
{
Expand Down Expand Up @@ -428,7 +428,7 @@ void DisplacementFieldTransform::InternalSetSmoothingBSplineOnUpdate( TDisplacem
itkNewDisplacement->SetInterpolator( itkDisplacement->GetModifiableInterpolator() );
itkNewDisplacement->SetInverseInterpolator( itkDisplacement->GetModifiableInverseInterpolator() );

this->SetPimpleTransform( new PimpleTransform<NewTransformType>(itkNewDisplacement));
this->SetPimpleTransform( std::make_unique<PimpleTransform<NewTransformType>>(itkNewDisplacement));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkEuler2DTransform.cxx
Expand Up @@ -119,9 +119,9 @@ Euler2DTransform::Self &Euler2DTransform::SetMatrix(const std::vector<double> &p
return *this;
}

void Euler2DTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void Euler2DTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkEuler3DTransform.cxx
Expand Up @@ -140,9 +140,9 @@ Euler3DTransform::Self &Euler3DTransform::SetMatrix(const std::vector<double> &p
return *this;
}

void Euler3DTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void Euler3DTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
13 changes: 6 additions & 7 deletions Code/Common/src/sitkPimpleTransform.hxx
Expand Up @@ -136,8 +136,8 @@ public:
}


virtual PimpleTransformBase *ShallowCopy( ) const = 0;
virtual PimpleTransformBase *DeepCopy( ) const = 0;
virtual std::unique_ptr<PimpleTransformBase> ShallowCopy( ) const = 0;
virtual std::unique_ptr<PimpleTransformBase> DeepCopy( ) const = 0;

virtual int GetReferenceCount( ) const = 0;

Expand Down Expand Up @@ -221,15 +221,14 @@ public:
unsigned int GetOutputDimension( ) const override { return OutputDimension; }


PimpleTransformBase *ShallowCopy( ) const override
std::unique_ptr<PimpleTransformBase> ShallowCopy( ) const override
{
return new Self( this->m_Transform.GetPointer() );
return std::make_unique<Self>( this->m_Transform.GetPointer() );
}

PimpleTransformBase *DeepCopy( ) const override
std::unique_ptr<PimpleTransformBase> DeepCopy( ) const override
{
PimpleTransformBase *copy( new Self( this->m_Transform->Clone() ) );
return copy;
return std::make_unique<Self>( this->m_Transform->Clone() );
}

int GetReferenceCount( ) const override
Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkScaleSkewVersor3DTransform.cxx
Expand Up @@ -167,9 +167,9 @@ std::vector<double> ScaleSkewVersor3DTransform::GetMatrix( ) const
return this->m_pfGetMatrix();
}

void ScaleSkewVersor3DTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void ScaleSkewVersor3DTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkScaleTransform.cxx
Expand Up @@ -88,9 +88,9 @@ std::vector<double> ScaleTransform::GetMatrix( ) const
return this->m_pfGetMatrix();
}

void ScaleTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void ScaleTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkScaleVersor3DTransform.cxx
Expand Up @@ -151,9 +151,9 @@ std::vector<double> ScaleVersor3DTransform::GetMatrix( ) const
return this->m_pfGetMatrix();
}

void ScaleVersor3DTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void ScaleVersor3DTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkSimilarity2DTransform.cxx
Expand Up @@ -132,9 +132,9 @@ Similarity2DTransform::Self &Similarity2DTransform::SetMatrix(const std::vector<
return *this;
}

void Similarity2DTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void Similarity2DTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down
4 changes: 2 additions & 2 deletions Code/Common/src/sitkSimilarity3DTransform.cxx
Expand Up @@ -157,9 +157,9 @@ Similarity3DTransform::Self &Similarity3DTransform::SetMatrix(const std::vector<
return *this;
}

void Similarity3DTransform::SetPimpleTransform( PimpleTransformBase *pimpleTransform )
void Similarity3DTransform::SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform )
{
Superclass::SetPimpleTransform(pimpleTransform);
Superclass::SetPimpleTransform(std::move(pimpleTransform));
Self::InternalInitialization(this->GetITKBase());
}

Expand Down

0 comments on commit c379a9d

Please sign in to comment.