Skip to content
Snippets Groups Projects
Commit 0654165e authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: initial work for a templated Component

parent eaf4136c
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,6 @@ set( ${MODULE}_LIBRARIES
# Module source files
set( ${MODULE}_SOURCE_FILES
${${MODULE}_SOURCE_DIR}/src/selxItkSmoothingRecursiveGaussianImageFilterComponent.cxx
${${MODULE}_SOURCE_DIR}/src/selxItkImageSource.cxx
${${MODULE}_SOURCE_DIR}/src/selxItkImageSink.cxx)
......
......@@ -9,6 +9,7 @@
#include "elxMacro.h"
namespace selx
{
template <int Dimensionality, class TPixel>
class ItkSmoothingRecursiveGaussianImageFilterComponent :
public Implements<
Accepting< itkImageSourceInterface >,
......@@ -22,11 +23,15 @@ namespace selx
public:
elxNewMacro(ItkSmoothingRecursiveGaussianImageFilterComponent, ComponentBase);
itkStaticConstMacro(Dimensionality, unsigned int, Dimensionality);
ItkSmoothingRecursiveGaussianImageFilterComponent();
virtual ~ItkSmoothingRecursiveGaussianImageFilterComponent();
typedef itk::SmoothingRecursiveGaussianImageFilter<itk::Image<double, 3>, itk::Image<double, 3>> TheItkFilterType;
typedef itk::ImageSource<itk::Image<double, 3>> ItkImageSourceType;
typedef TPixel PixelType;
typedef itk::SmoothingRecursiveGaussianImageFilter<itk::Image<PixelType, Dimensionality>, itk::Image<PixelType, Dimensionality>> TheItkFilterType;
typedef itk::ImageSource<itk::Image<PixelType, Dimensionality>> ItkImageSourceType;
typedef typename ItkImageSourceType::Pointer ItkImageSourcePointer;
// TODO: see if itkImageSourceInterface is the right way to connect itk filters..
/*
......@@ -37,7 +42,7 @@ namespace selx
virtual itk::ImageToImageFilter<itk::Image<double, 3>, itk::Image<double, 3>>::Pointer GetItkImageToImageFilter() override;
*/
virtual int Set(itkImageSourceInterface*) override;
virtual ItkImageSourceType::Pointer GetItkImageSource() override;
virtual ItkImageSourcePointer GetItkImageSource() override;
//int Update();
//virtual bool MeetsCriteria(const CriteriaType &criteria);
......@@ -45,7 +50,52 @@ namespace selx
//static const char * GetName() { return "GDOptimizer3rdPartyComponent"; } ;
static const char * GetDescription() { return "ItkSmoothingRecursiveGaussianImageFilter Component"; };
private:
TheItkFilterType::Pointer m_theItkFilter;
typename TheItkFilterType::Pointer m_theItkFilter;
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 required component (if desired)
// We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
}
};
/*
template <>
inline const std::string
ItkSmoothingRecursiveGaussianImageFilterComponent<2, float>
::GetTypeNameString()
{
return std::string("2_float");
}
template <>
inline const std::string
ItkSmoothingRecursiveGaussianImageFilterComponent<2, double>
::GetTypeNameString()
{
return std::string("2_double");
}
template <>
inline const std::string
ItkSmoothingRecursiveGaussianImageFilterComponent<3,float>
::GetTypeNameString()
{
return std::string("3_float");
}
*/
template <>
inline const std::string
ItkSmoothingRecursiveGaussianImageFilterComponent<3,double>
::GetTypeNameString()
{
return std::string("3_double");
}
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkSmoothingRecursiveGaussianImageFilterComponent.hxx"
#endif
#endif // #define GDOptimizer3rdPartyComponent_h
\ No newline at end of file
......@@ -2,11 +2,13 @@
namespace selx
{
ItkSmoothingRecursiveGaussianImageFilterComponent::ItkSmoothingRecursiveGaussianImageFilterComponent()
template<int Dimensionality, class TPixel>
ItkSmoothingRecursiveGaussianImageFilterComponent< Dimensionality, TPixel>::ItkSmoothingRecursiveGaussianImageFilterComponent()
{
m_theItkFilter = TheItkFilterType::New();
}
ItkSmoothingRecursiveGaussianImageFilterComponent::~ItkSmoothingRecursiveGaussianImageFilterComponent()
template<int Dimensionality, class TPixel>
ItkSmoothingRecursiveGaussianImageFilterComponent< Dimensionality, TPixel>::~ItkSmoothingRecursiveGaussianImageFilterComponent()
{
}
......@@ -38,8 +40,8 @@ itk::ImageToImageFilter<itk::Image<double, 3>, itk::Image<double, 3>>::Pointer I
return m_theItkFilter;
}
*/
int ItkSmoothingRecursiveGaussianImageFilterComponent::Set(itkImageSourceInterface* component)
template<int Dimensionality, class TPixel>
int ItkSmoothingRecursiveGaussianImageFilterComponent< Dimensionality, TPixel>::Set(itkImageSourceInterface* component)
{
auto other = component->GetItkImageSource();
// connect the itk pipeline
......@@ -48,13 +50,14 @@ int ItkSmoothingRecursiveGaussianImageFilterComponent::Set(itkImageSourceInterfa
}
//ItkImageSourceType::Pointer
itk::ImageSource<itk::Image<double, 3>>::Pointer ItkSmoothingRecursiveGaussianImageFilterComponent::GetItkImageSource()
template<int Dimensionality, class TPixel>
typename ItkSmoothingRecursiveGaussianImageFilterComponent< Dimensionality, TPixel>::ItkImageSourcePointer ItkSmoothingRecursiveGaussianImageFilterComponent< Dimensionality, TPixel>::GetItkImageSource()
{
return m_theItkFilter;
}
template<int Dimensionality, class TPixel>
bool
ItkSmoothingRecursiveGaussianImageFilterComponent
ItkSmoothingRecursiveGaussianImageFilterComponent< Dimensionality, TPixel>
::MeetsCriterion(const CriterionType &criterion)
{
bool hasUndefinedCriteria(false);
......
......@@ -30,7 +30,7 @@ public:
/** register all components used for this test */
ComponentFactory<ItkSmoothingRecursiveGaussianImageFilterComponent>::RegisterOneFactory();
ComponentFactory<ItkSmoothingRecursiveGaussianImageFilterComponent<3,double>>::RegisterOneFactory();
ComponentFactory<ItkImageSinkComponent>::RegisterOneFactory();
ComponentFactory<ItkImageSourceComponent>::RegisterOneFactory();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment