|
AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Represents the knot vector for a B-Spline/NURBS Curve/Surface. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/primal/geometry/KnotVector.hpp>
Classes | |
| class | DerivativeBasisView |
| struct | DerivativeBasisWorkspace |
| Scratch storage for derivativeBasisFunctionsBySpan(...) More... | |
Public Member Functions | |
| AXOM_STATIC_ASSERT_MSG (std::is_arithmetic< T >::value, "A knot vector must be defined using an arithmetic type") | |
| std::ostream & | print (std::ostream &os) const |
| Simple formatted print of a knot vector instance. More... | |
Constructors for KnotVector | |
The KnotVector class provides constructors that allow initialization from a user-supplied array of knots and a specified degree and enforces several conditions to ensure validity:
These checks guarantee that the constructed KnotVector adheres to the requirements for B-Spline/NURBS curves, such as monotonicity, clamped ends, and appropriate internal knot multiplicity. The isValid() method is used to verify that the resulting instance meets all necessary criteria for a valid knot span. | |
| KnotVector (axom::ArrayView< const T > knots, int degree) | |
| Constructor from a user-supplied knot vector (axom::ArrayView<const T>) More... | |
| KnotVector (axom::ArrayView< T > knots, int degree) | |
| KnotVector () | |
| Default constructor for an empty (invalid) knot vector. More... | |
| KnotVector (axom::IndexType npts, int degree) | |
| Constructor for a normalized, uniform knot vector. More... | |
| KnotVector (const T *knots, axom::IndexType nkts, int degree) | |
| Constructor from a user-supplied knot vector (C-style array) More... | |
| KnotVector (const axom::Array< T > &knots, int degree) | |
| Constructor from a user-supplied knot vector (axom::Array) More... | |
Query/modify knot vector properties and sizes | |
| void | makeUniform (axom::IndexType npts, int deg) |
| Give the knot vector uniformly spaced internal knots. More... | |
| int | getDegree () const |
| Return the degree of the knot vector. More... | |
| void | setDegree (int degree) |
| Reset the knot vector for the given degree. More... | |
| axom::IndexType | getNumKnots () const |
| Return the number of knots in the knot vector. More... | |
| axom::IndexType | getNumControlPoints () const |
| Return the number of control points implied by the knot vector. More... | |
| T | getMinKnot () const |
| Return the value of the smallest knot, or 0 if there are no knots. More... | |
| T | getMaxKnot () const |
| Return the value of the largest knot, or 0 if there are no knots. More... | |
| void | clear () |
| Clear the list of knots. More... | |
| bool | isValid () const |
| Return if the knot vector is valid. More... | |
| bool | isValidSpan (axom::IndexType span) const |
| Check if a knot span is valid. More... | |
| bool | isValidSpan (axom::IndexType span, T t) const |
| Check if a knot span is valid and contains the parameter value t. More... | |
Query/modify/access knots | |
| axom::Array< T > & | getArray () |
| Accessor for the array of knots. More... | |
| const axom::Array< T > & | getArray () const |
| Const accessor for the array of knots. More... | |
| const T & | operator[] (axom::IndexType i) const |
| Getter for the knot vector. More... | |
| T & | operator[] (axom::IndexType i) |
| Setter for the knot vector. More... | |
| axom::Array< T > | getUniqueKnots () const |
| Return an array of the unique knot values. More... | |
| axom::IndexType | getNumKnotSpans () const |
| Return the number of valid knot spans. More... | |
Query/modify KnotVector parametrization | |
| 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... | |
| void | reverse () |
| Reverse the knot vector. More... | |
| void | insertKnotBySpan (axom::IndexType span, T t, int r) |
| Insert a knot into the vector r times. More... | |
| void | insertKnot (T t, int target_multiplicity) |
| Insert a knot into the vector to have the given multiplicity. More... | |
| bool | isValidParameter (T t, T EPS=1e-5) const |
| Checks if given parameter is in knot span (to a tolerance) More... | |
| bool | isValidInteriorParameter (T t) const |
| Checks if given parameter is interior to knot span (to a tolerance) More... | |
Functions for evaluating knot vector | |
| axom::IndexType | findSpan (T t) const |
| Returns the index of the knot span containing parameter t. More... | |
| axom::IndexType | findSpan (T t, int &multiplicity) const |
| Returns the index of the knot span containing parameter t and its multiplicity. More... | |
| axom::Array< T > | calculateBasisFunctionsBySpan (axom::IndexType span, T t) const |
| Evaluates the NURBS basis functions for span at parameter value t. More... | |
| axom::Array< T > | calculateBasisFunctions (T t) const |
| Evaluates the NURBS basis functions for parameter value t. More... | |
| axom::Array< axom::Array< T > > | derivativeBasisFunctionsBySpan (axom::IndexType span, T t, int n) const |
| Evaluates the NURBS basis functions and derivatives for span at parameter value t. More... | |
| DerivativeBasisView | derivativeBasisFunctionsBySpan (axom::IndexType span, T t, int n, DerivativeBasisWorkspace &workspace) const |
| Evaluates the NURBS basis functions and derivatives using a caller-supplied workspace. More... | |
| axom::Array< axom::Array< T > > | derivativeBasisFunctions (T t, int n) const |
| Evaluates the NURBS basis functions and derivatives for parameter value t. More... | |
Functions dealing with knot vector subdivision | |
| void | splitBySpan (axom::IndexType span, KnotVector &k1, KnotVector &k2, bool normalize=false) const |
Split a knot vector at the value at index span More... | |
| void | split (T t, KnotVector &k1, KnotVector &k2, bool normalize=false) const |
| Split a knot vector at the value t. More... | |
Friends | |
| bool | operator== (const KnotVector< T > &lhs, const KnotVector< T > &rhs) |
| Check equality of two knot vectors. More... | |
| bool | operator!= (const KnotVector< T > &lhs, const KnotVector< T > &rhs) |
| Check inequality of two knot vectors. More... | |
Represents the knot vector for a B-Spline/NURBS Curve/Surface.
| T | the coordinate type, e.g., double, float, etc. |
Contains methods for knot vector manipulation shared between NURBS curves and surfaces. This class maintains the degree and requirements on a knot vector, namely
Monotonicity (u_i <= u_i+1) Open/Clamped-ness (degree + 1 knots at beginning and end) Continuity (maximum internal knot multiplicity = degree)
|
inline |
Constructor from a user-supplied knot vector (axom::ArrayView<const T>)
| [in] | knots | the knot vector |
| [in] | degree | the degree of the curve |
References axom::ArrayView< T, DIM, SPACE >::data(), axom::ArrayView< T, DIM, SPACE >::empty(), axom::primal::KnotVector< T >::isValid(), axom::ArrayView< T, DIM, SPACE >::size(), and SLIC_ASSERT.
|
inline |
|
inline |
Default constructor for an empty (invalid) knot vector.
|
inline |
Constructor for a normalized, uniform knot vector.
| [in] | npts | the number of control points |
| [in] | degree | the degree |
References axom::primal::KnotVector< T >::makeUniform().
|
inline |
Constructor from a user-supplied knot vector (C-style array)
| [in] | knots | the knot vector |
| [in] | nkts | the length of the knot vector |
| [in] | degree | the degree of the curve |
|
inline |
Constructor from a user-supplied knot vector (axom::Array)
| [in] | knots | the knot vector |
| [in] | degree | the degree of the curve |
| axom::primal::KnotVector< T >::AXOM_STATIC_ASSERT_MSG | ( | std::is_arithmetic< T >::value | , |
| "A knot vector must be defined using an arithmetic type" | |||
| ) |
|
inline |
Give the knot vector uniformly spaced internal knots.
| [in] | npts | The number of (implied) control points |
| [in] | deg | The degree of the curve |
References SLIC_ASSERT.
|
inline |
Return the degree of the knot vector.
|
inline |
Reset the knot vector for the given degree.
| [in] | degree | The target degree |
If the target degree is greater than the current degree, the knot vector must be expanded to remain valid (clamped)
References axom::primal::KnotVector< T >::getNumControlPoints(), axom::primal::KnotVector< T >::makeUniform(), and SLIC_ASSERT.
|
inline |
Return the number of knots in the knot vector.
|
inline |
Return the number of control points implied by the knot vector.
|
inline |
Return the value of the smallest knot, or 0 if there are no knots.
|
inline |
Return the value of the largest knot, or 0 if there are no knots.
|
inline |
Clear the list of knots.
|
inline |
Return if the knot vector is valid.
References axom::primal::KnotVector< T >::getMaxKnot(), and axom::primal::KnotVector< T >::getMinKnot().
|
inline |
Check if a knot span is valid.
| [in] | span | The span to check |
A valid span is one that is within the knot vector and has a non-zero length
|
inline |
Check if a knot span is valid and contains the parameter value t.
| [in] | span | The span to check |
| [in] | t | The parameter value |
A valid span is one that is within the knot vector, has a non-zero length, and contains the parameter value t
References axom::primal::KnotVector< T >::isValidSpan().
|
inline |
Accessor for the array of knots.
|
inline |
Const accessor for the array of knots.
|
inline |
Getter for the knot vector.
| [in] | i | The vector index |
|
inline |
Setter for the knot vector.
| [in] | i | The vector index |
References axom::primal::KnotVector< T >::isValid(), and SLIC_ASSERT.
|
inline |
Return an array of the unique knot values.
References axom::Array< T, DIM, SPACE, StoragePolicy >::push_back().
|
inline |
Return the number of valid knot spans.
|
inline |
Normalize the knot vector to the span of [0, 1].
References axom::primal::KnotVector< T >::getMaxKnot(), and axom::primal::KnotVector< T >::getMinKnot().
|
inline |
Rescale the knot vector to the span of [a, b].
| [in] | a | The lower bound of the new knot vector |
| [in] | b | The upper bound of the new knot vector |
References axom::primal::KnotVector< T >::getMaxKnot(), axom::primal::KnotVector< T >::getMinKnot(), axom::utilities::lerp(), and SLIC_ASSERT.
|
inline |
Reverse the knot vector.
References axom::primal::KnotVector< T >::getMaxKnot(), axom::primal::KnotVector< T >::getMinKnot(), and axom::utilities::swap().
|
inline |
Insert a knot into the vector r times.
| [in] | span | The span into which the knot will be inserted |
| [in] | t | The value of the knot to insert |
| [in] | r | The number of times to insert the knot |
References axom::primal::KnotVector< T >::isValid(), axom::primal::KnotVector< T >::isValidSpan(), and SLIC_ASSERT.
|
inline |
Insert a knot into the vector to have the given multiplicity.
| [in] | t | The value of the knot to insert |
| [in] | target_mutliplicity | The number of times the knot will be present |
References axom::utilities::clampVal(), axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::insertKnotBySpan(), axom::primal::KnotVector< T >::isValidParameter(), and SLIC_ASSERT.
|
inline |
Checks if given parameter is in knot span (to a tolerance)
References axom::primal::KnotVector< T >::getMaxKnot(), and axom::primal::KnotVector< T >::getMinKnot().
|
inline |
Checks if given parameter is interior to knot span (to a tolerance)
References axom::primal::KnotVector< T >::getMaxKnot(), and axom::primal::KnotVector< T >::getMinKnot().
|
inline |
Returns the index of the knot span containing parameter t.
| [in] | t | The parameter value |
For knot vector {u_0, ..., u_n}, returns i such that u_i <= t < u_i+1 if t == u_n, returns i such that u_i < t <= u_i+1 (i.e. i = n - degree - 1)
Implementation adapted from Algorithm A2.1 on page 68 of "The NURBS Book"
References axom::primal::KnotVector< T >::getMaxKnot(), axom::primal::KnotVector< T >::getMinKnot(), axom::primal::KnotVector< T >::isValidParameter(), and SLIC_ASSERT.
|
inline |
Returns the index of the knot span containing parameter t and its multiplicity.
| [in] | t | The parameter value |
| [out] | multiplicity | The multiplicity of the knot at t |
For knot vector {u_0, ..., u_n}, returns i such that u_i <= t < u_i+1 if t == u_n, returns i such that u_i < t <= u_i+1 (i.e. i = n - degree - 1)
References axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::getMaxKnot(), axom::primal::KnotVector< T >::getMinKnot(), axom::primal::KnotVector< T >::isValidParameter(), and SLIC_ASSERT.
|
inline |
Evaluates the NURBS basis functions for span at parameter value t.
| [in] | span | The span in which to evaluate the basis functions |
| [in] | t | The parameter value |
m_deg + 1 non-zero basis functions evaluated at t References axom::primal::KnotVector< T >::isValidSpan(), and SLIC_ASSERT.
|
inline |
Evaluates the NURBS basis functions for parameter value t.
| [in] | t | The parameter value |
m_deg + 1 non-zero basis functions evaluated at t References axom::primal::KnotVector< T >::calculateBasisFunctionsBySpan(), axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::isValidParameter(), and SLIC_ASSERT.
|
inline |
Evaluates the NURBS basis functions and derivatives for span at parameter value t.
| [in] | span | The span in which to evaluate the basis functions |
| [in] | t | The parameter value |
| [in] | n | The number of derivatives to compute |
Implementation adapted from Algorithm A2.2 on page 70 of "The NURBS Book".
n + 1 derivatives evaluated at t References axom::primal::KnotVector< T >::isValidSpan(), axom::Array< T, DIM, SPACE, StoragePolicy >::resize(), SLIC_ASSERT, and axom::utilities::swap().
|
inline |
Evaluates the NURBS basis functions and derivatives using a caller-supplied workspace.
References axom::primal::KnotVector< T >::DerivativeBasisWorkspace::a, axom::primal::KnotVector< T >::DerivativeBasisWorkspace::ders, axom::primal::KnotVector< T >::DerivativeBasisWorkspace::ensure(), axom::primal::KnotVector< T >::isValidSpan(), axom::primal::KnotVector< T >::DerivativeBasisWorkspace::left, axom::primal::KnotVector< T >::DerivativeBasisWorkspace::ndu, axom::primal::KnotVector< T >::DerivativeBasisWorkspace::right, SLIC_ASSERT, and axom::utilities::swap().
|
inline |
Evaluates the NURBS basis functions and derivatives for parameter value t.
| [in] | t | The parameter value |
| [in] | n | The number of derivatives to compute |
n + 1 derivatives evaluated at t References axom::primal::KnotVector< T >::derivativeBasisFunctionsBySpan(), axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::isValidParameter(), and SLIC_ASSERT.
|
inline |
Split a knot vector at the value at index span
| [in] | span | The span at which the knot will be split |
| [out] | k1 | The first knot vector |
| [out] | k2 | The second knot vector |
| [in] | normalize | Whether to normalize the output knot vectors |
References axom::primal::KnotVector< T >::getNumKnots(), axom::primal::KnotVector< T >::isValid(), axom::primal::KnotVector< T >::isValidSpan(), axom::primal::KnotVector< T >::normalize(), and SLIC_ASSERT.
|
inline |
Split a knot vector at the value t.
| [in] | t | The value at which the knot will be split |
| [out] | k1 | The first knot vector |
| [out] | k2 | The second knot vector |
| [in] | normalize | Whether to normalize the output knot vectors |
References axom::primal::KnotVector< T >::findSpan(), axom::primal::KnotVector< T >::insertKnotBySpan(), axom::primal::KnotVector< T >::isValidInteriorParameter(), axom::primal::KnotVector< T >::normalize(), SLIC_ASSERT, and axom::primal::KnotVector< T >::splitBySpan().
|
inline |
Simple formatted print of a knot vector instance.
| os | The output stream to write to |
|
friend |
Check equality of two knot vectors.
| [in] | lhs | The first knot vector |
| [in] | rhs | The second knot vector |
|
friend |
Check inequality of two knot vectors.
| [in] | lhs | The first knot vector |
| [in] | rhs | The second knot vector |