Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: refactoring transform templates #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
70 changes: 35 additions & 35 deletions Modules/Core/Transform/include/itkAffineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@
namespace itk
{
/** Constructor with default arguments */
template< typename TScalar, unsigned int NDimensions >
AffineTransform< TScalar, NDimensions >::AffineTransform():Superclass(ParametersDimension)
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType>
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >::AffineTransform():Superclass(ParametersDimension)
{}

/** Constructor with default arguments */
template< typename TScalar, unsigned int NDimensions >
AffineTransform< TScalar, NDimensions >::AffineTransform(unsigned int parametersDimension):
template< typename TScalar, unsigned int NDimensions typename TFixedParametersValueType>
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >::AffineTransform(unsigned int parametersDimension):
Superclass(parametersDimension)
{}

/** Constructor with explicit arguments */
template< typename TScalar, unsigned int NDimensions >
AffineTransform< TScalar, NDimensions >::AffineTransform(const MatrixType & matrix,
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
AffineTransform< TScalar, NDimensions, typename TFixedParametersValueType >::AffineTransform(const MatrixType & matrix,
const OutputVectorType & offset):
Superclass(matrix, offset)
{}

/** Destructor */
template< typename TScalar, unsigned int NDimensions >
AffineTransform< TScalar, NDimensions >::
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
AffineTransform< TScalar, NDimensions TFixedParametersValueType >::
~AffineTransform()
{
}

/** Print self */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >::PrintSelf(std::ostream & os, Indent indent) const
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >::PrintSelf(std::ostream & os, Indent indent) const
{
Superclass::PrintSelf(os, indent);
}

/** Compose with a translation */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >::Translate(const OutputVectorType & trans, bool pre)
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >::Translate(const OutputVectorType & trans, bool pre)
{
OutputVectorType newTranslation = this->GetTranslation();

Expand All @@ -78,9 +78,9 @@ AffineTransform< TScalar, NDimensions >::Translate(const OutputVectorType & tran
}

/** Compose with isotropic scaling */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Scale(const TScalar & factor, bool pre)
{
if ( pre )
Expand All @@ -105,9 +105,9 @@ AffineTransform< TScalar, NDimensions >
}

/** Compose with anisotropic scaling */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Scale(const OutputVectorType & factor, bool pre)
{
MatrixType trans;
Expand Down Expand Up @@ -136,9 +136,9 @@ AffineTransform< TScalar, NDimensions >
}

/** Compose with elementary rotation */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Rotate(int axis1, int axis2, TScalar angle, bool pre)
{
MatrixType trans;
Expand Down Expand Up @@ -173,9 +173,9 @@ AffineTransform< TScalar, NDimensions >
/** Compose with 2D rotation
* \todo Find a way to generate a compile-time error
* is this is used with NDimensions != 2. */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Rotate2D(TScalar angle, bool pre)
{
MatrixType trans;
Expand All @@ -201,9 +201,9 @@ AffineTransform< TScalar, NDimensions >
/** Compose with 3D rotation
* \todo Find a way to generate a compile-time error
* is this is used with NDimensions != 3. */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Rotate3D(const OutputVectorType & axis, TScalar angle, bool pre)
{
MatrixType trans;
Expand Down Expand Up @@ -249,9 +249,9 @@ AffineTransform< TScalar, NDimensions >
}

/** Compose with elementary rotation */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
void
AffineTransform< TScalar, NDimensions >
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Shear(int axis1, int axis2, TScalar coef, bool pre)
{
MatrixType trans;
Expand Down Expand Up @@ -281,18 +281,18 @@ AffineTransform< TScalar, NDimensions >
}

/** Get an inverse of this transform. */
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
bool
AffineTransform< TScalar, NDimensions >
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::GetInverse(Self *inverse) const
{
return this->Superclass::GetInverse(inverse);
}

/** Return an inverse of this transform. */
template< typename TScalar, unsigned int NDimensions >
typename AffineTransform< TScalar, NDimensions >::InverseTransformBasePointer
AffineTransform< TScalar, NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
typename AffineTransform< TScalar, NDimensions, TFixedParametersValueType >::InverseTransformBasePointer
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::GetInverseTransform() const
{
Pointer inv = New();
Expand All @@ -301,9 +301,9 @@ AffineTransform< TScalar, NDimensions >
}

/** Compute a distance between two affine transforms */
template< typename TScalar, unsigned int NDimensions >
typename AffineTransform< TScalar, NDimensions >::ScalarType
AffineTransform< TScalar, NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
typename AffineTransform< TScalar, NDimensions, TFixedParametersValueType >::ScalarType
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Metric(const Self *other) const
{
ScalarType result = 0.0, term;
Expand All @@ -322,9 +322,9 @@ AffineTransform< TScalar, NDimensions >
}

/** Compute a distance between self and the identity transform */
template< typename TScalar, unsigned int NDimensions >
typename AffineTransform< TScalar, NDimensions >::ScalarType
AffineTransform< TScalar, NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValue >
typename AffineTransform< TScalar, NDimensions, TFixedParametersValueType >::ScalarType
AffineTransform< TScalar, NDimensions, TFixedParametersValueType >
::Metric(void) const
{
ScalarType result = 0.0, term;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace itk
{
// Constructor with default arguments
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType=TScalar >
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::AzimuthElevationToCartesianTransform()
// add this construction call when deriving from itk::Transform
// :Superclass(ParametersDimension)
Expand All @@ -38,16 +38,16 @@ AzimuthElevationToCartesianTransform< TScalar, NDimensions >::AzimuthElevationTo
}

// Destructor
template< typename TScalar, unsigned int NDimensions >
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType >
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::
~AzimuthElevationToCartesianTransform()
{
}

// Print self
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType >
void
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::PrintSelf(std::ostream & os, Indent indent) const
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::PrintSelf(std::ostream & os, Indent indent) const
{
Superclass::PrintSelf(os, indent);

Expand All @@ -73,10 +73,10 @@ AzimuthElevationToCartesianTransform< TScalar, NDimensions >::PrintSelf(std::ost
os << indent << std::endl;
}

template< typename TScalar, unsigned int NDimensions >
typename AzimuthElevationToCartesianTransform< TScalar, NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType >
typename AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >
::OutputPointType
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::TransformPoint(const InputPointType & point) const
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::TransformPoint(const InputPointType & point) const
{
OutputPointType result;

Expand All @@ -92,11 +92,13 @@ AzimuthElevationToCartesianTransform< TScalar, NDimensions >::TransformPoint(con
}

/** Transform a point, from azimuth-elevation to cartesian */
template< typename TScalar, unsigned int NDimensions >
typename AzimuthElevationToCartesianTransform< TScalar, NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType>
typename AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >
::OutputPointType
AzimuthElevationToCartesianTransform< TScalar,
NDimensions >::TransformAzElToCartesian(const InputPointType & point) const
NDimensions,
TFixedParametersValueType >
::TransformAzElToCartesian(const InputPointType & point) const
{
OutputPointType result;
ScalarType Azimuth = ( ( 2 * vnl_math::pi ) / 360 )
Expand All @@ -118,10 +120,10 @@ AzimuthElevationToCartesianTransform< TScalar,
return result;
}

template< typename TScalar, unsigned int NDimensions >
typename AzimuthElevationToCartesianTransform< TScalar, NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType >
typename AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >
::OutputPointType
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::TransformCartesianToAzEl(
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::TransformCartesianToAzEl(
const OutputPointType & point) const
{
InputPointType result; // Converted point
Expand All @@ -138,9 +140,9 @@ AzimuthElevationToCartesianTransform< TScalar, NDimensions >::TransformCartesian
}

// Set parameters
template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType>
void
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::SetAzimuthElevationToCartesianParameters(
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::SetAzimuthElevationToCartesianParameters(
const double sampleSize,
const double
firstSampleDistance,
Expand All @@ -163,9 +165,9 @@ AzimuthElevationToCartesianTransform< TScalar, NDimensions >::SetAzimuthElevatio
SetFirstSampleDistance(firstSampleDistance / sampleSize);
}

template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType>
void
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::SetAzimuthElevationToCartesianParameters(
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::SetAzimuthElevationToCartesianParameters(
const double sampleSize,
const double
firstSampleDistance,
Expand All @@ -178,16 +180,16 @@ AzimuthElevationToCartesianTransform< TScalar, NDimensions >::SetAzimuthElevatio
maxAzimuth, maxElevation, 1.0, 1.0);
}

template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType >
void
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::SetForwardAzimuthElevationToCartesian()
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::SetForwardAzimuthElevationToCartesian()
{
m_ForwardAzimuthElevationToPhysical = true;
}

template< typename TScalar, unsigned int NDimensions >
template< typename TScalar, unsigned int NDimensions, typename TFixedParametersValueType >
void
AzimuthElevationToCartesianTransform< TScalar, NDimensions >::SetForwardCartesianToAzimuthElevation()
AzimuthElevationToCartesianTransform< TScalar, NDimensions, TFixedParametersValueType >::SetForwardCartesianToAzimuthElevation()
{
m_ForwardAzimuthElevationToPhysical = false;
}
Expand Down
Loading