SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Static Public Member Functions | List of all members
smtk::extension::qtBSpline2D Class Reference

Utilities for working with 2-D B-splines. More...

#include <qtBSpline2D.h>

Static Public Member Functions

static std::vector< double > uniformKnotVectorForInterpolatedEndpoints (std::size_t nn, std::size_t maxDegree=3, std::size_t *actualDegree=nullptr)
 Return a knot vector that, given a sequence of nn control points, will produce a spline of degree \ a dd (or lower) that interpolates its endpoints. More...
 
static bool insertKnot (std::size_t kk, std::size_t ll, double tt, std::vector< double > &knot, std::vector< QPointF > &controlPoint)
 Insert a knot value, tt, at location ll in a spline of order kk. More...
 
static bool splineToCubicPath (std::size_t degree, const std::vector< QPointF > &controlPoints, const std::vector< double > &knotVector, std::vector< QPointF > &outputPath)
 Insert knots into a cubic- (or lower-) degree spline to get cubic (or lower) Bezier points out. More...
 

Detailed Description

Utilities for working with 2-D B-splines.

These methods are used by smtk::extension::qtResourceDiagramArc to convert a B-spline control polygon that interpolates only its endpoints into a set of cubic Bézier points (since the latter is what Qt can render).

Member Function Documentation

◆ insertKnot()

bool smtk::extension::qtBSpline2D::insertKnot ( std::size_t  kk,
std::size_t  ll,
double  tt,
std::vector< double > &  knot,
std::vector< QPointF > &  controlPoint 
)
static

Insert a knot value, tt, at location ll in a spline of order kk.

This algorithm modifies the passed knot and controlPoint vectors; on output, knot will include an additional value and controlPoint will contain an additional point.

If you attempt an insertion that causes a non-monotonic knot vector, this method will return false and make no changes to knot and controlPoint.

Note that kk = degree + 1, so if your curve is cubic, kk will be 4.

◆ splineToCubicPath()

bool smtk::extension::qtBSpline2D::splineToCubicPath ( std::size_t  degree,
const std::vector< QPointF > &  controlPoints,
const std::vector< double > &  knotVector,
std::vector< QPointF > &  outputPath 
)
static

Insert knots into a cubic- (or lower-) degree spline to get cubic (or lower) Bezier points out.

If the input degree is too high, false is returned.

This repeatedly calls insertKnot on a copy of controlPoints and knotVector to determine the output path points. An alternative to repeated invocation of the Boehm insertKnot algorithm would be to implement the Oslo algorithm[1], but it is more complex.

[1]: Cohen, Lyche, and Riesenfeld. Discrete B-Splines and Subdivision Techniques in Computer-Aided Geometric Design and Computer Graphics. Computer Graphics and Image Processing, v14n2. October, 1980. Academic Press.

◆ uniformKnotVectorForInterpolatedEndpoints()

std::vector< double > smtk::extension::qtBSpline2D::uniformKnotVectorForInterpolatedEndpoints ( std::size_t  nn,
std::size_t  maxDegree = 3,
std::size_t *  actualDegree = nullptr 
)
static

Return a knot vector that, given a sequence of nn control points, will produce a spline of degree \ a dd (or lower) that interpolates its endpoints.

An empty vector indicates that nn < 2.

Example: if dd is 3 (a cubic spline is desired), then:

  • if nn == 2, the output degree will be 1;
  • if nn == 3, the output degree will be 2;
  • for nn >= 4, the output degree will be 3.

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