Commit 9c85d908 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: refactored ElastixComponents to use TemplateProperties() in

MeetsCriterion()
parent e73cbc1c
......@@ -96,113 +96,13 @@ private:
protected:
/* The following struct returns the string name of computation type */
/* default implementation */
static inline const std::string GetTypeNameString()
{
itkGenericExceptionMacro( << "Unknown ScalarType" << typeid( TPixel ).name() );
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
}
static inline const std::string GetPixelTypeNameString()
// return the class name and the template arguments to uniquely identify this component.
static inline const std::map<std::string, std::string> TemplateProperties()
{
itkGenericExceptionMacro( << "Unknown PixelType" << typeid( TPixel ).name() );
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
return{ { keys::NameOfClass, "ElastixComponent" }, { keys::PixelType, PodString<TPixel>::Get() }, { keys::Dimensionality, std::to_string(Dimensionality) } };
}
};
// unfortunately partial specialization of member functions is not allowed, without partially specializing the entire class.
/*
template <int Dimensionality>
class ElastixComponent < Dimensionality, double >
{
static inline const std::string GetPixelTypeNameString();
};
template <int Dimensionality>
inline const std::string
ElastixComponent<Dimensionality, double>
::GetPixelTypeNameString()
{
return std::string("double");
}
*/
template< >
inline const std::string
ElastixComponent< 2, float >
::GetPixelTypeNameString()
{
return std::string( "float" );
}
template< >
inline const std::string
ElastixComponent< 2, double >
::GetPixelTypeNameString()
{
return std::string( "double" );
}
template< >
inline const std::string
ElastixComponent< 3, float >
::GetPixelTypeNameString()
{
return std::string( "float" );
}
template< >
inline const std::string
ElastixComponent< 3, double >
::GetPixelTypeNameString()
{
return std::string( "double" );
}
template< >
inline const std::string
ElastixComponent< 2, float >
::GetTypeNameString()
{
return std::string( "2_float" );
}
template< >
inline const std::string
ElastixComponent< 2, double >
::GetTypeNameString()
{
return std::string( "2_double" );
}
template< >
inline const std::string
ElastixComponent< 3, float >
::GetTypeNameString()
{
return std::string( "3_float" );
}
template< >
inline const std::string
ElastixComponent< 3, double >
::GetTypeNameString()
{
return std::string( "3_double" );
}
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxElastixComponent.hxx"
......
......@@ -114,41 +114,18 @@ bool
ElastixComponent< Dimensionality, TPixel >
::MeetsCriterion( const CriterionType & criterion )
{
bool hasUndefinedCriteria( false );
bool meetsCriteria( false );
if( criterion.first == "ComponentProperty" )
bool hasUndefinedCriteria(false);
bool meetsCriteria(false);
auto status = CheckTemplateProperties(this->TemplateProperties(), criterion);
if (status == CriterionStatus::Satisfied)
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( criterionValue != "SomeProperty" ) // e.g. "GradientDescent", "SupportsSparseSamples
{
meetsCriteria = false;
}
}
}
else if( criterion.first == "Dimensionality" ) //Supports this?
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( std::stoi( criterionValue ) != Dimensionality )
{
meetsCriteria = false;
}
}
return true;
}
else if( criterion.first == "PixelType" ) //Supports this?
else if (status == CriterionStatus::Failed)
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( criterionValue != Self::GetPixelTypeNameString() )
{
meetsCriteria = false;
}
}
}
return false;
} // else: CriterionStatus::Unknown
else if( criterion.first == "RegistrationPreset" ) //Supports this?
{
// Temporary solution: RegistrationPreset: rigid, nonrigid, etc overwrite the current selxparameterObject.
......
......@@ -96,113 +96,13 @@ private:
protected:
/* The following struct returns the string name of computation type */
/* default implementation */
static inline const std::string GetTypeNameString()
{
itkGenericExceptionMacro( << "Unknown ScalarType" << typeid( TPixel ).name() );
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
}
static inline const std::string GetPixelTypeNameString()
// return the class name and the template arguments to uniquely identify this component.
static inline const std::map<std::string, std::string> TemplateProperties()
{
itkGenericExceptionMacro( << "Unknown PixelType" << typeid( TPixel ).name() );
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
return{ { keys::NameOfClass, "MonolithicElastixComponent" }, { keys::PixelType, PodString<TPixel>::Get() }, { keys::Dimensionality, std::to_string(Dimensionality) } };
}
};
// unfortunately partial specialization of member functions is not allowed, without partially specializing the entire class.
/*
template <int Dimensionality>
class MonolithicElastixComponent < Dimensionality, double >
{
static inline const std::string GetPixelTypeNameString();
};
template <int Dimensionality>
inline const std::string
MonolithicElastixComponent<Dimensionality, double>
::GetPixelTypeNameString()
{
return std::string("double");
}
*/
template< >
inline const std::string
MonolithicElastixComponent< 2, float >
::GetPixelTypeNameString()
{
return std::string( "float" );
}
template< >
inline const std::string
MonolithicElastixComponent< 2, double >
::GetPixelTypeNameString()
{
return std::string( "double" );
}
template< >
inline const std::string
MonolithicElastixComponent< 3, float >
::GetPixelTypeNameString()
{
return std::string( "float" );
}
template< >
inline const std::string
MonolithicElastixComponent< 3, double >
::GetPixelTypeNameString()
{
return std::string( "double" );
}
template< >
inline const std::string
MonolithicElastixComponent< 2, float >
::GetTypeNameString()
{
return std::string( "2_float" );
}
template< >
inline const std::string
MonolithicElastixComponent< 2, double >
::GetTypeNameString()
{
return std::string( "2_double" );
}
template< >
inline const std::string
MonolithicElastixComponent< 3, float >
::GetTypeNameString()
{
return std::string( "3_float" );
}
template< >
inline const std::string
MonolithicElastixComponent< 3, double >
::GetTypeNameString()
{
return std::string( "3_double" );
}
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxMonolithicElastix.hxx"
......
......@@ -94,42 +94,19 @@ bool
MonolithicElastixComponent< Dimensionality, TPixel >
::MeetsCriterion( const CriterionType & criterion )
{
bool hasUndefinedCriteria( false );
bool meetsCriteria( false );
if( criterion.first == "ComponentProperty" )
bool hasUndefinedCriteria(false);
bool meetsCriteria(false);
auto status = CheckTemplateProperties(this->TemplateProperties(), criterion);
if (status == CriterionStatus::Satisfied)
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( criterionValue != "SomeProperty" ) // e.g. "GradientDescent", "SupportsSparseSamples
{
meetsCriteria = false;
}
}
}
else if( criterion.first == "Dimensionality" ) //Supports this?
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( std::stoi( criterionValue ) != Dimensionality )
{
meetsCriteria = false;
}
}
return true;
}
else if( criterion.first == "PixelType" ) //Supports this?
else if (status == CriterionStatus::Failed)
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( criterionValue != Self::GetPixelTypeNameString() )
{
meetsCriteria = false;
}
}
}
else if( criterion.first == "RegistrationPreset" ) //Supports this?
return false;
} // else: CriterionStatus::Unknown
else if (criterion.first == "RegistrationPreset") //Supports this?
{
// Temporary solution: RegistrationPreset: rigid, nonrigid, etc overwrite the current selxparameterObject.
// Warning: the order of Criteria matters, since selxparameterObject may be overwritten
......
......@@ -92,113 +92,13 @@ private:
protected:
/* The following struct returns the string name of computation type */
/* default implementation */
static inline const std::string GetTypeNameString()
{
itkGenericExceptionMacro( << "Unknown ScalarType" << typeid( TPixel ).name() );
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
}
static inline const std::string GetPixelTypeNameString()
// return the class name and the template arguments to uniquely identify this component.
static inline const std::map<std::string, std::string> TemplateProperties()
{
itkGenericExceptionMacro( << "Unknown PixelType" << typeid( TPixel ).name() );
// TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
return{ { keys::NameOfClass, "MonolithicTransformixComponent" }, { keys::PixelType, PodString<TPixel>::Get() }, { keys::Dimensionality, std::to_string(Dimensionality) } };
}
};
// unfortunately partial specialization of member functions is not allowed, without partially specializing the entire class.
/*
template <int Dimensionality>
class MonolithicTransformixComponent < Dimensionality, double >
{
static inline const std::string GetPixelTypeNameString();
};
template <int Dimensionality>
inline const std::string
MonolithicTransformixComponent<Dimensionality, double>
::GetPixelTypeNameString()
{
return std::string("double");
}
*/
template< >
inline const std::string
MonolithicTransformixComponent< 2, float >
::GetPixelTypeNameString()
{
return std::string( "float" );
}
template< >
inline const std::string
MonolithicTransformixComponent< 2, double >
::GetPixelTypeNameString()
{
return std::string( "double" );
}
template< >
inline const std::string
MonolithicTransformixComponent< 3, float >
::GetPixelTypeNameString()
{
return std::string( "float" );
}
template< >
inline const std::string
MonolithicTransformixComponent< 3, double >
::GetPixelTypeNameString()
{
return std::string( "double" );
}
template< >
inline const std::string
MonolithicTransformixComponent< 2, float >
::GetTypeNameString()
{
return std::string( "2_float" );
}
template< >
inline const std::string
MonolithicTransformixComponent< 2, double >
::GetTypeNameString()
{
return std::string( "2_double" );
}
template< >
inline const std::string
MonolithicTransformixComponent< 3, float >
::GetTypeNameString()
{
return std::string( "3_float" );
}
template< >
inline const std::string
MonolithicTransformixComponent< 3, double >
::GetTypeNameString()
{
return std::string( "3_double" );
}
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxMonolithicTransformix.hxx"
......
......@@ -151,41 +151,18 @@ bool
MonolithicTransformixComponent< Dimensionality, TPixel >
::MeetsCriterion( const CriterionType & criterion )
{
bool hasUndefinedCriteria( false );
bool meetsCriteria( false );
if( criterion.first == "ComponentProperty" )
bool hasUndefinedCriteria(false);
bool meetsCriteria(false);
auto status = CheckTemplateProperties(this->TemplateProperties(), criterion);
if (status == CriterionStatus::Satisfied)
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( criterionValue != "SomeProperty" ) // e.g. "GradientDescent", "SupportsSparseSamples
{
meetsCriteria = false;
}
}
return true;
}
else if( criterion.first == "Dimensionality" ) //Supports this?
else if (status == CriterionStatus::Failed)
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( std::stoi( criterionValue ) != Dimensionality )
{
meetsCriteria = false;
}
}
}
else if( criterion.first == "PixelType" ) //Supports this?
{
meetsCriteria = true;
for( auto const & criterionValue : criterion.second ) // auto&& preferred?
{
if( criterionValue != Self::GetPixelTypeNameString() )
{
meetsCriteria = false;
}
}
}
return false;
} // else: CriterionStatus::Unknown
return meetsCriteria;
}
} //end namespace selx
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment