Go::BsplineBasis Class Reference
['geometry' - a spline library]

Class representing a B-spline basis of a spline space. More...

#include <BsplineBasis.h>

Inheritance diagram for Go::BsplineBasis:

Go::Streamable List of all members.

Public Member Functions

 BsplineBasis ()
 Default constructor, making an empty basis.
template<typename RandomIterator>
 BsplineBasis (int number, int order, RandomIterator knotstart)
 Constructor.
template<typename RandomIterator>
 BsplineBasis (int order, RandomIterator knotstart, RandomIterator knotend)
 Constructor.
virtual ~BsplineBasis ()
 Virtual destructor, enables safe inheritance.
template<typename RandomIterator>
void setData (int number, int order, RandomIterator knotstart)
 Change the defining data of an already-existing BsplineBasis.
void swap (BsplineBasis &other)
 Quick swap of two BsplineBasises.
virtual void read (std::istream &is)
 Read the BsplineBasis from a stream (ASCII mode).
virtual void write (std::ostream &os) const
 Write the BsplineBasis to a stream (ASCII mode).
virtual void read_bin (std::istream &is)
 Read the BsplineBasis from a stream (binary mode).
virtual void write_bin (std::ostream &os) const
 Write the BsplineBasis to a stream (binary mode).
int knotInterval (double t) const
 Find the interval in which the parameter value 't' lies.
std::vector< double > computeBasisValues (double t, int derivs=0) const
 Create a vector containing the basis values in a given parameter.
void computeBasisValues (double t, double *basisvals_start, int derivs=0, double resolution=1.0e-12) const
 Space for the basis values is allocated outside and passed in.
void computeBasisValues (const double *parvals_start, const double *parvals_end, double *basisvals_start, int *knotinter_start, int derivs=0) const
 Compute basis values for many points simultaneously.
std::vector< double > computeBasisValuesLeft (double tval, int derivs) const
 This function is similar to computeBasisValues(double, int), except that the values are calculated from the left, as opposed to the default right-evaluation.
void computeBasisValuesLeft (const double *parvals_start, const double *parvals_end, double *basisvals_start, int *knotinter_start, int derivs) const
 This function is similar to computeBasisValues(const double*, const double*, double*, int*, int), except that the values are calculated from the left, as opposed to the default right-evaluation.
void reverseParameterDirection ()
 We want the new knot vector to be a mirror image of the old one, translated so that is starts and ends in the same values as before.
void rescale (double new_start, double new_end)
 Rescales the knotvector so that parameter values lay in the specified interval.
void insertKnot (double apar)
 Insert a knot into the knotvector.
int knotIntervalFuzzy (double &t, double tol=DEFAULT_PARAMETER_EPSILON) const
 Find the interval in which a given parameter lies.
void insertKnot (const std::vector< double > &new_knots)
 Insert several knots into the knotvector.
void removeKnot (double old_knot)
 Remove a knot from the knotvector.
int lastKnotInterval () const
 Return the index of the left knot of the last knot interval accessed for some reason (evaluation, etc.
double grevilleParameter (int index) const
 Get the greville parameter starting from a certain knot.
int knotMultiplicity (const double parval) const
 If there is a knot in the knotvector with the value 'parval', its multiplicity is returned.
int endMultiplicity (bool atstart) const
 return the multiplicity of the first or the last knot
bool isKreg () const
 query whether the basis has a k-regular knotvector (start and end knot has multiplicity equal to order().
void coefsAffectingParam (double tpar, int &first_coef, int &last_coef) const
 Get the range of basis functions that are involved when evaluating at a given parameter.
int numCoefs () const
 Query the number of basis functions.
int order () const
 Query the order of the basis functions.
double startparam () const
 Query the start value of the parameter range.
double endparam () const
 Query the end value of the parameter range.
std::vector< double >::const_iterator begin () const
 Get a const-iterator to the beginning of the knotvector.
std::vector< double >::const_iterator end () const
 Get a const-iterator to the end of the knotvector.
std::vector< double >::iterator begin ()
 Get an iterator to the beginning of the knotvector.
std::vector< double >::iterator end ()
 Get an iterator to the end of the knotvector.
void check () const
 Checks the validity of the object.

Related Functions

(Note that these are not member functions.)

void computeBasisValuesLeft (double tval, double *basisvals_start, int derivs, double resolution=1.0e-12) const
 This function is similar to computeBasisValues(double, double*, int), except that the values are calculated from the left, as opposed to the default right-evaluation.

Detailed Description

Class representing a B-spline basis of a spline space.

This basis is defined by its order, its dimension (number of basis functions) and its knotvector.

Definition at line 57 of file BsplineBasis.h.


Constructor & Destructor Documentation

template<typename RandomIterator>
Go::BsplineBasis::BsplineBasis ( int  number,
int  order,
RandomIterator  knotstart 
) [inline]

Constructor.

Parameters:
number Number of basis functions in space
order order of the basis functions (polynomial degree + 1)
knotstart iterator pointing to start of defining knotvector The length of the knotvector is deduced automatically, and should be equal to 'order' + 'number'.

Definition at line 73 of file BsplineBasis.h.

References check().

template<typename RandomIterator>
Go::BsplineBasis::BsplineBasis ( int  order,
RandomIterator  knotstart,
RandomIterator  knotend 
) [inline]

Constructor.

Parameters:
order order of the basis functions (polynomial degree + 1)
knotstart iterator pointing to start of defining knotvector
knotend iterator pointing to one-past-end of defining knotvector. The number of basis functions will be deduced automatically by subtracting the 'order' from the length of the knotvector.

Definition at line 90 of file BsplineBasis.h.

References check().


Member Function Documentation

template<typename RandomIterator>
void Go::BsplineBasis::setData ( int  number,
int  order,
RandomIterator  knotstart 
) [inline]

Change the defining data of an already-existing BsplineBasis.

Parameters:
number Number of basis functions in space
order of the basis functions (polynomial degree + 1)
knotstart iterator pointing to start of defining knotvector.

Definition at line 109 of file BsplineBasis.h.

void Go::BsplineBasis::swap ( BsplineBasis other  ) 

Quick swap of two BsplineBasises.

Parameters:
other the BsplineBasis to swap with.

virtual void Go::BsplineBasis::read ( std::istream &  is  )  [virtual]

Read the BsplineBasis from a stream (ASCII mode).

Parameters:
is the stream from which the BsplineBasis is read.

Implements Go::Streamable.

virtual void Go::BsplineBasis::write ( std::ostream &  os  )  const [virtual]

Write the BsplineBasis to a stream (ASCII mode).

Parameters:
os the stream to which the BsplineBasis is written

Implements Go::Streamable.

virtual void Go::BsplineBasis::read_bin ( std::istream &  is  )  [virtual]

Read the BsplineBasis from a stream (binary mode).

Parameters:
is the stream from which the BsplineBasis is read.

virtual void Go::BsplineBasis::write_bin ( std::ostream &  os  )  const [virtual]

Write the BsplineBasis to a stream (binary mode).

Parameters:
os the stream to which the BsplineBasis is written

int Go::BsplineBasis::knotInterval ( double  t  )  const

Find the interval in which the parameter value 't' lies.

Parameters:
t the parameter value to test.

std::vector<double> Go::BsplineBasis::computeBasisValues ( double  t,
int  derivs = 0 
) const

Create a vector containing the basis values in a given parameter.

Parameters:
t the parameter at which to evaluate the basis functions
derivs the number of function derivatives to calculate for each nonzero basis function at 't'.
Returns:
a vector containing order() * ('derivs'+1) values, which are the function values and derivatives up to order 'derivs' of the nonzero basis functions at parameter value 't'. The order in which these values are stored is as follows: first all function values for the 'order' nonzero basis functions, then their first derivatives, then their second, etc..

void Go::BsplineBasis::computeBasisValues ( double  t,
double *  basisvals_start,
int  derivs = 0,
double  resolution = 1.0e-12 
) const

Space for the basis values is allocated outside and passed in.

Needed space is equal to order()*('derivs'+1) doubles.

Parameters:
t the parameter at which to evaluate the basis function
basisvals_start pointer to the memory area where the result will be written. This must be allocated by the user. The order in which the result values are written is similar to computeBasisValues(double, int)
derivs number of derivatives that should be evaluated for each nonzero basis function (derivs = 0 => only function values will be computed).
resolution accuracy for determining whether a given parametric value lies exactly 'on' a knot.

void Go::BsplineBasis::computeBasisValues ( const double *  parvals_start,
const double *  parvals_end,
double *  basisvals_start,
int *  knotinter_start,
int  derivs = 0 
) const

Compute basis values for many points simultaneously.

Parameters:
parvals_start pointer to the start of list of parameters where you want to evaluate the basis functions
parvals_end pointer to one-past-end of list of parameters where you want to evaluate the basis functions
basisvals_start pointer to range where the result of the evaluations will be written. The necessary memory is equal to 'derivs' multiplied by order() multiplied by length of parameter list, and should be allocated by user before calling the function. The order in which these values are stored is: first all values concerning the first parameter in the input range, then all values concerning the second parameter in the input range, etc. For each such parameter, the concerned values are stored in the order described in computeBasisValues(double, int)
knotinter_start pointer to range where the indexes to the parameter intervals in which the evaluated parameter values are located. ie. the index at knotinter_start[i] refer to the parameter interval where the i'th parameter in the range [parvals_start, parvals_end] is located. The total size of this range is therefore equal to (parvals_end - parvals_start), and should be allocated by the user.
derivs number of derivatives that should be evaluated for each nonzero basis function (derivs = 0 => only function values will be computed).

std::vector<double> Go::BsplineBasis::computeBasisValuesLeft ( double  tval,
int  derivs 
) const

This function is similar to computeBasisValues(double, int), except that the values are calculated from the left, as opposed to the default right-evaluation.

See also:
computeBasisValues()

void Go::BsplineBasis::rescale ( double  new_start,
double  new_end 
)

Rescales the knotvector so that parameter values lay in the specified interval.

Parameters:
new_start start of specified interval.
new_end end of specified interval.

void Go::BsplineBasis::insertKnot ( double  apar  ) 

Insert a knot into the knotvector.

Parameters:
apar parameter value of the new knot.

int Go::BsplineBasis::knotIntervalFuzzy ( double &  t,
double  tol = DEFAULT_PARAMETER_EPSILON 
) const

Find the interval in which a given parameter lies.

Parameters:
t the parameter we want to locate within an interval
tol if 't' is within DEFAULT_PARAMETER_EPSILON of an existing knot, 't' will be changed to that knot. To some callers of this function, that may be the primary wanted effect of this function.

void Go::BsplineBasis::insertKnot ( const std::vector< double > &  new_knots  ) 

Insert several knots into the knotvector.

Parameters:
new_knots a STL vector containing the new knots to insert into the vector

void Go::BsplineBasis::removeKnot ( double  old_knot  ) 

Remove a knot from the knotvector.

Parameters:
old_knot Parameter value indicating the knot to be removed. The corresponding knot is the largest one which is less than or equal to 'old_knot'.

int Go::BsplineBasis::knotMultiplicity ( const double  parval  )  const

If there is a knot in the knotvector with the value 'parval', its multiplicity is returned.

Otherwise, 0 i returned.

Parameters:
parval the parameter value for which we want to know the knot multiplicity
Returns:
the multiplicity in case the knot exists, 0 otherwise.

int Go::BsplineBasis::endMultiplicity ( bool  atstart  )  const

return the multiplicity of the first or the last knot

Parameters:
atstart if this is 'true' then the multiplicity of the first knot will be returned. Otherwise, the multiplicity of the last knot will be returned.
Returns:
the corresponding knot multiplicity

Referenced by isKreg().

bool Go::BsplineBasis::isKreg (  )  const [inline]

query whether the basis has a k-regular knotvector (start and end knot has multiplicity equal to order().

Returns:
whether this basis has a k-regular knotvector or not.

Definition at line 281 of file BsplineBasis.h.

References endMultiplicity().

void Go::BsplineBasis::coefsAffectingParam ( double  tpar,
int &  first_coef,
int &  last_coef 
) const

Get the range of basis functions that are involved when evaluating at a given parameter.

Parameters:
tpar the parameter where we want to determine the influential range
first_coef on function completion, will point to start of relevant range
last_coef on function completion, will point to end of relevant range

int Go::BsplineBasis::numCoefs (  )  const [inline]

Query the number of basis functions.

Returns:
the number of basis functions

Definition at line 296 of file BsplineBasis.h.

Referenced by Go::SplineCurve::numCoefs(), Go::SplineSurface::numCoefs_u(), Go::SplineSurface::numCoefs_v(), and Go::SplineSurface::SplineSurface().

int Go::BsplineBasis::order (  )  const [inline]

Query the order of the basis functions.

Returns:
the order of the basis functions

Definition at line 301 of file BsplineBasis.h.

Referenced by grevilleParameter(), Go::SplineCurve::order(), Go::SplineSurface::order_u(), and Go::SplineSurface::order_v().

double Go::BsplineBasis::startparam (  )  const [inline]

Query the start value of the parameter range.

Returns:
the start value of the parameter range

Definition at line 306 of file BsplineBasis.h.

double Go::BsplineBasis::endparam (  )  const [inline]

Query the end value of the parameter range.

Returns:
the end value of the parameter range

Definition at line 311 of file BsplineBasis.h.

std::vector<double>::const_iterator Go::BsplineBasis::begin (  )  const [inline]

Get a const-iterator to the beginning of the knotvector.

Returns:
an iterator to the beginning of the knotvector

Definition at line 316 of file BsplineBasis.h.

Referenced by Go::SplineCurve::knotsBegin().

std::vector<double>::const_iterator Go::BsplineBasis::end (  )  const [inline]

Get a const-iterator to the end of the knotvector.

Returns:
an iterator to the end of the knotvector

Definition at line 321 of file BsplineBasis.h.

Referenced by Go::SplineCurve::knotsEnd().

std::vector<double>::iterator Go::BsplineBasis::begin (  )  [inline]

Get an iterator to the beginning of the knotvector.

Returns:
an iterator to the beginning of the knotvector

Definition at line 326 of file BsplineBasis.h.

std::vector<double>::iterator Go::BsplineBasis::end (  )  [inline]

Get an iterator to the end of the knotvector.

Returns:
an iterator to the end of the knotvector

Definition at line 330 of file BsplineBasis.h.


Friends And Related Function Documentation

void computeBasisValuesLeft ( double  tval,
double *  basisvals_start,
int  derivs,
double  resolution = 1.0e-12 
) const [related]

This function is similar to computeBasisValues(double, double*, int), except that the values are calculated from the left, as opposed to the default right-evaluation.

Parameters:
resolution tolerance deciding whether a parameter value is situated "directly on" a knot. (In such situations, it might matter whether we evaluate from left or from left).
See also:
computeBasisValues() ()


The documentation for this class was generated from the following file:
Generated on Mon Jun 11 14:48:18 2007 for GoTools Core Library by  doxygen 1.5.1