3.4.0
BSplineFit Class Reference

#include <CTiglBSplineFit.h>

Public Types

enum  error { NoError = 0, MatrixSingular, InvalidInput }
 

Public Member Functions

TIGL_EXPORT BSplineFit (int deg, int ncp)
 BSplineFit Class to fit a B-spline to data points. More...
 
TIGL_EXPORT Handle_Geom_BSplineCurve Curve () const
 Returns the resulting curve. Returns Null in case of an error. More...
 
TIGL_EXPORT error Fit (const TColgp_Array1OfPnt &points, const std::vector< double > &parameters)
 Fits the given points by a B-spline. More...
 
TIGL_EXPORT error Fit (const TColgp_Array1OfPnt &points, double alpha=1.0)
 Fits the given points by a B-spline using the centripetal parameterization scheme (alpha=0.5) More...
 
TIGL_EXPORT error FitOptimal (const TColgp_Array1OfPnt &points, double alpha=1.0, double eps=1.0E-3, int maxIter=100)
 Fits, by optimizing the fit parameters This is an iterative algorithm and requires more time than the other fit algorithms. More...
 
TIGL_EXPORT double GetMaxError ()
 Computes the maximum error of the fit. More...
 

Private Member Functions

void computeKnots ()
 Computes an uniform knot vector. More...
 
void computeParameters (double alpha)
 Calculates curve parameter t_k [0, 1], which corresponds to the arc lengths. More...
 
void copyPoints (const TColgp_Array1OfPnt &)
 Copies the points to be fitted. More...
 
error fitCurve ()
 Fits the given points by a Bezier spline. More...
 
void initSystem (class math_Matrix &A, class math_Vector &rhsx, class math_Vector &rhsy, class math_Vector &rhsz)
 Computes the matrix and the right hand side of the system to be solved. More...
 
void optimizeParameters ()
 Recalculates the curve parameters t_k after the control points are fitted to achieve an even better fit. More...
 

Private Attributes

Handle_Geom_BSplineCurve _curve
 The resulting B-spline curve. More...
 
int _degree
 degree of the B-spline More...
 
TColStd_Array1OfReal _knots
 uniform knot vector of the B-spline More...
 
int _ncp
 Number of control points of the B-spline. More...
 
std::vector< double > _px
 curve coordinates to be fitted by the B-spline More...
 
std::vector< double > _py
 
std::vector< double > _pz
 
std::vector< double > t
 parameters at which the curve is sampled More...
 

Detailed Description

Copyright (C) 2015 DLR-SC

Author: Martin Siggel

A algorithm that fits a bspline to the given data points.

This iterative algorithm works as follows:

0) Initialize parameters t_k with uniform distance 1) Find control points, by minimizing the distance C(t_k) - p_k for all k using a least square fit. 2) Optimize all t_k, such that the distance C(t_k) - p_k becomes smaller. Go back to (1)

Member Enumeration Documentation

◆ error

Enumerator
NoError 
MatrixSingular 
InvalidInput 

Constructor & Destructor Documentation

◆ BSplineFit()

TIGL_EXPORT BSplineFit::BSplineFit ( int  deg,
int  ncp 
)

BSplineFit Class to fit a B-spline to data points.

Parameters
degDegree of the resulting B-spline
ncpNumber of control points of the B-spline (ncp > deg)
epsTolerance of the iterative method
maxIterMaximum number of iterations

Member Function Documentation

◆ computeKnots()

void BSplineFit::computeKnots ( )
private

Computes an uniform knot vector.

◆ computeParameters()

void BSplineFit::computeParameters ( double  alpha)
private

Calculates curve parameter t_k [0, 1], which corresponds to the arc lengths.

◆ copyPoints()

void BSplineFit::copyPoints ( const TColgp_Array1OfPnt &  )
private

Copies the points to be fitted.

◆ Curve()

TIGL_EXPORT Handle_Geom_BSplineCurve BSplineFit::Curve ( ) const

Returns the resulting curve. Returns Null in case of an error.

◆ Fit() [1/2]

TIGL_EXPORT error BSplineFit::Fit ( const TColgp_Array1OfPnt &  points,
const std::vector< double > &  parameters 
)

Fits the given points by a B-spline.

◆ Fit() [2/2]

TIGL_EXPORT error BSplineFit::Fit ( const TColgp_Array1OfPnt &  points,
double  alpha = 1.0 
)

Fits the given points by a B-spline using the centripetal parameterization scheme (alpha=0.5)

◆ fitCurve()

error BSplineFit::fitCurve ( )
private

Fits the given points by a Bezier spline.

◆ FitOptimal()

TIGL_EXPORT error BSplineFit::FitOptimal ( const TColgp_Array1OfPnt &  points,
double  alpha = 1.0,
double  eps = 1.0E-3,
int  maxIter = 100 
)

Fits, by optimizing the fit parameters This is an iterative algorithm and requires more time than the other fit algorithms.

◆ GetMaxError()

TIGL_EXPORT double BSplineFit::GetMaxError ( )

Computes the maximum error of the fit.

◆ initSystem()

void BSplineFit::initSystem ( class math_Matrix &  A,
class math_Vector &  rhsx,
class math_Vector &  rhsy,
class math_Vector &  rhsz 
)
private

Computes the matrix and the right hand side of the system to be solved.

◆ optimizeParameters()

void BSplineFit::optimizeParameters ( )
private

Recalculates the curve parameters t_k after the control points are fitted to achieve an even better fit.

Field Documentation

◆ _curve

Handle_Geom_BSplineCurve BSplineFit::_curve
private

The resulting B-spline curve.

◆ _degree

int BSplineFit::_degree
private

degree of the B-spline

◆ _knots

TColStd_Array1OfReal BSplineFit::_knots
private

uniform knot vector of the B-spline

◆ _ncp

int BSplineFit::_ncp
private

Number of control points of the B-spline.

◆ _px

std::vector<double> BSplineFit::_px
private

curve coordinates to be fitted by the B-spline

◆ _py

std::vector<double> BSplineFit::_py
private

◆ _pz

std::vector<double> BSplineFit::_pz
private

◆ t

std::vector<double> BSplineFit::t
private

parameters at which the curve is sampled


The documentation for this class was generated from the following file: