+++ /dev/null
-#include "CPRFilter.h"
-#include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/PolyLineParametricPath.h>
-#include <cpExtensions/Algorithms/CPRFilter.h>
-#include <itkInterpolateImageFunction.h>
-
-// -------------------------------------------------------------------------
-cpPlugins::BasicFilters::CPRFilter::
-CPRFilter( )
- : Superclass( )
-{
- this->_AddInput( "InputImage" );
- this->_AddInput( "InputAxis" );
- this->_AddInput( "Interpolator", false );
- this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
-
- this->m_Parameters->ConfigureAsUint( "NumberOfSlices" );
- this->m_Parameters->ConfigureAsReal( "SliceRadius" );
- std::vector< std::string > choices;
- choices.push_back( "float" );
- choices.push_back( "double" );
- this->m_Parameters->ConfigureAsChoices( "ScalarType", choices );
-
- this->m_Parameters->SetUint( "NumberOfSlices", 0 );
- this->m_Parameters->SetReal( "SliceRadius", 10 );
- this->m_Parameters->SetSelectedChoice( "ScalarType", "float" );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::BasicFilters::CPRFilter::
-~CPRFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::BasicFilters::CPRFilter::
-_GenerateData( )
-{
- auto image =
- this->GetInputData< cpPlugins::Interface::Image >( "InputImage" );
- itk::DataObject* itk_image = NULL;
- std::string r = "";
- cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
- else r = "CPRFilter: Input image type not supported.";
- return( r );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-std::string cpPlugins::BasicFilters::CPRFilter::
-_GD0( itk::DataObject* dobj )
-{
- I* image = dynamic_cast< I* >( dobj );
-
- auto choice = this->m_Parameters->GetSelectedChoice( "ScalarType" );
- if( choice == "float" )
- return( this->_GD1< I, float >( image ) );
- else if( choice == "double" )
- return( this->_GD1< I, double >( image ) );
- else
- return( "CPRFilter: Scalar type not supported." );
-}
-
-// -------------------------------------------------------------------------
-template< class I, class S >
-std::string cpPlugins::BasicFilters::CPRFilter::
-_GD1( I* image )
-{
- typedef cpExtensions::Algorithms::CPRFilter< I, S > _Filter;
- typedef itk::PolyLineParametricPath< I::ImageDimension > _Path;
- typedef itk::InterpolateImageFunction< I, S > _Interpolator;
-
- auto axis =
- this->GetInputData< cpPlugins::Interface::PolyLineParametricPath >(
- "InputAxis"
- )->GetITK< _Path >( );
- if( axis == NULL )
- return( "CPRFilter: Invalid input axis." );
- auto w_int =
- this->GetInputData< cpPlugins::Interface::DataObject >( "Interpolator" );
- _Interpolator* interpolator = NULL;
- if( w_int != NULL )
- interpolator = w_int->GetITK< _Interpolator >( );
-
- // Configure filter
- _Filter* filter = this->_CreateITK< _Filter >( );
- filter->SetInput( image );
- filter->SetAxis( axis );
- if( interpolator != NULL )
- filter->SetInterpolator( interpolator );
- filter->SetNumberOfSlices( this->m_Parameters->GetUint( "NumberOfSlices" ) );
- filter->SetSliceRadius( this->m_Parameters->GetReal( "SliceRadius" ) );
- filter->Update( );
-
- // Assign output
- auto out =
- this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
- out->SetITK( filter->GetOutput( ) );
- return( "" );
-}
-
-// eof - $RCSfile$