]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Dijkstra.h
...
[FrontAlgorithms.git] / lib / fpa / Image / Dijkstra.h
index d5a1bb9e6f2026b9038dcbda532aaea24dbbe9c7..4262f7f4b9d8e903d5c017fe64b1b59fb306c31b 100644 (file)
@@ -10,8 +10,9 @@
 #include <fpa/Base/MarksInterfaceWithCollisions.h>
 #include <fpa/Base/SeedsInterface.h>
 #include <fpa/Image/Algorithm.h>
+#include <fpa/Image/DefaultTraits.h>
 #include <fpa/Image/MinimumSpanningTree.h>
-#include <fpa/Image/Functors/Dijkstra/Identity.h>
+#include <fpa/Image/Functors/Dijkstra/Function.h>
 
 namespace fpa
 {
@@ -19,30 +20,26 @@ namespace fpa
   {
     /**
      */
-    template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
+    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::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, 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:
       typedef _TInputImage  TInputImage;
       typedef _TOutputImage TOutputImage;
-      typedef _TFrontId     TFrontId;
+      typedef _TTraits      TTraits;
+      typedef fpa::Base::MarksInterfaceWithCollisions< TTraits > TMarksInterface;
+      typedef fpa::Base::SeedsInterface< TTraits > TSeedsInterface;
+      typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST;
 
-      typedef typename TInputImage::IndexType        TVertex;
-      typedef typename TVertex::LexicographicCompare TVertexCompare;
-      typedef typename TInputImage::PixelType        TInputValue;
-      typedef typename TOutputImage::PixelType       TOutputValue;
-
-      typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
-      typedef fpa::Base::SeedsInterface< TVertex, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
-      typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
-      typedef fpa::Image::MinimumSpanningTree< TInputImage::ImageDimension > TMST;
-
-      typedef Dijkstra                                Self;
+      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;
 
+      fpa_Base_TraitTypes( typename TTraits );
+
       typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction;
 
     public:
@@ -50,43 +47,11 @@ namespace fpa
       itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
 
     protected:
-      Dijkstra( )
-        : Superclass( )
-        {
-          typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TOutputValue > _TDefaultFunction;
-          this->SetWeightFunction( _TDefaultFunction::New( ) );
-        }
-      virtual ~Dijkstra( )
-        {
-        }
+      Dijkstra( );
+      virtual ~Dijkstra( );
 
-      virtual void _ConfigureOutput( const TOutputValue& v ) override
-        {
-          this->Superclass::_ConfigureOutput( v );
-          const TInputImage* in = this->GetInput( );
-
-          TMST* mst = this->GetMinimumSpanningTree( );
-          mst->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
-          mst->SetRequestedRegion( in->GetRequestedRegion( ) );
-          mst->SetBufferedRegion( in->GetBufferedRegion( ) );
-          mst->SetSpacing( in->GetSpacing( ) );
-          mst->SetOrigin( in->GetOrigin( ) );
-          mst->SetDirection( in->GetDirection( ) );
-          mst->Allocate( );
-
-          typename TMST::PixelType zero;
-          zero.Fill( 0 );
-          mst->FillBuffer( zero );
-        }
-
-      virtual void _BeforeGenerateData( ) override
-        {
-          this->Superclass::_BeforeGenerateData( );
-          TWeightFunction* wf =
-            dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) );
-          if( wf != NULL )
-            wf->SetImage( this->GetInput( ) );
-        }
+      virtual void _BeforeGenerateData( ) override;
+      virtual void _ConfigureOutput( const TOutputValue& v ) override;
 
     private:
       // Purposely not implemented.
@@ -98,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$