]> Creatis software - cpPlugins.git/blobdiff - plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.cxx
MPR objects updated
[cpPlugins.git] / plugins / cpPluginsImageFilters / SignedMaurerDistanceMapImageFilter.cxx
index fcb03cd0cc0857ea7a2fa8d62b9bbfc73362027b..05b9620d19591d6bcc7ba9bfa0ffcf23799bd6b8 100644 (file)
@@ -1,13 +1,6 @@
 #include <cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h>
 #include <cpPlugins/Image.h>
-
-#include <itkSignedMaurerDistanceMapImageFilter.h>
-#include <itkSignedMaurerDistanceMapImageFilter.hxx>
-#include <itkBinaryThresholdImageFilter.hxx>
-#include <itkImageToImageFilter.hxx>
-#include <itkInPlaceImageFilter.hxx>
-#include <itkUnaryFunctorImageFilter.hxx>
-#include <itkBinaryContourImageFilter.hxx>
+#include <cpPlugins_Instances/DistanceMapFilters.h>
 
 // -------------------------------------------------------------------------
 cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
@@ -41,47 +34,42 @@ cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
 }
 
 // -------------------------------------------------------------------------
-std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
+void cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
 _GenerateData( )
 {
   auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
-  std::string   cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
-  if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
-  return( r );
+  cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
+  else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
+  else this->_Error( "No valid input image." );
 }
 
 // -------------------------------------------------------------------------
-template< class I >
-std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
-_GD0( I* image )
+template< class _TImage >
+void cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
+_GD0( _TImage* image )
 {
+  static const unsigned int D = _TImage::ImageDimension;
   if( image != NULL )
   {
     std::string out_res =
       this->m_Parameters.GetSelectedChoice( "OutputResolution" );
     if( out_res == "float" )
-      return(
-        this->_GD1< I, itk::Image< float, I::ImageDimension > >( image )
-        );
-  else if( out_res == "double" )
-    return(
-      this->_GD1< I, itk::Image< double, I::ImageDimension > >( image )
-      );
-  else
-    return( "ImageFilters::SignedMaurerDistanceMapImageFilter: Output resolution not supported." );
+      this->_GD1< _TImage, itk::Image< float, D > >( image );
+    else if( out_res == "double" )
+      this->_GD1< _TImage, itk::Image< double, D > >( image );
+    else
+      this->_Error( "Output resolution not supported." );
   }
   else
-    return(
-      "ImageFilters::SignedMaurerDistanceMapImageFilter: No valid input image."
-      );
+    this->_Error( "No valid input image." );
 }
 
 // -------------------------------------------------------------------------
-template< class I, class O >
-std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
-_GD1( I* image )
+template< class _TImage, class _TDMap >
+void cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
+_GD1( _TImage* image )
 {
-  typedef itk::SignedMaurerDistanceMapImageFilter< I, O > _F;
+  typedef itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap > _F;
 
   // Get parameters
   double back_value = this->m_Parameters.GetReal( "BackgroundValue" );
@@ -92,7 +80,7 @@ _GD1( I* image )
   // Configure filter
   _F* filter = this->_CreateITK< _F >( );
   filter->SetInput( image );
-  filter->SetBackgroundValue( ( typename I::PixelType )( back_value ) );
+  filter->SetBackgroundValue( ( typename _TImage::PixelType )( back_value ) );
   filter->SetInsideIsPositive( pos_inside );
   filter->SetSquaredDistance( sqr_dist );
   filter->SetUseImageSpacing( use_spac );
@@ -100,7 +88,6 @@ _GD1( I* image )
 
   // Connect output
   this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
-  return( "" );
 }
 
 // eof - $RCSfile$