2
// Copyright � 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
\brief Declares the CqSplineCubic class for generic spline functionality.
23
\author Paul C. Gregory (pgregory@aqsis.com)
26
//? Is .h included already?
27
#ifndef SPLINE_H_INCLUDED
28
#define SPLINE_H_INCLUDED 1
38
START_NAMESPACE( Aqsis )
41
typedef TqFloat __Basis[ 4 ][ 4 ];
43
extern __Basis gBezierBasis;
44
extern __Basis gBSplineBasis;
45
extern __Basis gCatmullRomBasis;
46
extern __Basis gHermiteBasis;
47
extern __Basis gPowerBasis;
50
//----------------------------------------------------------------------
51
/** \class CqSplineCubic
58
CqSplineCubic( TqInt cu = 4 );
59
virtual ~CqSplineCubic()
62
virtual CqVector4D Evaluate( TqFloat t ) const;
63
virtual void InitFD( TqInt n );
64
virtual CqVector4D EvaluateFD();
65
virtual TqInt cSections() const;
67
/** Get a reference to the array of control points.
69
std::vector<CqVector4D>& aControlPoints()
71
return ( m_aControlPoints );
73
/** Get a reference to the cubic spline basis matrix.
77
return ( m_matBasis );
79
/** Set the cubic spline basis matrix.
80
* \param mat Basis matrix.
82
void SetmatBasis( CqMatrix& mat )
86
/** Set the cubic spline basis matrix.
87
* \param strName Basis name.
89
void SetmatBasis( const CqString& strName )
92
if ( strName.compare( "bezier" ) == 0 )
93
pVals = &gBezierBasis;
94
else if ( strName.compare( "bspline" ) == 0 )
95
pVals = &gBSplineBasis;
96
else if ( strName.compare( "catmull-rom" ) == 0 )
97
pVals = &gCatmullRomBasis;
98
else if ( strName.compare( "hermite" ) == 0 )
99
pVals = &gHermiteBasis;
100
else if ( strName.compare( "power" ) == 0 )
101
pVals = &gPowerBasis;
109
// for ( i = 0; i < 4; i++ )
110
// for ( j = 0; j < 4; j++ )
111
// ( *b ) [ i ][ j ] = ( *pVals ) [ i ][ j ];
115
/** Get the control point step size for the evaluation window.
116
* \return Integer step size.
122
/** Set the control point step size for the evaluation window.
123
* \param Step Integer step size.
125
void SetStep( const TqInt Step )
130
/** Indexed access to the control points.
131
* \param i Integer index.
133
CqVector4D& operator[] ( TqInt i )
135
assert( i<m_cu ); return ( m_aControlPoints[ i ] );
137
/** Indexed access to the control points.
138
* \param i Integer index.
140
const CqVector4D& operator[] ( TqInt i ) const
142
assert( i<m_cu ); return ( m_aControlPoints[ i ] );
146
CqMatrix m_matBasis; ///< Basis matrix.
147
TqInt m_Step; ///< Evaluation window step size.
148
TqInt m_cu; ///< Number of control points.
149
std::vector<CqVector4D> m_aControlPoints; ///< Array of 4D control points.
151
CqVector4D m_vecFDPoint; ///< Forward difference evaluation parameters.
152
CqVector4D m_vecFDDelta; ///< Forward difference evaluation parameters.
153
CqVector4D m_vecFDDelta2; ///< Forward difference evaluation parameters.
154
CqVector4D m_vecFDDelta3; ///< Forward difference evaluation parameters.
159
//-----------------------------------------------------------------------
161
END_NAMESPACE( Aqsis )
163
#endif // !SPLINE_H_INCLUDED