34 #ifndef __INCLUDE_BSPLINE__
35 #define __INCLUDE_BSPLINE__
37 #ifndef __INCLUDE_MIST_CONF_H__
63 static double Base(
const std::vector< double > &knot, std::vector< double >::size_type i,
double t )
67 if( knot[ i + K - 1 ] - knot[ i ] != 0 )
72 if( knot[ i + K ] - knot[ i + 1 ] != 0 )
96 static double Base(
const std::vector< double > &knot, std::vector< double >::size_type i,
double t )
98 return( ( knot[ i ] <= t && t < knot[ i + 1 ] ) ? 1.0 : 0.0 );
153 template <
class T,
int K,
class Allocator = std::allocator< T > >
154 class bspline :
public std::vector< T, Allocator >
157 typedef std::vector< T, Allocator > base;
158 typedef typename base::allocator_type allocator_type;
159 typedef typename base::reference reference;
160 typedef typename base::const_reference const_reference;
161 typedef typename base::value_type value_type;
162 typedef typename base::size_type size_type;
163 typedef typename base::difference_type difference_type;
164 typedef typename base::pointer pointer;
165 typedef typename base::const_pointer const_pointer;
167 typedef std::vector< double > knot_list;
191 value_type operator( )(
double t )
193 size_type n = base::size( ) - 1;
195 if( knot_.size( ) < m + 1 )
200 else if( base::empty( ) )
202 return( value_type( 0 ) );
205 t *=
static_cast< double >( m - 2 * K + 2 );
208 value_type p = value_type( base::operator[]( 0 ) ) * 0;
209 for( size_type i = 0 ; i < base::size( ) ; i++ )
212 p += B * base::operator[]( i );
224 void knot(
const knot_list &kknot )
237 size_type n = base::size( ) - 1;
241 knot_list kknot( m + 1 );
246 for( i = 0 ; i <= m ; i++ )
248 kknot[ i ] =
static_cast< double >( i - K + 1 );
254 for( i = 0 ; i < K ; i++ )
258 for( i = K ; i < m - K + 1 ; i++ )
260 kknot[ i ] =
static_cast< double >( i - K + 1 );
262 for( i = m - K + 1 ; i <= m ; i++ )
264 kknot[ i ] =
static_cast< double >( 2 + m - 2 * K );
277 base::operator =( b );
310 #endif // __INCLUDE_BSPLINE__