]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/RegionGrow.h
Major refactoring
[FrontAlgorithms.git] / lib / fpa / Image / RegionGrow.h
index b12a869d87ccdca57610f351da531a9b71e30bc0..e20f062e07cf6c2563da1533437ed969bb2f4207 100644 (file)
@@ -1,11 +1,10 @@
 #ifndef __FPA__IMAGE__REGIONGROW__H__
 #define __FPA__IMAGE__REGIONGROW__H__
 
+#include <itkFunctionBase.h>
 #include <itkImageToImageFilter.h>
-#include <itkIndex.h>
 #include <fpa/Base/RegionGrow.h>
 #include <fpa/Image/Algorithm.h>
-#include <fpa/Image/Functors/ImageFunction.h>
 
 namespace fpa
 {
@@ -13,64 +12,55 @@ namespace fpa
   {
     /**
      * @param I Input image type
+     * @param O Output image type
      */
-    template< class I, class O = I, class CC = fpa::Image::Functors::CastVertexValueToCost< typename I::PixelType, typename O::PixelType > >
+    template< class I, class O >
     class RegionGrow
-      : public Algorithm< I, fpa::Base::RegionGrow< typename I::IndexType, typename O::PixelType, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, O > >, CC >
+      : public Algorithm< I, O, fpa::Base::RegionGrow< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::ImageToImageFilter< I, O > > >
     {
     public:
-      // Standard class typdedefs
-      typedef typename I::IndexType TVertex;
-      typedef typename O::PixelType TResult;
-      typedef typename I::PixelType TVertexValue;
-      typedef itk::ImageToImageFilter< I, O > TBaseFilter;
-      typedef fpa::Base::RegionGrow< TVertex, TResult, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm;
-
-      typedef RegionGrow                         Self;
-      typedef Algorithm< I, TBaseAlgorithm, CC > Superclass;
-      typedef itk::SmartPointer< Self >          Pointer;
-      typedef itk::SmartPointer< const Self >    ConstPointer;
-
-      typedef
-      fpa::Image::Functors::ImageFunction< I, bool >
-      TMembershipFunction;
+      typedef fpa::Base::RegionGrow< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::ImageToImageFilter< I, O > > TBaseAlgorithm;
+
+      typedef RegionGrow                        Self;
+      typedef Algorithm< I, O, TBaseAlgorithm > Superclass;
+      typedef itk::SmartPointer< Self >         Pointer;
+      typedef itk::SmartPointer< const Self >   ConstPointer;
+
+      typedef typename Superclass::TInputImage  TInputImage;
+      typedef typename Superclass::TOutputImage TOutputImage;
+      typedef typename Superclass::TVertex      TVertex;
+      typedef typename Superclass::TValue       TValue;
+      typedef typename Superclass::TResult      TResult;
+
+      typedef itk::FunctionBase< TValue, bool > TMembershipFunction;
+
+    protected:
+      typedef typename Superclass::_TVertices      _TVertices;
+      typedef typename Superclass::_TCollision     _TCollision;
+      typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
+      typedef typename Superclass::_TCollisions    _TCollisions;
+      typedef typename Superclass::_TNode          _TNode;
+      typedef typename Superclass::_TNodes         _TNodes;
 
     public:
       itkNewMacro( Self );
-      itkTypeMacro( RegionGrow, fpaBaseRegionGrow );
+      itkTypeMacro( RegionGrow, Algorithm );
 
       itkGetObjectMacro( MembershipFunction, TMembershipFunction );
+      itkGetConstObjectMacro( MembershipFunction, TMembershipFunction );
       itkSetObjectMacro( MembershipFunction, TMembershipFunction );
 
     protected:
-      RegionGrow( )
-        : Superclass( ),
-          m_MembershipFunction( NULL )
-        { }
-      virtual ~RegionGrow( )
-        { }
-
-      virtual bool _CheckMembership(
-        const typename Superclass::_TNode& n
-        ) const
-        {
-          if( this->m_MembershipFunction.IsNotNull( ) )
-          {
-            if(
-              this->m_MembershipFunction->GetInputImage( ) !=
-              this->GetInput( )
-              )
-              this->m_MembershipFunction->SetInputImage( this->GetInput( ) );
-            return( this->m_MembershipFunction->Evaluate( n.Vertex ) );
-          }
-          else
-            return( false );
-        }
+      RegionGrow( );
+      virtual ~RegionGrow( );
+
+      virtual bool _CheckMembership( const TVertex& v ) const;
+      virtual void _InitResults( );
 
     private:
       // Purposely not implemented
-      RegionGrow( const Self& );
-      void operator=( const Self& );
+      RegionGrow( const Self& other );
+      Self& operator=( const Self& other );
 
     protected:
       typename TMembershipFunction::Pointer m_MembershipFunction;
@@ -80,6 +70,8 @@ namespace fpa
 
 } // ecapseman
 
+#include <fpa/Image/RegionGrow.hxx>
+
 #endif // __FPA__IMAGE__REGIONGROW__H__
 
 // eof - $RCSfile$