]> Creatis software - FrontAlgorithms.git/blobdiff - plugins/ImageAlgorithms/BaseFilter.h
...
[FrontAlgorithms.git] / plugins / ImageAlgorithms / BaseFilter.h
index 256888161cb38796656e05276548e2537a7ea411..0b871a5f4cf06a1f0c6db17ea65446a4457791a3 100644 (file)
@@ -2,8 +2,11 @@
 #define __fpaPluginsImageAlgorithms__BaseFilter__h__
 
 #include <fpaPluginsImageAlgorithms_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
+
 #include <vtkPolyData.h>
+#include <cpPlugins/Pipeline/ProcessObject.h>
+
+#define ITK_MANUAL_INSTANTIATION
 #include <fpa/Image/Functors/SimpleNeighborhood.h>
 
 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