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