3.5.0-rc1
Loading...
Searching...
No Matches
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.
TIGL_EXPORT Handle_Geom_BSplineCurve Curve () const
 Returns the resulting curve. Returns Null in case of an error.
TIGL_EXPORT error Fit (const TColgp_Array1OfPnt &points, const std::vector< double > &parameters)
 Fits the given points by a B-spline.
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).
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.
TIGL_EXPORT double GetMaxError ()
 Computes the maximum error of the fit.

Private Member Functions

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

Private Attributes

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

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,
math_Vector & rhsx,
math_Vector & rhsy,
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: