]> Creatis software - cpPlugins.git/blobdiff - plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx
...
[cpPlugins.git] / plugins / ImageDistanceMaps / SignedMaurerDistanceMapImageFilter.cxx
index 41001947368179dc1a9d1027488c5cd4a068f2ce..237e15a07847d5bafb386c972e3eb38f1c2816e5 100644 (file)
@@ -1,36 +1,32 @@
-#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->m_Parameters.ConfigureAsReal( "BackgroundValue" );
-  this->m_Parameters.ConfigureAsBool( "InsideIsPositive" );
-  this->m_Parameters.ConfigureAsBool( "SquaredDistance" );
-  this->m_Parameters.ConfigureAsBool( "UseImageSpacing" );
+  this->_ConfigureInput< _TImage >( "Input", true, false );
+  this->_ConfigureOutput< _TImage >( "Output" );
+
+  this->m_Parameters.ConfigureAsReal( "BackgroundValue", 0 );
+  this->m_Parameters.ConfigureAsBool( "InsideIsPositive", true );
+  this->m_Parameters.ConfigureAsBool( "SquaredDistance", false );
+  this->m_Parameters.ConfigureAsBool( "UseImageSpacing", true );
 
   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 +40,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_ScalarPixels_VisualDims_1( o, _GD0 )
+    this->_Error( "Invalid input image dimension." );
 }
 
 // -------------------------------------------------------------------------
@@ -54,21 +49,22 @@ template< class _TImage >
 void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
 _GD0( _TImage* image )
 {
-  typedef itk::Image< float, _TImage::ImageDimension >  _TFDmap;
-  typedef itk::Image< double, _TImage::ImageDimension > _TDDmap;
-
   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->_GD1< _TImage, float >( image );
+#endif // cpPlugins_CONFIG_REAL_TYPES_float
+#ifdef cpPlugins_CONFIG_REAL_TYPES_double
+  if( out_res == "double" ) this->_GD1< _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 )
 {
+  typedef itk::Image< _TScalar, _TImage::ImageDimension >  _TDMap;
   typedef
     itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap >
     _TFilter;