2 #include <cpPlugins/Interface/Image.h>
3 #include <cpPlugins/Interface/PolyLineParametricPath.h>
4 #include <cpExtensions/Algorithms/CPRFilter.h>
5 #include <itkInterpolateImageFunction.h>
7 // -------------------------------------------------------------------------
8 cpPlugins::BasicFilters::CPRFilter::
12 this->_AddInput( "InputImage" );
13 this->_AddInput( "InputAxis" );
14 this->_AddInput( "Interpolator", false );
15 this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
17 this->m_Parameters->ConfigureAsUint( "NumberOfSlices" );
18 this->m_Parameters->ConfigureAsReal( "SliceRadius" );
19 std::vector< std::string > choices;
20 choices.push_back( "float" );
21 choices.push_back( "double" );
22 this->m_Parameters->ConfigureAsChoices( "ScalarType", choices );
24 this->m_Parameters->SetUint( "NumberOfSlices", 0 );
25 this->m_Parameters->SetReal( "SliceRadius", 10 );
26 this->m_Parameters->SetSelectedChoice( "ScalarType", "float" );
29 // -------------------------------------------------------------------------
30 cpPlugins::BasicFilters::CPRFilter::
35 // -------------------------------------------------------------------------
36 std::string cpPlugins::BasicFilters::CPRFilter::
40 this->GetInputData< cpPlugins::Interface::Image >( "InputImage" );
41 itk::DataObject* itk_image = NULL;
43 cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
44 else r = "CPRFilter: Input image type not supported.";
48 // -------------------------------------------------------------------------
50 std::string cpPlugins::BasicFilters::CPRFilter::
51 _GD0( itk::DataObject* dobj )
53 I* image = dynamic_cast< I* >( dobj );
55 auto choice = this->m_Parameters->GetSelectedChoice( "ScalarType" );
56 if( choice == "float" )
57 return( this->_GD1< I, float >( image ) );
58 else if( choice == "double" )
59 return( this->_GD1< I, double >( image ) );
61 return( "CPRFilter: Scalar type not supported." );
64 // -------------------------------------------------------------------------
65 template< class I, class S >
66 std::string cpPlugins::BasicFilters::CPRFilter::
69 typedef cpExtensions::Algorithms::CPRFilter< I, S > _Filter;
70 typedef itk::PolyLineParametricPath< I::ImageDimension > _Path;
71 typedef itk::InterpolateImageFunction< I, S > _Interpolator;
74 this->GetInputData< cpPlugins::Interface::PolyLineParametricPath >(
76 )->GetITK< _Path >( );
78 return( "CPRFilter: Invalid input axis." );
80 this->GetInputData< cpPlugins::Interface::DataObject >( "Interpolator" );
81 _Interpolator* interpolator = NULL;
83 interpolator = w_int->GetITK< _Interpolator >( );
86 _Filter* filter = this->_CreateITK< _Filter >( );
87 filter->SetInput( image );
88 filter->SetAxis( axis );
89 if( interpolator != NULL )
90 filter->SetInterpolator( interpolator );
91 filter->SetNumberOfSlices( this->m_Parameters->GetUint( "NumberOfSlices" ) );
92 filter->SetSliceRadius( this->m_Parameters->GetReal( "SliceRadius" ) );
97 this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
98 out->SetITK( filter->GetOutput( ) );