#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 > ¶meters) |
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... | |
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)
enum BSplineFit::error |
TIGL_EXPORT BSplineFit::BSplineFit | ( | int | deg, |
int | ncp | ||
) |
BSplineFit Class to fit a B-spline to data points.
deg | Degree of the resulting B-spline |
ncp | Number of control points of the B-spline (ncp > deg) |
eps | Tolerance of the iterative method |
maxIter | Maximum number of iterations |
|
private |
Computes an uniform knot vector.
|
private |
Calculates curve parameter t_k [0, 1], which corresponds to the arc lengths.
|
private |
Copies the points to be fitted.
TIGL_EXPORT Handle_Geom_BSplineCurve BSplineFit::Curve | ( | ) | const |
Returns the resulting curve. Returns Null in case of an error.
TIGL_EXPORT error BSplineFit::Fit | ( | const TColgp_Array1OfPnt & | points, |
const std::vector< double > & | parameters | ||
) |
Fits the given points by a B-spline.
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)
|
private |
Fits the given points by a Bezier spline.
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.
TIGL_EXPORT double BSplineFit::GetMaxError | ( | ) |
Computes the maximum error of the fit.
|
private |
Computes the matrix and the right hand side of the system to be solved.
|
private |
Recalculates the curve parameters t_k after the control points are fitted to achieve an even better fit.
|
private |
The resulting B-spline curve.
|
private |
degree of the B-spline
|
private |
uniform knot vector of the B-spline
|
private |
Number of control points of the B-spline.
|
private |
curve coordinates to be fitted by the B-spline
|
private |
|
private |
|
private |
parameters at which the curve is sampled