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

SplineCurve provides methodes for storing, reading and manipulating rational and non-rational B-spline curves. More...

#include <SplineCurve.h>

Inheritance diagram for Go::SplineCurve:

Go::ParamCurve Go::GeomObject Go::Streamable List of all members.

Public Member Functions

 SplineCurve ()
 Creates an uninitialized SplineCurve, which can only be assigned to or read() into.
template<typename RandomIterator1, typename RandomIterator2>
 SplineCurve (int number, int order, RandomIterator1 knotstart, RandomIterator2 coefsstart, int dim, bool rational=false)
 Create a SplineCurve by explicitly providing all spline-related information.
 SplineCurve (const Point &pnt1, const Point &pnt2)
 Construct a straight curve between two points (order 2 - linear).
 SplineCurve (const Point &pnt1, double startpar, const Point &pnt2, double endpar)
 Make a straight curve between two points (order 2 - linear).
virtual ~SplineCurve ()
 Virtual destructor, enables safe inheritance.
virtual void read (std::istream &is)
 read object from stream
virtual void write (std::ostream &os) const
 write object to stream
virtual BoundingBox boundingBox () const
 Return the object's bounding box.
virtual int dimension () const
 Return the dimension of the space in which the object lies (usually 2 or 3).
virtual ClassType instanceType () const
 Return the class type identifier of a given, derived instance of GeomObject.
virtual SplineCurveclone () const
 The clone-function is herited from GeomObject, but overridden here to get a covariant return type (for those compilers that allow this).
virtual void point (Point &pt, double tpar) const
 Evaluate the curve's position at a given parameter.
virtual void point (std::vector< Point > &pts, double tpar, int derivs, bool from_right=true) const
 Evaluate the curve's position and a certain number of derivatives at a given parameter.
virtual double startparam () const
 Query the start parameter of the curve.
virtual double endparam () const
 Query the end parameter of the curve.
virtual void reverseParameterDirection (bool switchparam=false)
 Set the parameter direction of the curve.
virtual SplineCurvegeometryCurve ()
 If the definition of this ParamCurve contains a SplineCurve describing its spatial shape, then this function will return a pointer to this SplineCurve.
virtual DirectionCone directionCone () const
 Creates a DirectionCone which covers all tangent directions of this curve.
virtual CompositeBox compositeBox () const
 Creates a composite box enclosing the curve.
virtual bool isDegenerate (double degenerate_epsilon)
 Query whether the curve is degenerate (collapsed into a single point).
SplineCurvederivCurve (int ider) const
 Make a curve expressing the i'th derivative of 'this' curve, and return a pointer to it.
virtual SplineCurvesubCurve (double from_par, double to_par, double fuzzy=DEFAULT_PARAMETER_EPSILON) const
 Returns a curve which is a part of this curve.
virtual void closestPoint (const Point &pt, double tmin, double tmax, double &clo_t, Point &clo_pt, double &clo_dist, double const *seed=0) const
 Compute the closest point from an interval of this curve to a specified point.
virtual void appendCurve (ParamCurve *other_curve, int continuity, double &dist, bool repar=true)
 Inherited from ParamCurve.
virtual void appendCurve (ParamCurve *cv, bool repar=true)
 Inherited from ParamCurve.
const BsplineBasisbasis () const
 Get a const reference to the BsplineBasis of the curve.
BsplineBasisbasis ()
 Get a reference to the BsplineBasis of the curve.
int numCoefs () const
 Query the number of control points of the curve.
int order () const
 Query the order of the spline space in which the curve lies.
bool rational () const
 Query whether or not the curve is rational.
std::vector< double >::iterator knotsBegin ()
 Get an iterator to the beginning of the knot vector.
std::vector< double >::iterator knotsEnd ()
 Get a one-past-end iterator to the knot vector.
std::vector< double >::const_iterator knotsBegin () const
 Get a const iterator to the beginning of the knot vector.
std::vector< double >::const_iterator knotsEnd () const
 Get a one-past-end const iterator to the knot vector.
std::vector< double >::iterator coefs_begin ()
 Get an iterator to the start of the curve's internal, non-rational control point array.
std::vector< double >::iterator coefs_end ()
 Get a one-past-end iterator to the curve's non-rational, internal control point array.
std::vector< double >::const_iterator coefs_begin () const
 Get a const iterator to the start of the curve's non-rational, internal control point array.
std::vector< double >::const_iterator coefs_end () const
 Get a one-past-end const iterator to the curve's non-rational, internal control point array.
std::vector< double >::iterator rcoefs_begin ()
 Get an iterator to the start of the curve's internal, rational control point array.
std::vector< double >::iterator rcoefs_end ()
 Get a one-past-end iterator to the curve's rational, internal control point array.
std::vector< double >::const_iterator rcoefs_begin () const
 Get a const iterator to the start of the curve's rational, internal control point array.
std::vector< double >::const_iterator rcoefs_end () const
 Get a one-past-end const iterator to the curve's rational, internal control point array.
void interpolate (Interpolator &interpolator, int num_points, int dim, const double *param_start, const double *data_start)
 Remake 'this' SplineCurve to interpolate (or approximate) a given sequence of data points.
void insertKnot (double apar)
 Insert a new knot into the curve's knotvector.
void insertKnot (const std::vector< double > &new_knots)
 Insert several knots into the curve's knotvector.
void makeBernsteinKnots ()
 Insert knots into the knotvector such that all knots get multiplicity equal to the order of the b-spline basis.
void setParameterInterval (double t1, double t2)
 Rescale the knotvector so that the total parameter span now ranges from 't1' to 't2'.
void removeKnot (double tpar)
 Remove a knot from the knotvector.
void raiseOrder (int i=1)
 Raise the order of the curve's b-spline basis without changing the shape of the curve.
void makeKnotStartRegular ()
 Make the knotvector k-regular at start.
void makeKnotEndRegular ()
 Make the knotvector k-regular at end.
void swap (SplineCurve &other)
 quick swap of 'this' SplineCurve with the 'other' one.
virtual double nextSegmentVal (double par, bool forward, double tol) const
 Inherited from ParamCurve.

Static Public Member Functions

static ClassType classType ()
 Return the class type identifier of a given class derived from GeomObject.

Detailed Description

SplineCurve provides methodes for storing, reading and manipulating rational and non-rational B-spline curves.

Definition at line 52 of file SplineCurve.h.


Constructor & Destructor Documentation

template<typename RandomIterator1, typename RandomIterator2>
Go::SplineCurve::SplineCurve ( int  number,
int  order,
RandomIterator1  knotstart,
RandomIterator2  coefsstart,
int  dim,
bool  rational = false 
) [inline]

Create a SplineCurve by explicitly providing all spline-related information.

Parameters:
number number of control points
order order of b-spline basis
knotstart pointer to the array describing the knotvector
coefsstart pointer to the array where the control points are consecutively stored.
dim dimension of the space in which the curve lies (usually 2 or 3).
rational Specify whether the curve is rational or not. If the curve is rational, coefficients must be in the following format: wP1 wP2 .... wPdim w. I.e., a (dim+1)-dimensional form. (This is the same form that is used within SISL).

Definition at line 76 of file SplineCurve.h.

References rational().

Go::SplineCurve::SplineCurve ( const Point pnt1,
const Point pnt2 
)

Construct a straight curve between two points (order 2 - linear).

The parameter span will be from 0 to T, where T is the euclidean distance between the two points.

Parameters:
pnt1 first of the two points defining the straight curve
pnt2 second of the two points defining the straight curve

Go::SplineCurve::SplineCurve ( const Point pnt1,
double  startpar,
const Point pnt2,
double  endpar 
)

Make a straight curve between two points (order 2 - linear).

The parameter span is also given by the user.

Parameters:
pnt1 first of the two points defining the straight curve
startpar start parameter of curve
pnt2 second of the two points defining the straight curve
endpar end parameter of curve


Member Function Documentation

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

read object from stream

Parameters:
is stream from which object is read

Implements Go::Streamable.

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

write object to stream

Parameters:
os stream to which object is written

Implements Go::Streamable.

virtual void Go::SplineCurve::point ( Point pt,
double  tpar 
) const [virtual]

Evaluate the curve's position at a given parameter.

Parameters:
pt the evaluated position will be written to this Point
tpar the parameter for which we wish to evaluate the curve

Implements Go::ParamCurve.

virtual void Go::SplineCurve::point ( std::vector< Point > &  pts,
double  tpar,
int  derivs,
bool  from_right = true 
) const [virtual]

Evaluate the curve's position and a certain number of derivatives at a given parameter.

Parameters:
pts the evaluated position and derivatives (tangent, curvature vector, etc.) will be written to this vector. The first entry will be the position, the second entry will be the first derivative, etc. The size of this vector must be set to 'derivs'+ 1 prior to calling this function.
tpar the parameter for which we want to evaluate the curve
derivs the number of derivatives we want to have calculated
from_right specify whether we should calculate derivatives 'from the right' or 'from the left' (default is from the right). This matters only when the curve presents discontinuities in its derivatives.

Implements Go::ParamCurve.

virtual double Go::SplineCurve::startparam (  )  const [virtual]

Query the start parameter of the curve.

Returns:
the curve's start parameter

Implements Go::ParamCurve.

virtual double Go::SplineCurve::endparam (  )  const [virtual]

Query the end parameter of the curve.

Returns:
the curve's end parameter

Implements Go::ParamCurve.

virtual void Go::SplineCurve::reverseParameterDirection ( bool  switchparam = false  )  [virtual]

Set the parameter direction of the curve.

The curve's parameter interval will always remain constant, but by flipping the parameter direction, the curve will be traced the opposite way when moving a parameter over the parameter interval.

Parameters:
switchparam if true, and the curve is 2D, the x and y coordinates should be swapped. This is used when turning the orientation of bounded (trimmed) surfaces.

Implements Go::ParamCurve.

virtual SplineCurve* Go::SplineCurve::geometryCurve (  )  [virtual]

If the definition of this ParamCurve contains a SplineCurve describing its spatial shape, then this function will return a pointer to this SplineCurve.

Otherwise it will return a null pointer.

Returns:
a pointer to the internal SplineCurve, if it exists. Null pointer otherwise.

Implements Go::ParamCurve.

virtual DirectionCone Go::SplineCurve::directionCone (  )  const [virtual]

Creates a DirectionCone which covers all tangent directions of this curve.

Returns:
the smallest DirectionCone containing all tangent directions of this curve.

Implements Go::ParamCurve.

virtual CompositeBox Go::SplineCurve::compositeBox (  )  const [virtual]

Creates a composite box enclosing the curve.

The composite box consists of an inner and an edge box. The inner box is supposed to be made from the interior of the curve, while the edge box is made from the start and end points. The default implementation simply makes both boxes identical to the regular bounding box.

Returns:
the CompositeBox enclosing the curve.

Reimplemented from Go::ParamCurve.

virtual bool Go::SplineCurve::isDegenerate ( double  degenerate_epsilon  )  [virtual]

Query whether the curve is degenerate (collapsed into a single point).

Parameters:
degenerate_epsilon the tolerance used in determine whether the curve is degenerate. A curve is considered degenerate if its total length is shorter than this value.
Returns:
'true' if the curve is degenerate, 'false' otherwise.

Implements Go::ParamCurve.

SplineCurve* Go::SplineCurve::derivCurve ( int  ider  )  const

Make a curve expressing the i'th derivative of 'this' curve, and return a pointer to it.

Parameters:
ider the number of the derivative of which we want to make a curve
Returns:
a pointer to the newly generated curve. User assumes ownership and is responsible for deletion.

virtual SplineCurve* Go::SplineCurve::subCurve ( double  from_par,
double  to_par,
double  fuzzy = DEFAULT_PARAMETER_EPSILON 
) const [virtual]

Returns a curve which is a part of this curve.

The result is NEWed, so the user is responsible for deleting it. NB: This function only work for derived classes of ParamCurve, namely those who are spline-based.

Parameters:
from_par start value of parameter interval that will define the subcurve
to_par end value of parameter interval that will define the subcurve
fuzzy since subCurve works on those curves who are spline-based, this tolerance defines how close the start and end parameter must be to an existing knot in order to be considered on the knot.
Returns:
a pointer to a new subcurve which represents the part of the curve between 'from_par' and 'to_par'. It will be spline-based and have a k-regular knotvector. The user is responsible for deleting this subcurve when it is no longer needed.

Implements Go::ParamCurve.

virtual void Go::SplineCurve::closestPoint ( const Point pt,
double  tmin,
double  tmax,
double &  clo_t,
Point clo_pt,
double &  clo_dist,
double const *  seed = 0 
) const [virtual]

Compute the closest point from an interval of this curve to a specified point.

Parameters:
pt point we want to find the closest point to
tmin start parameter of search interval
tmax end parameter of search interval
clo_t upon function return, 'clo_t' will contain the parameter value of the closest point found.
clo_pt upon function return, 'clo_pt' will contain the position of the closest point found.
clo_dist upon function return, 'clo_dist' will containn the distance between 'pt' and the closest point found.
seed pointer to initial guess value, provided by the user (can be 0, for which the algorithm will determine a (hopefully) reasonable choice).

Implements Go::ParamCurve.

virtual void Go::SplineCurve::appendCurve ( ParamCurve other_curve,
int  continuity,
double &  dist,
bool  repar = true 
) [virtual]

Inherited from ParamCurve.

Appends a curve to end of this curve. The knotvector and control point vector of 'this' curve will be extended, and the degree will be raised if necessary. Note that there will be side-effects on the 'other_curve' (its order might be raised, its knotvector will become k-regular and evt. reparametrized, its start point will be moved to coincide with the end point of 'this' curve, etc.)

Parameters:
other_curve the curve to append to this curve
continuity which level of continuity we demand at the transition between the two curves (can be from -1 to order(), but the higher the value the more the curves will have to be locally modified.
dist upon function return, this variable will hold the estimated maximum distorsion after 'smoothing' of joined curve to achieve the desired continuity.
repar The parametrization of the 'other_curve' will always be shifted so that it starts where the parametrization of 'this' curve ends. However, if 'repar' is set to 'true', it will also be scaled as a function of position of control points close to the transition.

Implements Go::ParamCurve.

virtual void Go::SplineCurve::appendCurve ( ParamCurve cv,
bool  repar = true 
) [virtual]

Inherited from ParamCurve.

Short hand function to call appendCurve with C^1 continuity.

Parameters:
cv the curve to append to this curve
repar The parametrization of the 'other_curve' will always be shifted so that it starts where the parametrization of 'this' curve ends. However, if 'repar' is set to 'true', it will also be scaled as a function of position of control points close to the transition.

Implements Go::ParamCurve.

const BsplineBasis& Go::SplineCurve::basis (  )  const [inline]

Get a const reference to the BsplineBasis of the curve.

Returns:
const reference to the curve's BsplineBasis.

Definition at line 247 of file SplineCurve.h.

BsplineBasis& Go::SplineCurve::basis (  )  [inline]

Get a reference to the BsplineBasis of the curve.

Returns:
reference to the curve's BsplineBasis.

Definition at line 252 of file SplineCurve.h.

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

Query the number of control points of the curve.

Returns:
the number of control points of the curve.

Definition at line 257 of file SplineCurve.h.

References Go::BsplineBasis::numCoefs().

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

Query the order of the spline space in which the curve lies.

Returns:
the order of the curve's spline space

Definition at line 262 of file SplineCurve.h.

References Go::BsplineBasis::order().

bool Go::SplineCurve::rational (  )  const [inline]

Query whether or not the curve is rational.

Returns:
'true' if the curve is rational, 'false' otherwise.

Definition at line 267 of file SplineCurve.h.

Referenced by SplineCurve().

std::vector<double>::iterator Go::SplineCurve::knotsBegin (  )  [inline]

Get an iterator to the beginning of the knot vector.

Returns:
an iterator to the beginning of the knot vector

Definition at line 272 of file SplineCurve.h.

References Go::BsplineBasis::begin().

std::vector<double>::iterator Go::SplineCurve::knotsEnd (  )  [inline]

Get a one-past-end iterator to the knot vector.

Returns:
an iterator to one-past-end of the knot vector

Definition at line 276 of file SplineCurve.h.

References Go::BsplineBasis::end().

std::vector<double>::const_iterator Go::SplineCurve::knotsBegin (  )  const [inline]

Get a const iterator to the beginning of the knot vector.

Returns:
a const iterator to the beginning of the knot vector

Definition at line 280 of file SplineCurve.h.

References Go::BsplineBasis::begin().

std::vector<double>::const_iterator Go::SplineCurve::knotsEnd (  )  const [inline]

Get a one-past-end const iterator to the knot vector.

Returns:
a const iterator to one-past-end of the knot vector

Definition at line 284 of file SplineCurve.h.

References Go::BsplineBasis::end().

std::vector<double>::iterator Go::SplineCurve::coefs_begin (  )  [inline]

Get an iterator to the start of the curve's internal, non-rational control point array.

Returns:
an iterator to the start of the curves non-rational control point array

Definition at line 292 of file SplineCurve.h.

std::vector<double>::iterator Go::SplineCurve::coefs_end (  )  [inline]

Get a one-past-end iterator to the curve's non-rational, internal control point array.

Returns:
an iterator to one-past-end of the curve's non-rational, internal control point array

Definition at line 298 of file SplineCurve.h.

std::vector<double>::const_iterator Go::SplineCurve::coefs_begin (  )  const [inline]

Get a const iterator to the start of the curve's non-rational, internal control point array.

Returns:
a const iterator to the start of the curve's non-rational control point array.

Definition at line 304 of file SplineCurve.h.

std::vector<double>::const_iterator Go::SplineCurve::coefs_end (  )  const [inline]

Get a one-past-end const iterator to the curve's non-rational, internal control point array.

Returns:
a const iterator to one-past-end of the curve's non-rational, internal control point array

Definition at line 310 of file SplineCurve.h.

std::vector<double>::iterator Go::SplineCurve::rcoefs_begin (  )  [inline]

Get an iterator to the start of the curve's internal, rational control point array.

Returns:
an iterator to the start of the curves rational control point array

Definition at line 316 of file SplineCurve.h.

std::vector<double>::iterator Go::SplineCurve::rcoefs_end (  )  [inline]

Get a one-past-end iterator to the curve's rational, internal control point array.

Returns:
an iterator to one-past-end of the curve's rational, internal control point array

Definition at line 322 of file SplineCurve.h.

std::vector<double>::const_iterator Go::SplineCurve::rcoefs_begin (  )  const [inline]

Get a const iterator to the start of the curve's rational, internal control point array.

Returns:
a const iterator to the start of the curve's rational control point array.

Definition at line 328 of file SplineCurve.h.

std::vector<double>::const_iterator Go::SplineCurve::rcoefs_end (  )  const [inline]

Get a one-past-end const iterator to the curve's rational, internal control point array.

Returns:
a const iterator to one-past-end of the curve's rational, internal control point array

Definition at line 334 of file SplineCurve.h.

void Go::SplineCurve::interpolate ( Interpolator interpolator,
int  num_points,
int  dim,
const double *  param_start,
const double *  data_start 
)

Remake 'this' SplineCurve to interpolate (or approximate) a given sequence of data points.

Parameters:
interpolator reference to the Interpolator object specifying the interpolation method to use
num_points number of points to interpolate
dim dimension of the Euclidean space in which the points lie (usually 2 or 3)
param_start pointer to the start of an array expressing the parameter values of the given data points.
data_start pointer to the array where the coordinates of the data points are stored.

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

Insert a new knot into the curve's knotvector.

Parameters:
apar parameter value of the new knot

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

Insert several knots into the curve's knotvector.

Parameters:
new_knots vector containing the parameter values of the new knots to be inserted into the knotvector.

void Go::SplineCurve::setParameterInterval ( double  t1,
double  t2 
)

Rescale the knotvector so that the total parameter span now ranges from 't1' to 't2'.

Parameters:
t1 new start value of the spline's parameter span
t2 new end value of the spline's parameter span

void Go::SplineCurve::removeKnot ( double  tpar  ) 

Remove a knot from the knotvector.

Parameters:
tpar the parameter value of the knot to be removed.

void Go::SplineCurve::raiseOrder ( int  i = 1  ) 

Raise the order of the curve's b-spline basis without changing the shape of the curve.

Parameters:
i specifies how many times the order will be raised.

void Go::SplineCurve::makeKnotStartRegular (  ) 

Make the knotvector k-regular at start.

Useful when k-regularity of a knotvector is to be assumed.

void Go::SplineCurve::makeKnotEndRegular (  ) 

Make the knotvector k-regular at end.

Useful when k-regularity of a knotvector is to be assumed.

void Go::SplineCurve::swap ( SplineCurve other  ) 

quick swap of 'this' SplineCurve with the 'other' one.

Parameters:
other the SplineCurve to swap with 'this' one.

virtual double Go::SplineCurve::nextSegmentVal ( double  par,
bool  forward,
double  tol 
) const [virtual]

Inherited from ParamCurve.

Returns the value of the next knot.

Parameters:
par the parameter from which we will look for the start of the next interval.
forward specify whether we will look forwards or backwards.
tol a tolerance specifying how close 'par' has to be to a knot to be considered 'on' the knot.

Reimplemented from Go::ParamCurve.


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