]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/curve.hxx
f91e66c19c6f4549d396a5adf8e542fb39eee10b
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / curve.hxx
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: curve.hxx,v $
5   Language:  C++
6   Date:      $Date: 2010/04/20 16:11:41 $
7   Version:   $Revision: 1.2 $
8
9   Copyright: (c) 2002, 2003
10   License:
11   
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notice for more information.
15
16 =========================================================================*/
17
18 #ifndef KGFO__CURVE__HXX
19 #define KGFO__CURVE__HXX
20
21 #include <vector>
22 #include "marTypes.h"
23
24 /*! \brief Parametrized n-dimensional curve.
25  *
26  *  This class realizes a parametric curve model, given some control points.
27  */
28 class MAR_KERNEL_EXPORT kCurve
29 {
30     public:
31
32     kCurve( size_t dim = 3, size_t sdim = 0 );
33     ~kCurve( );
34
35     kCurve& operator=( const kCurve& r );
36
37     uint32_t getDimension( ) const
38     {
39       return( _dimension );
40     }
41
42     uint32_t getStateDimension( ) const
43     {
44       return( _stateDim );
45     }
46
47     uint32_t getClosestControlPoint( double* p );
48
49     void getPoint( double* p, double s );
50     void getState( double* st, double s );
51     void getTangent( double* tg, double s );
52     void getNormal( double* n, double s );
53     void getBinormal( double* b, double s );
54
55     void addControlPoint( double* cp, double* sp );
56     void getControlPoint( int i, double* cp, double* sp );
57     void setControlPoint( int i, double* cp, double* sp );
58     uint32_t getNumberOfControlPoints( )
59     {
60       return( _controlPoints.size( ) );
61     }
62
63     double length( double step = 0.01 );
64
65     double projectOverControlPoints( double* pr, double* pt );
66     double projectOverCurve( double* pr, double* pt );
67
68     void evaluate( double* p, int i, double t );
69     void evalState( double* s, int i, double t );
70
71     void derivative1( double* d, int i, double t );
72     void derivative2( double* d, int i, double t );
73
74     void reset( );
75
76     public:
77
78     static int MAX_DIMENSION;
79     static int MAX_STATE_DIMENSION;
80
81     protected:
82     
83     std::vector< double* > _controlPoints;
84     std::vector< double* > _controlState;
85     uint32_t _dimension;
86     uint32_t _stateDim;
87
88     private:
89
90     void loadCatmullControlMatrix( int i );
91     void loadCatmullStateMatrix( int i );
92     void calculeSplineArguments( double s, int& i, double& t );
93
94     std::vector< double > _controlT;
95     std::vector< double > _controlL;
96
97     double* _mC;
98     double* _mS;
99
100 };
101
102 #endif // KGFO__CURVE__HXX
103
104 // eof - curve.hxx