AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::primal::NURBSCurve< T, NDIMS > Class Template Reference

Represents a NURBS curve defined by an array of control points, weights and knots. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/main/src/axom/primal/geometry/NURBSCurve.hpp>

Public Types

using NumericType = T
 
using PointType = Point< T, NDIMS >
 
using VectorType = Vector< T, NDIMS >
 
using SegmentType = Segment< T, NDIMS >
 
using WeightsVec = axom::Array< T >
 
using CoordsVec = axom::Array< PointType >
 
using KnotVectorType = KnotVector< T >
 
using BoundingBoxType = BoundingBox< T, NDIMS >
 
using OrientedBoundingBoxType = OrientedBoundingBox< T, NDIMS >
 

Public Member Functions

std::ostream & print (std::ostream &os) const
 Simple formatted print of a NURBS Curve instance. More...
 
Query/modify curve properties (degree, rationality, ...)
void setParameters (int npts, int degree)
 Reset the degree and resize arrays of points (and weights) More...
 
void setDegree (int degree)
 Reset the knot vector. More...
 
int getDegree () const
 Returns the degree of the NURBS Curve. More...
 
int getOrder () const
 Returns the order of the NURBS Curve. More...
 
int getNumControlPoints () const
 Returns the number of control points in the NURBS Curve. More...
 
void setNumControlPoints (int npts)
 Set the number control points. More...
 
void clear ()
 Clears the list of control points, make nonrational. More...
 
bool isRational () const
 Use array size as flag for rationality. More...
 
void makeRational ()
 Make trivially rational. If already rational, do nothing. More...
 
void makeNonrational ()
 Make nonrational. If already rational, do nothing. More...
 
bool isValidNURBS () const
 Function to check if the NURBS curve is valid. More...
 
Query/modify curve's geometry (control points, weights, bounding box, ...)
PointTypeoperator[] (int idx)
 Retrieve the control point at index idx. More...
 
const PointTypeoperator[] (int idx) const
 Retrieve the control point at index idx. More...
 
const PointTypegetInitPoint () const
 
const PointTypegetEndPoint () const
 
CoordsVecgetControlPoints ()
 Returns a reference to the NURBS curve's control points. More...
 
const CoordsVecgetControlPoints () const
 Returns a const reference to the NURBS curve's control points. More...
 
const T & getWeight (int idx) const
 Get a specific weight. More...
 
void setWeight (int idx, T weight)
 Set the weight at a specific index. More...
 
WeightsVecgetWeights ()
 Returns a reference to the NURBS curve's weights. More...
 
const WeightsVecgetWeights () const
 Returns a const reference to the NURBS curve's weights. More...
 
BoundingBoxType boundingBox () const
 Returns an axis-aligned bounding box containing the NURBS curve. More...
 
OrientedBoundingBoxType orientedBoundingBox () const
 Returns an oriented bounding box containing the NURBS curve. More...
 
Query/modify curve parametrization
axom::IndexType getNumKnots () const
 Returns the number of knots in the NURBS Curve. More...
 
auto getNumKnotSpans () const
 
void normalize ()
 Normalize the knot vector to the span of [0, 1]. More...
 
void rescale (T a, T b)
 Rescale the knot vector to the span of [a, b]. More...
 
const T & getKnot (int idx) const
 Get a specific knot value. More...
 
void setKnot (int idx, T knot)
 Set the knot value at a specific index. More...
 
void setKnots (const axom::Array< T > &knots, int degree)
 Set the knot vector by an axom::Array. More...
 
void setKnots (const KnotVectorType &knotVector)
 Set the knot vector by a KnotVector object. More...
 
KnotVectorTypegetKnots ()
 Return a reference to the knot vector. More...
 
const KnotVectorTypegetKnots () const
 Return a const reference to the knot vector. More...
 
getMinKnot () const
 Get minimum knot value. More...
 
getMaxKnot () const
 Get maximum knot value. More...
 
void reverseOrientation ()
 Reverses the order of the NURBS curve's control points and weights. More...
 
axom::IndexType insertKnot (T t, int target_multiplicity=1)
 Insert a knot with given multiplicity. More...
 
Functions to evaluate curve and its derivatives and normals
PointType evaluate (T t) const
 Evaluate a NURBS Curve at a particular parameter value t. More...
 
VectorType dt (T t) const
 Evaluate the first derivative of NURBS Curve at parameter t. More...
 
VectorType dtdt (T t) const
 Evaluate the second derivative of NURBS Curve at parameter t. More...
 
void evaluateFirstDerivative (T t, PointType &eval, VectorType &Dt) const
 Evaluate the curve and the first derivative at parameter t. More...
 
void evaluateSecondDerivative (T t, PointType &eval, VectorType &Dt, VectorType &DtDt) const
 Evaluate the curve and the first two derivatives at parameter t. More...
 
void evaluateDerivatives (T t, int d, PointType &eval, axom::Array< VectorType > &ders) const
 Evaluate the curve and the first d derivatives at parameter t. More...
 
Functions dealing with curve subdivision
bool split (T t, NURBSCurve< T, NDIMS > &n1, NURBSCurve< T, NDIMS > &n2, bool normalizeParameters=false) const
 Splits a NURBS curve into two curves at a given parameter value. More...
 
void bisect (NURBSCurve< T, NDIMS > &n1, NURBSCurve< T, NDIMS > &n2, bool normalizeParameters=false) const
 Splits a NURBS curve into two curves at the middle parameter value. More...
 
axom::Array< BezierCurve< T, NDIMS > > extractBezier () const
 Splits a NURBS curve (at each internal knot) into several Bezier curves. More...
 

Friends

bool operator== (const NURBSCurve< T, NDIMS > &lhs, const NURBSCurve< T, NDIMS > &rhs)
 Equality operator for NURBS Curves. More...
 
bool operator!= (const NURBSCurve< T, NDIMS > &lhs, const NURBSCurve< T, NDIMS > &rhs)
 Inequality operator for NURBS Curves. More...
 

Constructors for NURBSCurve

The constructors allow for flexible initialization of NURBSCurve objects from:

  • 1D arrays of control points, weights and knots. The control points and weight can be provided as C-style arrays with sizes, axom Arrays and axom ArrayViews. The knots can be provided as C-style arrays with sizes, axom Arrays and KnotVector instances
  • Specified number of points and degree
  • Rational or polynomial (nonrational) curves, depending on the presence of weights.

All require:

  • Degree >= -1. Degree -1 creates an empty/invalid curve.
  • For valid curves, npts must be greater than the degree
  • The weights array is optional. The curve is polynomial (non-rational) if weights are not provided
  • When weights are provided, their size must match the number of control points
  • The knot vector must satisfy continuity and openness conditions
 NURBSCurve (int degree=-1)
 Constructor for a simple NURBS curve that reserves space for the minimum (sensible) number of points for the given degree. More...
 
 NURBSCurve (int npts, int degree)
 Constructor for a NURBS curve with given number of control points and degree. More...
 
 NURBSCurve (axom::ArrayView< const PointType > pts, axom::ArrayView< const T > weights, const KnotVectorType &knotVector)
 Constructor for a NURBS Curve with ArrayViews of control points and weights and a KnotVector. More...
 
 NURBSCurve (axom::ArrayView< PointType > pts, axom::ArrayView< T > weights, const KnotVectorType &knotVector)
 Constructs a NURBSCurve from arrays of control points, weights and knots. More...
 
 NURBSCurve (const BezierCurve< T, NDIMS > &bezierCurve)
 Constructor for a NURBS curve from a Bezier curve. More...
 
 NURBSCurve (const PointType *pts, int npts, int degree)
 Constructor for a NURBS Curve with control points and degree. More...
 
 NURBSCurve (const PointType *pts, const T *weights, int npts, int degree)
 Constructor for a NURBS Curve with control points, weights, and degree. More...
 
 NURBSCurve (const PointType *pts, int npts, const T *knots, int nkts)
 Constructor for a NURBS Curve with control points and knots. More...
 
 NURBSCurve (const PointType *pts, const T *weights, int npts, const T *knots, int nkts)
 Constructor for a NURBS Curve with control points, weights, and knots. More...
 
 NURBSCurve (const axom::Array< PointType > &pts, int degree)
 Constructor for a NURBS Curve of the specified degree from an array of control points. More...
 
 NURBSCurve (const axom::Array< PointType > &pts, const axom::Array< T > &weights, int degree)
 Constructor for a NURBS Curve of the specified degree from an array of control points and weights. More...
 
 NURBSCurve (const axom::Array< PointType > &pts, const axom::Array< T > &knots)
 Constructor for a NURBS Curve with axom arrays of nodes and knots. More...
 
 NURBSCurve (const axom::Array< PointType > &pts, const axom::Array< T > &weights, const axom::Array< T > &knots)
 Constructor for a NURBS Curve with axom arrays of nodes, weights, and knots. More...
 
 NURBSCurve (const axom::Array< PointType > &pts, const KnotVectorType &knotVector)
 Constructor from axom array of nodes and KnotVector object. More...
 
 NURBSCurve (const axom::Array< PointType > &pts, const axom::Array< T > &weights, const KnotVectorType &knotVector)
 Constructor from axom array of nodes, weights, and KnotVector object. More...
 
static NURBSCurve make_circular_arc_nurbs (T theta_0, T theta_1, T u, T v, T radius)
 Construct a multi-span, rational, degree 2 NURBS curve from the angles of a circular arc. More...
 
static NURBSCurve make_linear_segment_nurbs (const PointType &start, const PointType &end)
 Construct a NURBS curve from the endpoints of a line segment. More...
 

Detailed Description

template<typename T, int NDIMS>
class axom::primal::NURBSCurve< T, NDIMS >

Represents a NURBS curve defined by an array of control points, weights and knots.

Template Parameters
Tthe coordinate type, e.g., double, float, etc.
NDIMSthe number of dimensions

A NURBS curve has degree p, n+1 control points, optionally n+1 weights, and a knot vector of length k+1. A valid curve has k+1 = n+p+2 The curve must be open (clamped on each end) and continuous (unless p = 0)

Polynomial (Nonrational) NURBS curves are identified by an empty weights array.

Member Typedef Documentation

◆ NumericType

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::NumericType = T

◆ PointType

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::PointType = Point<T, NDIMS>

◆ VectorType

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::VectorType = Vector<T, NDIMS>

◆ SegmentType

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::SegmentType = Segment<T, NDIMS>

◆ WeightsVec

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::WeightsVec = axom::Array<T>

◆ CoordsVec

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::CoordsVec = axom::Array<PointType>

◆ KnotVectorType

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::KnotVectorType = KnotVector<T>

◆ BoundingBoxType

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::BoundingBoxType = BoundingBox<T, NDIMS>

◆ OrientedBoundingBoxType

template<typename T , int NDIMS>
using axom::primal::NURBSCurve< T, NDIMS >::OrientedBoundingBoxType = OrientedBoundingBox<T, NDIMS>

Constructor & Destructor Documentation

◆ NURBSCurve() [1/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( int  degree = -1)
inlineexplicit

Constructor for a simple NURBS curve that reserves space for the minimum (sensible) number of points for the given degree.

Parameters
[in]degthe degree of the resulting curve
Note
A uniform knot vector is constructed such that the curve is continuous
Precondition
degree is greater than or equal to -1
Note
When the degree is -1, no space is reserved and the NURBS curve is not valid, i.e. in this case, curve.isValid() will return false

◆ NURBSCurve() [2/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( int  npts,
int  degree 
)
inline

Constructor for a NURBS curve with given number of control points and degree.

Parameters
[in]nptsthe number of control points
[in]degreethe degree of the curve
Note
A uniform knot vector is constructed such that the curve is continuous
This constructor reserves space for the control points, but does not set them
Precondition
npts > degree, degree >= -1

References axom::primal::NURBSCurve< T, NDIMS >::isValidNURBS(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), and SLIC_ASSERT.

◆ NURBSCurve() [3/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( axom::ArrayView< const PointType pts,
axom::ArrayView< const T >  weights,
const KnotVectorType knotVector 
)
inline

Constructor for a NURBS Curve with ArrayViews of control points and weights and a KnotVector.

Parameters
[in]ptsArrayView of control points
[in]weightsArrayView of weights
[in]knotVectorThe knot vector object

For clamped and continuous curves, the control points and knot vector uniquely determine the degree

Precondition
The number of control points must be greater than the knot vector degree
If the knotVector degree is -1, pts must be empty
If the knotVector degree is higher, we assume knotVector.isValid()
weights can either be empty (yielding a non-rational spline) or its size must match that of pts

References axom::ArrayView< T, DIM, SPACE >::data(), axom::ArrayView< T, DIM, SPACE >::empty(), axom::primal::KnotVector< T >::getDegree(), axom::primal::KnotVector< T >::isValid(), axom::primal::NURBSCurve< T, NDIMS >::isValidNURBS(), axom::primal::NURBSCurve< T, NDIMS >::makeNonrational(), axom::ArrayView< T, DIM, SPACE >::size(), and SLIC_ASSERT.

◆ NURBSCurve() [4/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( axom::ArrayView< PointType pts,
axom::ArrayView< T >  weights,
const KnotVectorType knotVector 
)
inline

Constructs a NURBSCurve from arrays of control points, weights and knots.

Parameters
[in]ptsArrayView of control points
[in]weightsArrayView of weights
[in]knotVectorKnot vector defining the parameterization of the curve.

◆ NURBSCurve() [5/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const BezierCurve< T, NDIMS > &  bezierCurve)
inlineexplicit

Constructor for a NURBS curve from a Bezier curve.

Parameters
[in]bezierCurvethe Bezier curve to convert to a NURBS curve

◆ NURBSCurve() [6/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const PointType pts,
int  npts,
int  degree 
)
inline

Constructor for a NURBS Curve with control points and degree.

Parameters
[in]ptsthe control points of the curve
[in]nptsthe number of control points
[in]degreethe degree of the curve
Precondition
Requires valid pointers, npts > degree, degree >= 0

◆ NURBSCurve() [7/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const PointType pts,
const T *  weights,
int  npts,
int  degree 
)
inline

Constructor for a NURBS Curve with control points, weights, and degree.

Parameters
[in]ptsthe control points of the curve
[in]weightsthe weights of the control points
[in]nptsthe number of control points and weights
[in]degreethe degree of the curve
Precondition
Requires valid pointers, npts > degree, npts == nwts, and degree >= 0

◆ NURBSCurve() [8/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const PointType pts,
int  npts,
const T *  knots,
int  nkts 
)
inline

Constructor for a NURBS Curve with control points and knots.

Parameters
[in]ptsthe control points of the curve
[in]nptsthe number of control points and weights
[in]knotsthe weights of the control points
[in]nktsthe length of the knot vector
Precondition
Requires valid pointers, a valid knot vector and npts > degree

◆ NURBSCurve() [9/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const PointType pts,
const T *  weights,
int  npts,
const T *  knots,
int  nkts 
)
inline

Constructor for a NURBS Curve with control points, weights, and knots.

Parameters
[in]ptsthe control points of the curve
[in]weightsthe weights of the control points
[in]nptsthe number of control points and weights
[in]knotsthe weights of the control points
[in]nktsthe length of the knot vector
Precondition
Requires valid pointers, a valid knot vector, npts > degree, npts == nwts, wts > 0

◆ NURBSCurve() [10/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const axom::Array< PointType > &  pts,
int  degree 
)
inline

Constructor for a NURBS Curve of the specified degree from an array of control points.

Parameters
[in]ptsthe control points of the curve
[in]degreethe degree of the curve
Precondition
Requires npts > degree and degree >= 0

◆ NURBSCurve() [11/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const axom::Array< PointType > &  pts,
const axom::Array< T > &  weights,
int  degree 
)
inline

Constructor for a NURBS Curve of the specified degree from an array of control points and weights.

Parameters
[in]ptsthe control points of the curve
[in]weightsthe weights of the control points
[in]degreethe degree of the curve
Precondition
Requires npts > degree, degree >= 0, and pts.size() == weights.size()

◆ NURBSCurve() [12/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const axom::Array< PointType > &  pts,
const axom::Array< T > &  knots 
)
inline

Constructor for a NURBS Curve with axom arrays of nodes and knots.

Parameters
[in]ptsthe control points of the curve
[in]knotsthe knot vector of the curve
Precondition
Requires a valid knot vector and npts > degree

◆ NURBSCurve() [13/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const axom::Array< PointType > &  pts,
const axom::Array< T > &  weights,
const axom::Array< T > &  knots 
)
inline

Constructor for a NURBS Curve with axom arrays of nodes, weights, and knots.

Parameters
[in]ptsthe control points of the curve
[in]weightsthe weights of the control points
[in]knotsthe knot vector of the curve
Precondition
Requires a valid knot vector, npts > degree, npts == nwts, wts > 0

◆ NURBSCurve() [14/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const axom::Array< PointType > &  pts,
const KnotVectorType knotVector 
)
inline

Constructor from axom array of nodes and KnotVector object.

Parameters
[in]ptsthe control points of the curve
[in]knotVectorA KnotVector object
Precondition
Requires a valid knot vector and npts > degree

◆ NURBSCurve() [15/15]

template<typename T , int NDIMS>
axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve ( const axom::Array< PointType > &  pts,
const axom::Array< T > &  weights,
const KnotVectorType knotVector 
)
inline

Constructor from axom array of nodes, weights, and KnotVector object.

Parameters
[in]ptsthe control points of the curve
[in]weightsthe weights of the control points
[in]knotVectorA KnotVector object
Precondition
Requires a valid knot vector, npts > degree, npts == nwts, wts > 0

Member Function Documentation

◆ make_circular_arc_nurbs()

template<typename T , int NDIMS>
static NURBSCurve axom::primal::NURBSCurve< T, NDIMS >::make_circular_arc_nurbs ( theta_0,
theta_1,
u,
v,
radius 
)
inlinestatic

Construct a multi-span, rational, degree 2 NURBS curve from the angles of a circular arc.

Parameters
[in]theta_0The starting angle of the arc
[in]theta_1The ending angle of the arc
[in]u,vThe center of the 2D circle
[in]radiusThe radius of the circle
Note
The curve's knots will span [0, 1], but the parameterization is not uniform with respect to the arc length
The arc is assumed to be counter-clockwise, unless theta_1 < theta_0, in which case the arc is clockwise.
Precondition
Requires a 2D NURBS curve, and the arc is less than a full circle

References axom::utilities::ceil(), axom::primal::NURBSCurve< T, NDIMS >::makeRational(), axom::utilities::min(), axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve(), axom::primal::NURBSCurve< T, NDIMS >::reverseOrientation(), axom::primal::NURBSCurve< T, NDIMS >::setKnot(), axom::primal::NURBSCurve< T, NDIMS >::setWeight(), SLIC_ASSERT, and axom::utilities::swap().

◆ make_linear_segment_nurbs()

template<typename T , int NDIMS>
static NURBSCurve axom::primal::NURBSCurve< T, NDIMS >::make_linear_segment_nurbs ( const PointType start,
const PointType end 
)
inlinestatic

Construct a NURBS curve from the endpoints of a line segment.

Parameters
[in]startThe starting point of the arc
[in]endThe ending point of the arc
Precondition
Requires a 2D NURBS curve

References axom::utilities::annotations::end(), and SLIC_ASSERT.

◆ setParameters()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::setParameters ( int  npts,
int  degree 
)
inline

Reset the degree and resize arrays of points (and weights)

Parameters
[in]nptsThe target number of control points
[in]degreeThe target degree
Warning
This method will replace existing knot vector with a uniform one.

References axom::primal::NURBSCurve< T, NDIMS >::isRational(), axom::primal::KnotVector< T >::makeUniform(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), and SLIC_ASSERT.

◆ setDegree()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::setDegree ( int  degree)
inline

Reset the knot vector.

Parameters
[in]degreeThe target degree
Warning
This method does NOT change the existing control points, i.e. does not perform degree elevation/reduction. Will replace existing knot vector with a uniform one.
Precondition
Requires target degree < npts and degree >= 0

References axom::primal::NURBSCurve< T, NDIMS >::getNumControlPoints(), axom::primal::KnotVector< T >::makeUniform(), and SLIC_ASSERT.

◆ getDegree()

template<typename T , int NDIMS>
int axom::primal::NURBSCurve< T, NDIMS >::getDegree ( ) const
inline

Returns the degree of the NURBS Curve.

References axom::primal::KnotVector< T >::getDegree().

◆ getOrder()

template<typename T , int NDIMS>
int axom::primal::NURBSCurve< T, NDIMS >::getOrder ( ) const
inline

Returns the order of the NURBS Curve.

References axom::primal::KnotVector< T >::getDegree().

◆ getNumControlPoints()

template<typename T , int NDIMS>
int axom::primal::NURBSCurve< T, NDIMS >::getNumControlPoints ( ) const
inline

Returns the number of control points in the NURBS Curve.

References axom::Array< T, DIM, SPACE, StoragePolicy >::size().

◆ setNumControlPoints()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::setNumControlPoints ( int  npts)
inline

Set the number control points.

Parameters
[in]nptsThe target number of control points
Warning
This method does NOT change the existing control points, i.e. does not perform degree elevation/reduction. Will replace existing knot vector with a uniform one.

References axom::primal::KnotVector< T >::getDegree(), axom::primal::NURBSCurve< T, NDIMS >::isRational(), axom::primal::KnotVector< T >::makeUniform(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), and SLIC_ASSERT.

◆ clear()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::clear ( )
inline

◆ isRational()

template<typename T , int NDIMS>
bool axom::primal::NURBSCurve< T, NDIMS >::isRational ( ) const
inline

Use array size as flag for rationality.

References axom::Array< T, DIM, SPACE, StoragePolicy >::empty().

◆ makeRational()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::makeRational ( )
inline

◆ makeNonrational()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::makeNonrational ( )
inline

Make nonrational. If already rational, do nothing.

References axom::Array< T, DIM, SPACE, StoragePolicy >::resize().

◆ isValidNURBS()

◆ operator[]() [1/2]

template<typename T , int NDIMS>
PointType& axom::primal::NURBSCurve< T, NDIMS >::operator[] ( int  idx)
inline

Retrieve the control point at index idx.

Parameters
[in]idxThe index of the control point
Returns
A reference to the control point at index idx

◆ operator[]() [2/2]

template<typename T , int NDIMS>
const PointType& axom::primal::NURBSCurve< T, NDIMS >::operator[] ( int  idx) const
inline

Retrieve the control point at index idx.

Parameters
[in]idxThe index of the control point
Returns
A const reference to the control point at index idx

◆ getInitPoint()

template<typename T , int NDIMS>
const PointType& axom::primal::NURBSCurve< T, NDIMS >::getInitPoint ( ) const
inline

◆ getEndPoint()

template<typename T , int NDIMS>
const PointType& axom::primal::NURBSCurve< T, NDIMS >::getEndPoint ( ) const
inline

◆ getControlPoints() [1/2]

template<typename T , int NDIMS>
CoordsVec& axom::primal::NURBSCurve< T, NDIMS >::getControlPoints ( )
inline

Returns a reference to the NURBS curve's control points.

◆ getControlPoints() [2/2]

template<typename T , int NDIMS>
const CoordsVec& axom::primal::NURBSCurve< T, NDIMS >::getControlPoints ( ) const
inline

Returns a const reference to the NURBS curve's control points.

◆ getWeight()

template<typename T , int NDIMS>
const T& axom::primal::NURBSCurve< T, NDIMS >::getWeight ( int  idx) const
inline

Get a specific weight.

Parameters
[in]idxThe index of the weight
Precondition
Requires that the curve be rational
Returns
The weight at index idx

References axom::primal::NURBSCurve< T, NDIMS >::isRational(), and SLIC_ASSERT.

◆ setWeight()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::setWeight ( int  idx,
weight 
)
inline

Set the weight at a specific index.

Parameters
[in]idxThe index of the weight
[in]weightThe updated value of the weight
Precondition
Requires that the curve be rational, and the weight be rational

References axom::primal::NURBSCurve< T, NDIMS >::isRational(), and SLIC_ASSERT.

◆ getWeights() [1/2]

template<typename T , int NDIMS>
WeightsVec& axom::primal::NURBSCurve< T, NDIMS >::getWeights ( )
inline

Returns a reference to the NURBS curve's weights.

◆ getWeights() [2/2]

template<typename T , int NDIMS>
const WeightsVec& axom::primal::NURBSCurve< T, NDIMS >::getWeights ( ) const
inline

Returns a const reference to the NURBS curve's weights.

◆ boundingBox()

template<typename T , int NDIMS>
BoundingBoxType axom::primal::NURBSCurve< T, NDIMS >::boundingBox ( ) const
inline

Returns an axis-aligned bounding box containing the NURBS curve.

References axom::Array< T, DIM, SPACE, StoragePolicy >::data(), and axom::Array< T, DIM, SPACE, StoragePolicy >::size().

◆ orientedBoundingBox()

template<typename T , int NDIMS>
OrientedBoundingBoxType axom::primal::NURBSCurve< T, NDIMS >::orientedBoundingBox ( ) const
inline

Returns an oriented bounding box containing the NURBS curve.

References axom::Array< T, DIM, SPACE, StoragePolicy >::data(), and axom::Array< T, DIM, SPACE, StoragePolicy >::size().

◆ getNumKnots()

template<typename T , int NDIMS>
axom::IndexType axom::primal::NURBSCurve< T, NDIMS >::getNumKnots ( ) const
inline

Returns the number of knots in the NURBS Curve.

References axom::primal::KnotVector< T >::getNumKnots().

◆ getNumKnotSpans()

template<typename T , int NDIMS>
auto axom::primal::NURBSCurve< T, NDIMS >::getNumKnotSpans ( ) const
inline

◆ normalize()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::normalize ( )
inline

Normalize the knot vector to the span of [0, 1].

References axom::primal::KnotVector< T >::normalize().

◆ rescale()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::rescale ( a,
b 
)
inline

Rescale the knot vector to the span of [a, b].

Parameters
[in]aThe lower bound of the new knot vector
[in]bThe upper bound of the new knot vector
Precondition
Requires a < b

References axom::primal::KnotVector< T >::rescale(), and SLIC_ASSERT.

◆ getKnot()

template<typename T , int NDIMS>
const T& axom::primal::NURBSCurve< T, NDIMS >::getKnot ( int  idx) const
inline

Get a specific knot value.

Parameters
[in]idxThe index of the knot
Returns
The knot value at index idx

◆ setKnot()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::setKnot ( int  idx,
knot 
)
inline

Set the knot value at a specific index.

Parameters
[in]idxThe index of the knot
[in]knotThe updated value of the knot

◆ setKnots() [1/2]

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::setKnots ( const axom::Array< T > &  knots,
int  degree 
)
inline

Set the knot vector by an axom::Array.

Parameters
[in]knotsThe new knot vector

◆ setKnots() [2/2]

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::setKnots ( const KnotVectorType knotVector)
inline

Set the knot vector by a KnotVector object.

Parameters
[in]knotVectorThe new knot vector

◆ getKnots() [1/2]

template<typename T , int NDIMS>
KnotVectorType& axom::primal::NURBSCurve< T, NDIMS >::getKnots ( )
inline

Return a reference to the knot vector.

◆ getKnots() [2/2]

template<typename T , int NDIMS>
const KnotVectorType& axom::primal::NURBSCurve< T, NDIMS >::getKnots ( ) const
inline

Return a const reference to the knot vector.

◆ getMinKnot()

template<typename T , int NDIMS>
T axom::primal::NURBSCurve< T, NDIMS >::getMinKnot ( ) const
inline

Get minimum knot value.

References axom::primal::KnotVector< T >::getMinKnot().

◆ getMaxKnot()

template<typename T , int NDIMS>
T axom::primal::NURBSCurve< T, NDIMS >::getMaxKnot ( ) const
inline

Get maximum knot value.

References axom::primal::KnotVector< T >::getMaxKnot().

◆ reverseOrientation()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::reverseOrientation ( )
inline

◆ insertKnot()

template<typename T , int NDIMS>
axom::IndexType axom::primal::NURBSCurve< T, NDIMS >::insertKnot ( t,
int  target_multiplicity = 1 
)
inline

Insert a knot with given multiplicity.

Parameters
[in]tThe parameter value of the knot to insert
[in]target_multiplicityThe multiplicity of the knot to insert
Returns
The index of the new knot

Algorithm A5.1 on p. 151 of "The NURBS Book"

Note
If the knot is already present, it will be inserted up to the given multiplicity, or the maximum permitted by the degree
Precondition
Requires t in the span of the knots (up to a small tolerance)
Note
If t is outside the knot span up to this tolerance, it is clamped to the span
Returns
The (maximum) index of the new knot

References axom::utilities::clampVal(), axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::getDegree(), axom::primal::NURBSCurve< T, NDIMS >::getMaxKnot(), axom::primal::NURBSCurve< T, NDIMS >::getMinKnot(), axom::primal::NURBSCurve< T, NDIMS >::getNumControlPoints(), axom::primal::KnotVector< T >::insertKnotBySpan(), axom::primal::NURBSCurve< T, NDIMS >::isRational(), axom::primal::KnotVector< T >::isValidParameter(), axom::utilities::min(), axom::Array< T, DIM, SPACE, StoragePolicy >::size(), and SLIC_ASSERT.

◆ evaluate()

template<typename T , int NDIMS>
PointType axom::primal::NURBSCurve< T, NDIMS >::evaluate ( t) const
inline

Evaluate a NURBS Curve at a particular parameter value t.

Parameters
[in]tThe parameter value at which to evaluate
Returns
p The point of the NURBS curve at t

Adapted from Algorithm A4.1 on page 124 of "The NURBS Book"

Precondition
Requires t in the span of the knots (up to a small tolerance).
Note
If t is outside the knot span up to this tolerance, it is clamped to the span

References axom::primal::KnotVector< T >::calculateBasisFunctionsBySpan(), axom::utilities::clampVal(), axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::getDegree(), axom::primal::NURBSCurve< T, NDIMS >::getMaxKnot(), axom::primal::NURBSCurve< T, NDIMS >::getMinKnot(), axom::primal::NURBSCurve< T, NDIMS >::isRational(), axom::primal::KnotVector< T >::isValidParameter(), and SLIC_ASSERT.

◆ dt()

template<typename T , int NDIMS>
VectorType axom::primal::NURBSCurve< T, NDIMS >::dt ( t) const
inline

Evaluate the first derivative of NURBS Curve at parameter t.

Parameters
[in]tThe parameter value at which to evaluate
Returns
p The vector of NURBS curve's derivative at t
Precondition
Requires t in the span of the knots (up to a small tolerance)
Note
If t is outside the knot span up to this tolerance, it is clamped to the span

References axom::primal::NURBSCurve< T, NDIMS >::evaluateDerivatives().

◆ dtdt()

template<typename T , int NDIMS>
VectorType axom::primal::NURBSCurve< T, NDIMS >::dtdt ( t) const
inline

Evaluate the second derivative of NURBS Curve at parameter t.

Parameters
[in]tThe parameter value at which to evaluate
Returns
p The vector of NURBS curve's 2nd derivative at t
Precondition
Requires t in the span of the knots (up to a small tolerance)
Note
If t is outside the knot span up to this tolerance, it is clamped to the span

References axom::primal::NURBSCurve< T, NDIMS >::evaluateDerivatives().

◆ evaluateFirstDerivative()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::evaluateFirstDerivative ( t,
PointType eval,
VectorType Dt 
) const
inline

Evaluate the curve and the first derivative at parameter t.

Parameters
[in]tThe parameter value at which to evaluate
[out]evalThe point on the curve at t
[out]DtThe first derivative of the curve at t
Precondition
Requires t in the span of the knots (up to a small tolerance)
Note
If t is outside the knot span up to this tolerance, it is clamped to the span

References axom::primal::NURBSCurve< T, NDIMS >::evaluateDerivatives().

◆ evaluateSecondDerivative()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::evaluateSecondDerivative ( t,
PointType eval,
VectorType Dt,
VectorType DtDt 
) const
inline

Evaluate the curve and the first two derivatives at parameter t.

Parameters
[in]tThe parameter value at which to evaluate
[out]evalThe point on the curve at t
[out]DtThe first derivative of the curve at t
[out]DtDtThe second derivative of the curve at t
Precondition
Requires t in the span of the knots (up to a small tolerance)
Note
If t is outside the knot span up to this tolerance, it is clamped to the span

References axom::primal::NURBSCurve< T, NDIMS >::evaluateDerivatives().

◆ evaluateDerivatives()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::evaluateDerivatives ( t,
int  d,
PointType eval,
axom::Array< VectorType > &  ders 
) const
inline

Evaluate the curve and the first d derivatives at parameter t.

Parameters
[in]tThe parameter value at which to evaluate
[in]dThe number of derivatives to evaluate
[out]evalThe point on the curve at t
[out]dersAn array of the first d derivatives at t

Implementation adapted from Algorithm A3.2 on p. 93 of "The NURBS Book". Rational derivatives from Algorithm A4.2 on p. 127 of "The NURBS Book".

Precondition
Requires t in the span of the knots (up to a small tolerance)
Note
If t is outside the knot span up to this tolerance, it is clamped to the span

References axom::utilities::binomialCoefficient(), axom::utilities::clampVal(), axom::primal::KnotVector< T >::derivativeBasisFunctionsBySpan(), axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::getDegree(), axom::primal::NURBSCurve< T, NDIMS >::getMaxKnot(), axom::primal::NURBSCurve< T, NDIMS >::getMinKnot(), axom::primal::NURBSCurve< T, NDIMS >::isRational(), axom::primal::KnotVector< T >::isValidParameter(), axom::utilities::min(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), and SLIC_ASSERT.

◆ split()

template<typename T , int NDIMS>
bool axom::primal::NURBSCurve< T, NDIMS >::split ( t,
NURBSCurve< T, NDIMS > &  n1,
NURBSCurve< T, NDIMS > &  n2,
bool  normalizeParameters = false 
) const
inline

Splits a NURBS curve into two curves at a given parameter value.

Parameters
[in]tparameter value at which to evaluate
[out]n1First output NURBS curve
[out]n2Second output NURBS curve
[in]normalizeParametersWhether to normalize the output curves

If t is at the knot u_0 or u_max, will return the original curve and a degenerate curve with the first or last control point

Precondition
Requires t in the strict interior of the span of the knots
Returns
True if and only if the curve was split (i.e., t is in the knot span)

References axom::primal::NURBSCurve< T, NDIMS >::getDegree(), axom::primal::NURBSCurve< T, NDIMS >::getKnots(), axom::primal::NURBSCurve< T, NDIMS >::getMaxKnot(), axom::primal::NURBSCurve< T, NDIMS >::getMinKnot(), axom::primal::NURBSCurve< T, NDIMS >::getNumKnots(), axom::primal::NURBSCurve< T, NDIMS >::insertKnot(), axom::primal::NURBSCurve< T, NDIMS >::isRational(), axom::primal::KnotVector< T >::isValidInteriorParameter(), axom::primal::NURBSCurve< T, NDIMS >::normalize(), axom::primal::NURBSCurve< T, NDIMS >::NURBSCurve(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), axom::Array< T, DIM, SPACE, StoragePolicy >::size(), SLIC_ASSERT, and axom::primal::KnotVector< T >::splitBySpan().

◆ bisect()

template<typename T , int NDIMS>
void axom::primal::NURBSCurve< T, NDIMS >::bisect ( NURBSCurve< T, NDIMS > &  n1,
NURBSCurve< T, NDIMS > &  n2,
bool  normalizeParameters = false 
) const
inline

Splits a NURBS curve into two curves at the middle parameter value.

Parameters
[out]n1First output NURBS curve
[out]n2Second output NURBS curve
[in]normalizeParametersWhether to normalize the output curves

References axom::primal::NURBSCurve< T, NDIMS >::getMaxKnot(), axom::primal::NURBSCurve< T, NDIMS >::getMinKnot(), and axom::primal::NURBSCurve< T, NDIMS >::split().

◆ extractBezier()

template<typename T , int NDIMS>
axom::Array<BezierCurve<T, NDIMS> > axom::primal::NURBSCurve< T, NDIMS >::extractBezier ( ) const
inline

Splits a NURBS curve (at each internal knot) into several Bezier curves.

If the curve is of degree 0, will return a set of disconnected, order 0 Bezier curves

Adapted from Algorithm A5.6 on p. 173 of "The NURBS Book"

Returns
An array of Bezier curves

References axom::primal::NURBSCurve< T, NDIMS >::getDegree(), axom::primal::NURBSCurve< T, NDIMS >::getNumControlPoints(), axom::primal::KnotVector< T >::getNumKnotSpans(), axom::primal::NURBSCurve< T, NDIMS >::getWeight(), and axom::primal::NURBSCurve< T, NDIMS >::isRational().

◆ print()

template<typename T , int NDIMS>
std::ostream& axom::primal::NURBSCurve< T, NDIMS >::print ( std::ostream &  os) const
inline

Simple formatted print of a NURBS Curve instance.

Parameters
osThe output stream to write to
Returns
A reference to the modified ostream

References axom::primal::KnotVector< T >::getDegree(), axom::primal::NURBSCurve< T, NDIMS >::getNumControlPoints(), axom::primal::KnotVector< T >::getNumKnots(), and axom::primal::NURBSCurve< T, NDIMS >::isRational().

Friends And Related Function Documentation

◆ operator==

template<typename T , int NDIMS>
bool operator== ( const NURBSCurve< T, NDIMS > &  lhs,
const NURBSCurve< T, NDIMS > &  rhs 
)
friend

Equality operator for NURBS Curves.

Parameters
[in]lhsThe left-hand side NURBS curve
[in]rhsThe right-hand side NURBS curve
Returns
True if the two curves are equal, false otherwise

◆ operator!=

template<typename T , int NDIMS>
bool operator!= ( const NURBSCurve< T, NDIMS > &  lhs,
const NURBSCurve< T, NDIMS > &  rhs 
)
friend

Inequality operator for NURBS Curves.

Parameters
[in]lhsThe left-hand side NURBS curve
[in]rhsThe right-hand side NURBS curve
Returns
True if the two curves are not equal, false otherwise

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