]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Functors/Dijkstra/Invert.h
...
[FrontAlgorithms.git] / lib / fpa / Functors / Dijkstra / Invert.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Functors__Dijkstra__Invert__h__
6 #define __fpa__Functors__Dijkstra__Invert__h__
7
8 #include <itkFunctionBase.h>
9
10 namespace fpa
11 {
12   namespace Functors
13   {
14     namespace Dijkstra
15     {
16       /**
17        */
18       template< class _TValue >
19       class Invert
20         : public itk::FunctionBase< _TValue, _TValue >
21       {
22       public:
23         typedef _TValue TValue;
24         typedef itk::FunctionBase< _TValue, _TValue > Superclass;
25         typedef Invert                                Self;
26         typedef itk::SmartPointer< Self >             Pointer;
27         typedef itk::SmartPointer< const Self >       ConstPointer;
28
29       public:
30         itkNewMacro( Self );
31         itkTypeMacro( fpa::Functors::Dijkstra::Invert, itk::FunctionBase );
32
33         itkGetConstMacro( Alpha, double );
34         itkSetMacro( Alpha, double );
35
36         itkGetConstMacro( Beta, double );
37         itkSetMacro( Beta, double );
38
39       public:
40         virtual TValue Evaluate( const TValue& v ) const override
41           {
42             double a = double( v );
43             double d = this->m_Alpha;
44             d += std::pow( double( a ), this->m_Beta );
45             double x = -1;
46             if( std::fabs( d ) > double( 0 ) )
47               x =
48                 double( 1 ) /
49                 ( this->m_Alpha + std::pow( double( a ), this->m_Beta ) );
50             return( TValue( x ) );
51           }
52
53       protected:
54         Invert( )
55           : Superclass( ),
56             m_Alpha( double( 1 ) ),
57             m_Beta( double( 1 ) )
58           {
59           }
60         virtual ~Invert( )
61           {
62           }
63
64       private:
65         // Purposely not implemented.
66         Invert( const Self& other );
67         Self& operator=( const Self& other );
68
69       protected:
70         double m_Alpha;
71         double m_Beta;
72       };
73
74     } // ecapseman
75
76   } // ecapseman
77
78 } // ecapseman
79
80 #endif // __fpa__Functors__Dijkstra__Invert__h__
81 // eof - $RCSfile$