]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Extensions/Algorithms/BezierCurveFunction.h
641220cf22abbb3bc3e84f34b0d1b2293bdbb1bc
[cpPlugins.git] / lib / cpPlugins / Extensions / Algorithms / BezierCurveFunction.h
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__
6 #define __CPPLUGINS__EXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__
7
8 #include <vector>
9 #include <itkFunctionBase.h>
10 #include <itkMatrix.h>
11
12 namespace cpPlugins
13 {
14   namespace Extensions
15   {
16     namespace Algorithms
17     {
18       /**
19        * Uses the De Casteljau's algorithm.
20        */
21       template< class V >
22       class BezierCurveFunction
23         : public itk::FunctionBase< typename V::ValueType, V >
24       {
25       public:
26         typedef BezierCurveFunction                           Self;
27         typedef itk::FunctionBase< typename V::ValueType, V > Superclass;
28         typedef itk::SmartPointer< Self >                     Pointer;
29         typedef itk::SmartPointer< const Self >               ConstPointer;
30
31         typedef V                     TVector;
32         typedef typename V::ValueType TScalar;
33
34         typedef
35         itk::Matrix< TScalar, TVector::Dimension, TVector::Dimension >
36         TFrame; 
37         typedef std::vector< TVector > TVectorsContainer;
38
39       public:
40         itkNewMacro( Self );
41         itkTypeMacro( BezierCurveFunction, itkFunctionBase );
42
43       public:
44         virtual void AddPoint( const TVector& v );
45         virtual unsigned int GetNumberOfPoints( ) const;
46
47         virtual TVector Evaluate( const TScalar& u ) const;
48         virtual TFrame EvaluateFrenetFrame( const TScalar& u ) const;
49         virtual TScalar EvaluateLength( ) const;
50
51       protected:
52         BezierCurveFunction( );
53         virtual ~BezierCurveFunction( ) { }
54
55         void _UpdateDerivative( ) const;
56
57       private:
58         // Purposely not implemented
59         BezierCurveFunction( const Self& other );
60         Self& operator=( const Self& other );
61
62       protected:
63         TVectorsContainer m_Vectors;
64         mutable Pointer   m_Derivative;
65         mutable bool      m_DerivativeUpdated;
66       };
67
68     } // ecapseman
69
70   } // ecapseman
71
72 } // ecapseman
73
74 #include <cpPlugins/Extensions/Algorithms/BezierCurveFunction.hxx>
75
76 #endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__
77
78 // eof - $RCSfile$