Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions
Approx_BSplineApproxInterp Class Reference

Constrained least-squares B-spline curve approximation with exact interpolation constraints. More...

#include <Approx_BSplineApproxInterp.hxx>

Public Member Functions

 Approx_BSplineApproxInterp (const NCollection_Array1< gp_Pnt > &thePoints, int theNbControlPts, int theDegree=3, bool theContinuousIfClosed=false)
 Creates a constrained approximation solver.
 
void InterpolatePoint (int thePointIndex, bool theWithKink=false)
 Marks a point to be exactly interpolated rather than approximated.
 
void Perform ()
 Performs the fit using automatically computed parameters. Parameters are computed from input points using current parametrization alpha.
 
void Perform (const NCollection_Array1< double > &theParams)
 Performs the fit with given parameters.
 
void PerformOptimal (int theMaxIter)
 Performs the fit with iterative parameter optimization using automatically computed initial parameters.
 
void PerformOptimal (const NCollection_Array1< double > &theParams, int theMaxIter)
 Performs the fit with iterative parameter optimization. Parameters of approximated points are re-projected onto the curve after each iteration to improve the fit.
 
bool IsDone () const
 Returns true if the fit was successfully computed.
 
const occ::handle< Geom_BSplineCurve > & Curve () const
 Returns the resulting B-spline curve.
 
double MaxError () const
 Returns the maximum approximation error (distance at approximated points).
 
void SetParametrizationAlpha (double theAlpha)
 Sets the parametrization power for automatic parameter computation. 0.0 = uniform, 0.5 = centripetal (default), 1.0 = chord-length.
 
void SetMinPivot (double theMinPivot)
 Sets the minimum pivot value for the Gauss solver. Matrices with pivots below this threshold are treated as singular.
 
void SetClosedTolerance (double theRelTol)
 Sets the relative tolerance for detecting closed curves. Closedness is detected when first/last points are within theRelTol * (bounding box diagonal).
 
void SetKnotInsertionTolerance (double theTol)
 Sets the tolerance for detecting duplicate knot positions during insertion.
 
void SetConvergenceTolerance (double theTol)
 Sets the convergence tolerance for parameter optimization. Optimization stops when relative error reduction falls below this value.
 
void SetProjectionTolerance (double theTol)
 Sets the tolerance for point projection onto curve during optimization.
 

Detailed Description

Constrained least-squares B-spline curve approximation with exact interpolation constraints.

This class fits a B-spline curve through a set of 3D points, where each point can be either approximated (in the least-squares sense) or exactly interpolated. Selected interpolation points can additionally be marked as "kinks" - the solver then inserts high-multiplicity knots at the corresponding parameters to preserve C0 discontinuities.

The algorithm solves a KKT (Karush-Kuhn-Tucker) saddle-point system:

| A^T*A C^T L^T | | x | | A^T*b |
| C 0 0 | * | l | = | d |
| L 0 0 | | m | | 0 |
STL input iterator that wraps an OCCT More()/Next() iterator.
Definition NCollection_ForwardRange.hxx:142

where:

Usage:

// ... fill points ...
anApprox.InterpolatePoint(0); // first point exact
anApprox.InterpolatePoint(99); // last point exact
anApprox.InterpolatePoint(50, true); // kink at midpoint
anApprox.Perform(aParams);
if (anApprox.IsDone())
{
double aMaxErr = anApprox.MaxError();
}
Constrained least-squares B-spline curve approximation with exact interpolation constraints.
Definition Approx_BSplineApproxInterp.hxx:66
Intrusive smart pointer for use with Standard_Transient class and its descendants.
Definition Standard_Handle.hxx:54

Constructor & Destructor Documentation

◆ Approx_BSplineApproxInterp()

Approx_BSplineApproxInterp::Approx_BSplineApproxInterp ( const NCollection_Array1< gp_Pnt > & thePoints,
int theNbControlPts,
int theDegree = 3,
bool theContinuousIfClosed = false )

Creates a constrained approximation solver.

Parameters
[in]thePointsarray of 3D points to fit (1-based indexing)
[in]theNbControlPtsdesired number of control points for the B-spline
[in]theDegreedegree of the B-spline (default 3)
[in]theContinuousIfClosedif true, enforces C2 continuity for closed curves

Member Function Documentation

◆ Curve()

const occ::handle< Geom_BSplineCurve > & Approx_BSplineApproxInterp::Curve ( ) const

Returns the resulting B-spline curve.

◆ InterpolatePoint()

void Approx_BSplineApproxInterp::InterpolatePoint ( int thePointIndex,
bool theWithKink = false )

Marks a point to be exactly interpolated rather than approximated.

Parameters
[in]thePointIndex0-based index of the point
[in]theWithKinkif true, a kink (C0 break) is inserted at this parameter

◆ IsDone()

bool Approx_BSplineApproxInterp::IsDone ( ) const
inline

Returns true if the fit was successfully computed.

◆ MaxError()

double Approx_BSplineApproxInterp::MaxError ( ) const
inline

Returns the maximum approximation error (distance at approximated points).

◆ Perform() [1/2]

void Approx_BSplineApproxInterp::Perform ( )

Performs the fit using automatically computed parameters. Parameters are computed from input points using current parametrization alpha.

◆ Perform() [2/2]

void Approx_BSplineApproxInterp::Perform ( const NCollection_Array1< double > & theParams)

Performs the fit with given parameters.

Parameters
[in]theParamsparameter values for each point (size must match point count)

◆ PerformOptimal() [1/2]

void Approx_BSplineApproxInterp::PerformOptimal ( const NCollection_Array1< double > & theParams,
int theMaxIter )

Performs the fit with iterative parameter optimization. Parameters of approximated points are re-projected onto the curve after each iteration to improve the fit.

Parameters
[in]theParamsinitial parameter values
[in]theMaxItermaximum number of optimization iterations

◆ PerformOptimal() [2/2]

void Approx_BSplineApproxInterp::PerformOptimal ( int theMaxIter)

Performs the fit with iterative parameter optimization using automatically computed initial parameters.

Parameters
[in]theMaxItermaximum number of optimization iterations

◆ SetClosedTolerance()

void Approx_BSplineApproxInterp::SetClosedTolerance ( double theRelTol)
inline

Sets the relative tolerance for detecting closed curves. Closedness is detected when first/last points are within theRelTol * (bounding box diagonal).

Parameters
[in]theRelTolrelative tolerance (default 1e-12)

◆ SetConvergenceTolerance()

void Approx_BSplineApproxInterp::SetConvergenceTolerance ( double theTol)
inline

Sets the convergence tolerance for parameter optimization. Optimization stops when relative error reduction falls below this value.

Parameters
[in]theTolconvergence tolerance (default 1e-3)

◆ SetKnotInsertionTolerance()

void Approx_BSplineApproxInterp::SetKnotInsertionTolerance ( double theTol)
inline

Sets the tolerance for detecting duplicate knot positions during insertion.

Parameters
[in]theTolknot matching tolerance (default 1e-4)

◆ SetMinPivot()

void Approx_BSplineApproxInterp::SetMinPivot ( double theMinPivot)
inline

Sets the minimum pivot value for the Gauss solver. Matrices with pivots below this threshold are treated as singular.

Parameters
[in]theMinPivotminimum pivot threshold (default 1e-20)

◆ SetParametrizationAlpha()

void Approx_BSplineApproxInterp::SetParametrizationAlpha ( double theAlpha)
inline

Sets the parametrization power for automatic parameter computation. 0.0 = uniform, 0.5 = centripetal (default), 1.0 = chord-length.

Parameters
[in]theAlphaparametrization exponent in [0, 1]

◆ SetProjectionTolerance()

void Approx_BSplineApproxInterp::SetProjectionTolerance ( double theTol)
inline

Sets the tolerance for point projection onto curve during optimization.

Parameters
[in]theTolprojection accuracy (default 1e-6)

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