#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 > ¶meters) |
| 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 | |
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