X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FAlgorithm.h;h=9a44146ddee238464b799a7faa236554273dedd5;hb=015105c2f44abb80923a59adfb1a01713506744f;hp=e23a1084c3a585826adb7f9e54ac44bf233f6767;hpb=d3bb16bf060b7249a9ed1a49e6b118ca9394a22a;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Algorithm.h b/lib/fpa/Image/Algorithm.h index e23a108..9a44146 100644 --- a/lib/fpa/Image/Algorithm.h +++ b/lib/fpa/Image/Algorithm.h @@ -2,91 +2,19 @@ #define __FPA__IMAGE__ALGORITHM__H__ #include -#include namespace fpa { namespace Image { - namespace Functors - { - /** - */ - template< class VV, class C > - class CastVertexValueToCost - : public itk::FunctionBase< VV, C > - { - public: - // Type-related and pointers - typedef CastVertexValueToCost Self; - typedef itk::FunctionBase< VV, C > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( CastVertexValueToCost, itkFunctionBase ); - - public: - virtual C Evaluate( const VV& v ) const - { return( C( v ) ); } - - protected: - CastVertexValueToCost( ) - : Superclass( ) - { } - virtual ~CastVertexValueToCost( ) - { } - - private: - // Purposely not implemented - CastVertexValueToCost( const Self& ); - void operator=( const Self& ); - }; - - /** - */ - template< class VV, class C > - class CastVertexValueToConstantCost - : public itk::FunctionBase< VV, C > - { - public: - // Type-related and pointers - typedef CastVertexValueToConstantCost Self; - typedef itk::FunctionBase< VV, C > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( CastVertexValueToConstantCost, itkFunctionBase ); - - public: - virtual C Evaluate( const VV& v ) const - { return( C( 1 ) ); } - - protected: - CastVertexValueToConstantCost( ) - : Superclass( ) - { } - virtual ~CastVertexValueToConstantCost( ) - { } - - private: - // Purposely not implemented - CastVertexValueToConstantCost( const Self& ); - void operator=( const Self& ); - }; - - } // ecapseman - /** * A generic front propagation algorithm were vertices are image pixels. * - * @param I Input image type - * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching) + * @param I Input image type + * @param O Output image type + * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching) */ - template< class I, class A, class CC > + template< class I, class O, class A > class Algorithm : public A { @@ -98,72 +26,61 @@ namespace fpa typedef itk::SmartPointer< const Self > ConstPointer; /// Template input values - typedef I TInputImage; - typedef A TBaseAlgorithm; - typedef CC TCostConversionFunction; - - typedef typename A::TTraits TTraits; - typedef typename TTraits::TCost TCost; - typedef typename TTraits::TResult TResult; - typedef typename TTraits::TVertex TVertex; - typedef typename TTraits::TVertexValue TVertexValue; + typedef I TInputImage; + typedef O TOutputImage; - typedef itk::Image< TResult, I::ImageDimension > TOutputImage; + typedef typename Superclass::TVertex TVertex; + typedef typename Superclass::TValue TValue; + typedef typename Superclass::TResult TResult; + typedef typename Superclass::TSpace TSpace; + typedef typename Superclass::TVertexCompare TVertexCompare; + typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree; protected: - typedef typename TTraits::TFrontId _TFrontId; - typedef typename TTraits::TNode _TNode; - typedef typename TTraits::TNodes _TNodes; - - private: - typedef itk::Image< bool, I::ImageDimension > _TMarks; - typedef itk::Image< _TFrontId, I::ImageDimension > _TFrontsIds; - typedef itk::Image< TVertex, I::ImageDimension > _TParents; + 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: itkTypeMacro( Algorithm, TAlgorithm ); /// Set/Get itkGetConstMacro( NeighborhoodOrder, unsigned int ); - itkGetConstObjectMacro( CostConversion, TCostConversionFunction ); - itkGetObjectMacro( CostConversion, TCostConversionFunction ); - itkSetMacro( NeighborhoodOrder, unsigned int ); - itkSetObjectMacro( CostConversion, TCostConversionFunction ); protected: Algorithm( ); virtual ~Algorithm( ); - /// Base interface - virtual bool _UpdateResult( _TNode& n ); - - /// Pure virtual interface: vertices - virtual unsigned long _NumberOfVertices ( ) const; - virtual TVertexValue _Value ( const TVertex& v ) const; - virtual TResult _Result ( const TVertex& v ) const; - - /// Pure virtual interface: edges - virtual double _Norm ( const TVertex& a, const TVertex& b ) const; - virtual bool _Edge ( const TVertex& a, const TVertex& b ) const; - virtual TCost _Cost ( const TVertex& a, const TVertex& b ) const; - - /// Pure virtual interface: neighborhood - virtual void _Neighs ( const _TNode& n, _TNodes& N ) const; - virtual void _NeighsInDim ( const _TNode& n, - const unsigned int& d, - _TNodes& N ); - - /// Pure virtual interface: results - virtual void _InitializeResults ( ); + virtual void _BeforeGenerateData( ); + virtual void _AfterGenerateData( ); + + // Graph-related abstract methods + virtual unsigned long _NumberOfVertices( ) const; + virtual const TValue& _VertexValue( const TVertex& v ) const; + virtual double _Distance( + const TVertex& a, const TVertex& b + ) const; + virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const; + virtual void _Neighborhood( + _TVertices& neighborhood, const TVertex& v + ) const; + + // Results-related abstract methods + virtual void _InitResults( ); + virtual const TResult& _Result( const TVertex& v ) const; + virtual void _SetResult( const TVertex& v, const _TNode& n ); private: - Algorithm( const Self& ); // Not impl. - void operator=( const Self& ); // Not impl. + // Purposely not implemented + Algorithm( const Self& other ); + Self& operator=( const Self& other ); protected: - unsigned int m_NeighborhoodOrder; - typename TCostConversionFunction::Pointer m_CostConversion; + unsigned int m_NeighborhoodOrder; }; } // ecapseman