]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Dijkstra.h
...
[FrontAlgorithms.git] / lib / fpa / Image / Dijkstra.h
index 1df0836a985668ee3f0f526144b63d80f8e2d7f8..4262f7f4b9d8e903d5c017fe64b1b59fb306c31b 100644 (file)
@@ -7,11 +7,12 @@
 #define __fpa__Image__Dijkstra__h__
 
 #include <fpa/Base/Dijkstra.h>
+#include <fpa/Base/MarksInterfaceWithCollisions.h>
 #include <fpa/Base/SeedsInterface.h>
-#include <fpa/Image/MarksInterface.h>
-#include <fpa/Image/Filter.h>
+#include <fpa/Image/Algorithm.h>
+#include <fpa/Image/DefaultTraits.h>
 #include <fpa/Image/MinimumSpanningTree.h>
-#include <fpa/Image/Functors/VertexParentBase.h>
+#include <fpa/Image/Functors/Dijkstra/Function.h>
 
 namespace fpa
 {
@@ -19,64 +20,41 @@ namespace fpa
   {
     /**
      */
-    template< class _TInputImage, class _TOutputImage >
+    template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char, class _TTraits = fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, _TFrontId > >
     class Dijkstra
-      : public fpa::Base::Dijkstra< fpa::Image::Filter< _TInputImage, _TOutputImage >, fpa::Image::MarksInterface< _TInputImage::ImageDimension >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
+      : public fpa::Base::Dijkstra< fpa::Image::Algorithm< _TTraits, fpa::Base::MarksInterfaceWithCollisions< _TTraits >, fpa::Base::SeedsInterface< _TTraits > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
     {
     public:
-      // Interfaces
-      typedef fpa::Image::Filter< _TInputImage, _TOutputImage > TFilter;
-      typedef fpa::Image::MarksInterface< _TInputImage::ImageDimension > TMarksInterface;
-      typedef fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > TSeedsInterface;
+      typedef _TInputImage  TInputImage;
+      typedef _TOutputImage TOutputImage;
+      typedef _TTraits      TTraits;
+      typedef fpa::Base::MarksInterfaceWithCollisions< TTraits > TMarksInterface;
+      typedef fpa::Base::SeedsInterface< TTraits > TSeedsInterface;
       typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST;
 
-      // Smart pointers
-      typedef Dijkstra Self;
-      typedef fpa::Base::Dijkstra< TFilter, TMarksInterface, TSeedsInterface, TMST > Superclass;
-      typedef itk::SmartPointer< Self > Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef fpa::Image::Algorithm< TTraits, TMarksInterface, TSeedsInterface > TAlgorithm;
+      typedef fpa::Base::Dijkstra< TAlgorithm, TMST > Superclass;
+      typedef Dijkstra                                Self;
+      typedef itk::SmartPointer< Self >               Pointer;
+      typedef itk::SmartPointer< const Self >         ConstPointer;
 
-      typedef typename TFilter::TInputImage TInputImage;
-      typedef typename TFilter::TOutputValue TOutputValue;
-      typedef typename TFilter::TVertex TVertex;
+      fpa_Base_TraitTypes( typename TTraits );
+
+      typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction;
 
     public:
       itkNewMacro( Self );
       itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
 
     protected:
-      Dijkstra( ) : Superclass( ) { }
-      virtual ~Dijkstra( )        { }
-
-      virtual void _ConfigureOutputs( const TOutputValue& init_value ) override
-        {
-          this->Superclass::_ConfigureOutputs( init_value );
-
-          typename TVertex::OffsetType o;
-          o.Fill( 0 );
-          const TInputImage* input = this->GetInput( );
-          TMST* mst = this->GetMinimumSpanningTree( );
-          mst->CopyInformation( input );
-          mst->SetBufferedRegion( input->GetRequestedRegion( ) );
-          mst->Allocate( );
-          mst->FillBuffer( o );
-        }
+      Dijkstra( );
+      virtual ~Dijkstra( );
 
-      virtual void GenerateData( ) override
-        {
-          // Configure functors with input image
-          typedef typename TFilter::TOutputValue _TOutputValue;
-          typedef fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue > _TVFunc;
-          _TVFunc* vfunc =
-            dynamic_cast< _TVFunc* >( this->m_VertexFunctor.GetPointer( ) );
-          if( vfunc != NULL )
-            vfunc->SetImage( this->GetInput( ) );
-
-          // Ok, continue
-          this->Superclass::GenerateData( );
-        }
+      virtual void _BeforeGenerateData( ) override;
+      virtual void _ConfigureOutput( const TOutputValue& v ) override;
 
     private:
+      // Purposely not implemented.
       Dijkstra( const Self& other );
       Self& operator=( const Self& other );
     };
@@ -85,6 +63,10 @@ namespace fpa
 
 } // ecapseman
 
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Image/Dijkstra.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
 #endif // __fpa__Image__Dijkstra__h__
 
 // eof - $RCSfile$