+#include "SignedMaurerDistanceMapImageFilter.h"
+#include <cpPlugins/Interface/Image.h>
+
+#include <itkSignedMaurerDistanceMapImageFilter.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+SignedMaurerDistanceMapImageFilter( )
+ : Superclass( )
+{
+ this->_AddInput( "Input" );
+ this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+
+ this->m_Parameters->ConfigureAsReal( "BackgroundValue" );
+ this->m_Parameters->ConfigureAsBool( "InsideIsPositive" );
+ this->m_Parameters->ConfigureAsBool( "SquaredDistance" );
+ this->m_Parameters->ConfigureAsBool( "UseImageSpacing" );
+
+ std::vector< std::string > choices;
+ choices.push_back( "float" );
+ choices.push_back( "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" );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+~SignedMaurerDistanceMapImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+_GenerateData( )
+{
+ cpPlugins::Interface::Image* image =
+ this->GetInput< cpPlugins::Interface::Image >( "Input" );
+ if( image == NULL )
+ return( "SignedMaurerDistanceMapImageFilter: No input image." );
+
+ itk::DataObject* itk_image = NULL;
+ std::string r = "";
+ cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
+ else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
+ else r = "SignedMaurerDistanceMapImageFilter: Input image type not supported.";
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+_GD0( itk::DataObject* image )
+{
+ std::string out_res =
+ this->m_Parameters->GetSelectedChoice( "OutputResolution" );
+ if( out_res == "float" )
+ return(
+ this->_RealGD< I, itk::Image< float, I::ImageDimension > >(
+ image
+ )
+ );
+ else if( out_res == "double" )
+ return(
+ this->_RealGD< I, itk::Image< double, I::ImageDimension > >(
+ image
+ )
+ );
+ else
+ return( "SignedMaurerDistanceMapImageFilter: Output resolution not supported." );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+inline std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+_RealGD( itk::DataObject* image )
+{
+ typedef itk::SignedMaurerDistanceMapImageFilter< I, O > _F;
+
+ // Get parameters
+ double back_value = this->m_Parameters->GetReal( "BackgroundValue" );
+ bool pos_inside = this->m_Parameters->GetBool( "InsideIsPositive" );
+ bool sqr_dist = this->m_Parameters->GetBool( "SquaredDistance" );
+ bool use_spac = this->m_Parameters->GetBool( "UseImageSpacing" );
+
+ // Configure filter
+ _F* filter = this->_CreateITK< _F >( );
+ filter->SetInput( dynamic_cast< I* >( image ) );
+ filter->SetBackgroundValue( ( typename I::PixelType )( back_value ) );
+ filter->SetInsideIsPositive( pos_inside );
+ filter->SetSquaredDistance( sqr_dist );
+ filter->SetUseImageSpacing( use_spac );
+
+ filter->Update( );
+
+ // Connect output
+ cpPlugins::Interface::Image* out =
+ this->GetOutput< cpPlugins::Interface::Image >( "Output" );
+ if( out != NULL )
+ {
+ out->SetITK< O >( filter->GetOutput( ) );
+ return( "" );
+ }
+ else
+ return( "SignedMaurerDistanceMapImageFilter: output not correctly created." );
+}
+
+// eof - $RCSfile$