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