X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FImageAlgorithms%2FBaseFilter.h;h=0b871a5f4cf06a1f0c6db17ea65446a4457791a3;hb=40fb0405cfef444001429f8ba49c407ce9168a94;hp=256888161cb38796656e05276548e2537a7ea411;hpb=91510d06bf1895f684f9f2f6508ab7d97154576d;p=FrontAlgorithms.git diff --git a/plugins/ImageAlgorithms/BaseFilter.h b/plugins/ImageAlgorithms/BaseFilter.h index 2568881..0b871a5 100644 --- a/plugins/ImageAlgorithms/BaseFilter.h +++ b/plugins/ImageAlgorithms/BaseFilter.h @@ -2,8 +2,11 @@ #define __fpaPluginsImageAlgorithms__BaseFilter__h__ #include -#include + #include +#include + +#define ITK_MANUAL_INSTANTIATION #include namespace fpaPluginsImageAlgorithms @@ -14,10 +17,10 @@ namespace fpaPluginsImageAlgorithms : public cpPlugins::Pipeline::ProcessObject { public: - typedef BaseFilter Self; + typedef BaseFilter Self; typedef cpPlugins::Pipeline::ProcessObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; public: itkTypeMacro( BaseFilter, cpPlugins::Pipeline::ProcessObject ); @@ -28,19 +31,10 @@ namespace fpaPluginsImageAlgorithms virtual ~BaseFilter( ); template< class _TFilter, class _TImage > - inline void _ConfigureFilter( _TFilter* filter, _TImage* image ); - - /* TODO - - template< class _TFilter > - inline void _ExecuteFilter( _TFilter* filter ); - - template< class _TFilter > - inline void _ConfigureDebugger( _TFilter* filter ); - - template< class _TFilter > - inline void _DeconfigureDebugger( _TFilter* filter ); - */ + inline void _ConfigureFilter( + _TFilter* filter, _TImage* image, + std::vector< typename _TImage::IndexType >& seeds + ); private: // Purposely not implemented. @@ -53,11 +47,14 @@ namespace fpaPluginsImageAlgorithms // ------------------------------------------------------------------------- template< class _TFilter, class _TImage > void fpaPluginsImageAlgorithms::BaseFilter:: -_ConfigureFilter( _TFilter* filter, _TImage* image ) +_ConfigureFilter( + _TFilter* filter, _TImage* image, + std::vector< typename _TImage::IndexType >& seeds + ) { typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood; typedef - fpa::Image::Functors::SimpleNeighborhood< typename _TImage::Superclass > + fpa::Image::Functors::SimpleNeighborhood< _TImage::ImageDimension > _TSimpleNeigh; // Simple configuration @@ -65,35 +62,30 @@ _ConfigureFilter( _TFilter* filter, _TImage* image ) filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) ); // Neighborhood function - auto neig = this->GetInputData< _TNeighborhood >( "Neighborhood" ); - if( neig == NULL ) - { - typename _TSimpleNeigh::Pointer sfunc = _TSimpleNeigh::New( ); - sfunc->SetOrder( this->m_Parameters.GetUint( "NeighborhoodOrder" ) ); - filter->SetNeighborhoodFunction( sfunc ); - } - else - filter->SetNeighborhoodFunction( neig ); + typename _TSimpleNeigh::Pointer sfunc = _TSimpleNeigh::New( ); + sfunc->SetOrder( this->m_Parameters.GetUint( "NeighborhoodOrder" ) ); + filter->SetNeighborhoodFunction( sfunc ); // Assign seeds - auto seeds = this->GetInputData< vtkPolyData >( "Seeds" ); - if( seeds != NULL ) + seeds.clear( ); + auto pnt_seeds = this->GetInputData< vtkPolyData >( "Seeds" ); + if( pnt_seeds != NULL ) { typename _TImage::PointType pnt; typename _TImage::IndexType idx; unsigned int dim = ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; - for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) + for( int i = 0; i < pnt_seeds->GetNumberOfPoints( ); ++i ) { double buf[ 3 ]; - seeds->GetPoint( i, buf ); + pnt_seeds->GetPoint( i, buf ); pnt.Fill( 0 ); for( unsigned int d = 0; d < dim; ++d ) pnt[ d ] = buf[ d ]; if( image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); + seeds.push_back( idx ); } // rof