]> Creatis software - cpPlugins.git/blobdiff - plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx
...
[cpPlugins.git] / plugins / ImageDistanceMaps / SignedMaurerDistanceMapImageFilter.cxx
index 41001947368179dc1a9d1027488c5cd4a068f2ce..ad2b183eba272b891532fff850df4ccf94eeda30 100644 (file)
@@ -1,20 +1,18 @@
-#include <plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.h>
+#include <ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.h>
 #include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Image_Demanglers.h>
 
-#include <cpPlugins_ImageIterators.h>
 #include <itkSignedMaurerDistanceMapImageFilter.h>
-#include <itkSignedMaurerDistanceMapImageFilter.hxx>
-#include <itkBinaryContourImageFilter.hxx>
-#include <itkBinaryThresholdImageFilter.hxx>
-#include <itkUnaryFunctorImageFilter.hxx>
 
 // -------------------------------------------------------------------------
 cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
 SignedMaurerDistanceMapImageFilter( )
   : Superclass( )
 {
-  this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false );
-  this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" );
+  typedef cpPlugins::DataObjects::Image _TImage;
+
+  this->_ConfigureInput< _TImage >( "Input", true, false );
+  this->_ConfigureOutput< _TImage >( "Output" );
 
   this->m_Parameters.ConfigureAsReal( "BackgroundValue" );
   this->m_Parameters.ConfigureAsBool( "InsideIsPositive" );
@@ -22,15 +20,18 @@ SignedMaurerDistanceMapImageFilter( )
   this->m_Parameters.ConfigureAsBool( "UseImageSpacing" );
 
   std::vector< std::string > choices;
+#ifdef cpPlugins_CONFIG_REAL_TYPES_float
   choices.push_back( "float" );
+#endif // cpPlugins_CONFIG_REAL_TYPES_float
+#ifdef cpPlugins_CONFIG_REAL_TYPES_double
   choices.push_back( "double" );
+#endif // cpPlugins_CONFIG_REAL_TYPES_double
   this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
 
   this->m_Parameters.SetReal( "BackgroundValue", 0 );
   this->m_Parameters.SetBool( "InsideIsPositive", true );
   this->m_Parameters.SetBool( "SquaredDistance", false );
   this->m_Parameters.SetBool( "UseImageSpacing", true );
-  this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" );
 }
 
 // -------------------------------------------------------------------------
@@ -44,9 +45,8 @@ void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
 _GenerateData( )
 {
   auto o = this->GetInputData( "Input" );
-  cpPlugins_Demangle_ImageScalars( o, _GD0, 2 );
-  else cpPlugins_Demangle_ImageScalars( o, _GD0, 3 );
-  else this->_Error( "Invalid input image." );
+  cpPlugins_Demangle_Image_ProcessDims( o, _GD0, )
+    this->_Error( "Invalid input image dimension." );
 }
 
 // -------------------------------------------------------------------------
@@ -54,21 +54,31 @@ template< class _TImage >
 void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
 _GD0( _TImage* image )
 {
-  typedef itk::Image< float, _TImage::ImageDimension >  _TFDmap;
-  typedef itk::Image< double, _TImage::ImageDimension > _TDDmap;
+  cpPlugins_Demangle_Image_ScalarPixels( image, _GD1, _TImage::ImageDimension, )
+    this->_Error( "Invalid input image pixel type." );
+}
 
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
+_GD1( _TImage* image )
+{
   std::string out_res =
     this->m_Parameters.GetSelectedChoice( "OutputResolution" );
-  if( out_res == "float" )       this->_GD1< _TImage, _TFDmap >( image );
-  else if( out_res == "double" ) this->_GD1< _TImage, _TDDmap >( image );
-  else this->_Error( "Output resolution not supported." );
+#ifdef cpPlugins_CONFIG_REAL_TYPES_float
+  if( out_res == "float" ) this->_GD2< _TImage, float >( image );
+#endif // cpPlugins_CONFIG_REAL_TYPES_float
+#ifdef cpPlugins_CONFIG_REAL_TYPES_double
+  if( out_res == "double" ) this->_GD2< _TImage, double >( image );
+#endif // cpPlugins_CONFIG_REAL_TYPES_double
 }
 
 // -------------------------------------------------------------------------
-template< class _TImage, class _TDMap >
+template< class _TImage, class _TScalar >
 void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
-_GD1( _TImage* image )
+_GD2( _TImage* image )
 {
+  typedef itk::Image< _TScalar, _TImage::ImageDimension >  _TDMap;
   typedef
     itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap >
     _TFilter;