1 #ifndef __fpaPlugins_ImageAlgorithms__BaseFilter__h__
2 #define __fpaPlugins_ImageAlgorithms__BaseFilter__h__
4 #include <fpaPlugins_ImageAlgorithms_Export.h>
6 #include <vtkPolyData.h>
7 #include <cpPlugins/Pipeline/ProcessObject.h>
9 namespace fpaPlugins_ImageAlgorithms
13 class fpaPlugins_ImageAlgorithms_EXPORT BaseFilter
14 : public cpPlugins::Pipeline::ProcessObject
17 typedef BaseFilter Self;
18 typedef cpPlugins::Pipeline::ProcessObject Superclass;
19 typedef itk::SmartPointer< Self > Pointer;
20 typedef itk::SmartPointer< const Self > ConstPointer;
23 itkTypeMacro( BaseFilter, cpPlugins::Pipeline::ProcessObject );
24 cpPlugins_Id_Macro( BaseFilter, fpaImageAlgorithm );
28 virtual ~BaseFilter( );
30 template< class _TFilter, class _TImage >
31 inline void _ConfigureFilter(
32 _TFilter* filter, _TImage* image,
33 std::vector< typename _TImage::IndexType >& seeds
37 // Purposely not implemented.
38 BaseFilter( const Self& other );
39 Self& operator=( const Self& other );
44 // -------------------------------------------------------------------------
45 #define ITK_MANUAL_INSTANTIATION
46 #include <fpa/Image/Functors/SimpleNeighborhood.h>
48 // -------------------------------------------------------------------------
49 template< class _TFilter, class _TImage >
50 void fpaPlugins_ImageAlgorithms::BaseFilter::
52 _TFilter* filter, _TImage* image,
53 std::vector< typename _TImage::IndexType >& seeds
56 typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood;
58 fpa::Image::Functors::SimpleNeighborhood< _TImage::ImageDimension >
61 // Simple configuration
62 filter->SetInput( image );
63 filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) );
65 // Neighborhood function
66 typename _TSimpleNeigh::Pointer sfunc = _TSimpleNeigh::New( );
67 sfunc->SetOrder( this->m_Parameters.GetUint( "NeighborhoodOrder" ) );
68 filter->SetNeighborhoodFunction( sfunc );
72 auto pnt_seeds = this->GetInputData< vtkPolyData >( "Seeds" );
73 if( pnt_seeds != NULL )
75 typename _TImage::PointType pnt;
76 typename _TImage::IndexType idx;
78 ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
80 for( int i = 0; i < pnt_seeds->GetNumberOfPoints( ); ++i )
83 pnt_seeds->GetPoint( i, buf );
85 for( unsigned int d = 0; d < dim; ++d )
88 if( image->TransformPhysicalPointToIndex( pnt, idx ) )
89 seeds.push_back( idx );
96 #endif // __fpaPlugins_ImageAlgorithms__BaseFilter__h__