HDK
|
Bezier or NURBS basis classes which maintain knot vectors. More...
#include <GA_Basis.h>
Public Types | |
enum | { GA_BASIS_ADAPT_NONE, GA_BASIS_ADAPT_FLAGS, GA_BASIS_ADAPT_KNOTS } |
Public Member Functions | |
GA_Basis () | |
The default constructor will initialize order=0 and length=0. More... | |
GA_Basis (const GA_Basis &src) | |
virtual | ~GA_Basis () |
Destructor. More... | |
virtual void | reset ()=0 |
Re-initializes the basis to default values. More... | |
virtual bool | isEqual (const GA_Basis &basis) const =0 |
Compare to see whether the basis is equal. More... | |
virtual GA_BASIS_TYPE | getType () const =0 |
Return the type of the basis. More... | |
virtual const char * | getTypeName () const =0 |
Return the name of the basis. More... | |
int | getOrder () const |
Return the order of the basis. More... | |
int | getLength () const |
Return the length of the knot vector. More... | |
virtual int | getDimension () const =0 |
virtual bool | getValidInterval (int &a, int &b) const =0 |
Get the boundaries of the valid evaluation interval (as indices) More... | |
bool | getValidRange (fpreal &a, fpreal &b) const |
Get the boundaries of the valid range of evaluation. More... | |
virtual void | evalInterval (fpreal u, int offset, int deriv, fpreal64 *vals) const =0 |
virtual void | evalInterval (fpreal u, int offset, int deriv, fpreal32 *vals) const =0 |
virtual void | evalDerivativeMatrix (fpreal u, int offset, int deriv, fpreal64 bmatx[][GA_MAXORDER]) const =0 |
Evaluate all the derivatives of the basis from 0 to deriv (inclusive). More... | |
virtual void | evalDerivativeMatrix (fpreal u, int offset, int deriv, fpreal32 bmatx[][GA_MAXORDER]) const =0 |
virtual int | findStartOffset (fpreal u, int uoffset) const =0 |
virtual fpreal | computeBValue (int index, fpreal u) const =0 |
virtual int | getBreakCount () const =0 |
virtual int | knotToBreakpoint (int &kidx, int a, int b) const =0 |
virtual int | getBreakpoints (GA_KnotVector &a, fpreal tol=theBasisTolerance) const =0 |
int | getMultiplicities (UT_IntArray &arr) const |
virtual int | getMultiplicity (fpreal u, int &uidx) const =0 |
virtual int | getEndMultiplicity () const |
Return the expected multiplicity of the end knots (1 by default): More... | |
virtual void | getCvRangeOfDomain (int ustartidx, int ustopidx, int &start_cv, int &end_cv) const =0 |
virtual void | getCvRangeOfDomain (fpreal ustart, fpreal ustop, int &start_cv, int &end_cv) const =0 |
virtual void | getCvRangeOfBreakpoint (int bkp, int &startcv, int &stopcv) const =0 |
bool | testForNan () const |
Returns true if any NANs snuck into this vector. More... | |
virtual bool | saveH9 (std::ostream &os, bool wrapped, bool binary) const =0 |
I/O functions for houdini9 format. More... | |
virtual bool | loadH9 (UT_IStream &is, int cvs, bool wrapped)=0 |
bool | jsonSave (UT_JSONWriter &w) const |
bool | jsonSave (UT_JSONValue &v) const |
Save to a JSON value. More... | |
bool | jsonLoad (UT_JSONParser &p) |
Load basis from a JSON parser. More... | |
bool | jsonLoad (UT_JSONParser &p, const UT_JSONValue &v) |
Load basis from a JSON value. More... | |
virtual bool | copyFrom (const GA_Basis &b, bool compatible=false) |
virtual bool | validate (int adapt=GA_Basis::GA_BASIS_ADAPT_NONE)=0 |
virtual bool | checkValid (int cvLen, int bLen, bool doesWrap) const =0 |
bool | checkValid (int cvLen, bool doesWrap) const |
Convenience method to check validity using the basis's length. More... | |
virtual fpreal | getGreville (int idx, bool clamp=true, bool wrap=false) const =0 |
virtual int | grow (bool wrapped=false)=0 |
virtual int | shrink (bool wrapped=false)=0 |
virtual bool | attach (const GA_Basis &b, bool overlap=true, bool spread=false)=0 |
virtual void | setWrapping (bool wrap)=0 |
virtual void | reverse (bool wrapped)=0 |
Reverse the breakpoints in the basis. More... | |
virtual int | findOffset (fpreal k, int startIdx=0) const =0 |
Find index in the knot vector for the break point corresponding to k. More... | |
fpreal | unitToReal (fpreal u_unit, bool valid_interval=true) const |
fpreal | realToUnit (fpreal u_real, bool valid_interval=true) const |
int | append (fpreal v) |
Append a knot value to the end of the knot vector. More... | |
int | insertKnot (fpreal v, int i) |
int | remove (int i) |
Remove a knot value (by index) More... | |
bool | merge (const GA_Basis &b) |
bool | merge (GA_Basis &b) |
int | findMaxSpan (int start, int stop) const |
void | normalize (fpreal scale=0, const fpreal *neworig=0) |
Convenience method to normalize this basis. More... | |
virtual void | rebuild (fpreal ustart=0, fpreal ustep=1)=0 |
Rebuild the basis as a uniform sequence with a given step. More... | |
virtual void | makeUniform (fpreal ustep=1)=0 |
Make the basis uniform of just find out if it is uniform: More... | |
void | map (const GA_Basis &b) |
void | map (fpreal newlen=1, const fpreal *neworig=0) |
int | map (const GA_Basis &b, fpreal &u, int uoffset=0) const |
virtual void | chord (UT_Vector4Array &cvs)=0 |
virtual bool | slideRange (fpreal umin, fpreal umax, fpreal ubias=0.5)=0 |
void | setOrder (int ord) |
bool | findClosest (fpreal val, int &idx, int startidx, int endidx) const |
int | findApproximate (fpreal val, int startidx, fpreal tol=theBasisTolerance) const |
void | computeRaiseOrderAlphas (int increment, fpreal bezalfs[][GA_MAXORDER]) const |
void | resize (int sz) |
virtual int64 | getMemoryUsage (bool inclusive) const |
Return the amount of memory used. More... | |
const GA_KnotVector & | getVector () const |
GA_KnotVector & | getVector () |
const GA_KnotVector & | getKnotVector () const |
GA_KnotVector & | getKnotVector () |
Static Public Member Functions | |
static GA_Basis * | newSpecies (GA_BASIS_TYPE type) |
static void | map (GA_KnotVector &knots, const GA_KnotVector &src, fpreal newlen=1, const fpreal *neworig=0) |
Static Public Attributes | |
static const fpreal | theBasisTolerance |
static const fpreal | theBinomial [GA_MAXORDER][GA_MAXORDER] |
Table of binomial coefficients. More... | |
Protected Member Functions | |
const GA_KnotFloat * | getData () const |
Static Protected Member Functions | |
static void | doMerge (GA_KnotVector &avec, const GA_KnotVector &bvec, GA_KnotVector *inserts=0) |
Protected Attributes | |
GA_KnotVector | myData |
int | myOrder |
Bezier or NURBS basis classes which maintain knot vectors.
The GA_Basis class maintains the knot vectors for Bezier or NURBS splines. The basis consists of:
Definition at line 49 of file GA_Basis.h.
anonymous enum |
When making the basis valid, the adapt enum will be used to adjust the end-interpolation and knot values to ensure that the basis is valid.
Enumerator | |
---|---|
GA_BASIS_ADAPT_NONE | |
GA_BASIS_ADAPT_FLAGS | |
GA_BASIS_ADAPT_KNOTS |
Definition at line 219 of file GA_Basis.h.
GA_Basis::GA_Basis | ( | ) |
The default constructor will initialize order=0 and length=0.
GA_Basis::GA_Basis | ( | const GA_Basis & | src | ) |
|
inlinevirtual |
Destructor.
Definition at line 65 of file GA_Basis.h.
Append a knot value to the end of the knot vector.
Definition at line 281 of file GA_Basis.h.
|
pure virtual |
Attach another basis to us and grow our basis as a result. The bases must have the same type and order. If "overlap" is true, we overlap the beginning of b with our end. Spreading makes sense when you can have multiple knots in the basis, and causes identical knots to be spread within range of the neighbouring knots.
Implemented in GA_NUBBasis, and GA_BezBasis.
The checkValid() methods test to see whether th basis is valid given a curve with
Implemented in GA_NUBBasis, and GA_BezBasis.
|
inline |
Convenience method to check validity using the basis's length.
Definition at line 236 of file GA_Basis.h.
|
pure virtual |
Reparameterize the basis using the chord-length method, and clamp it to the valid interval. The origin and length of the valid domain remains unchanged.
Implemented in GA_NUBBasis, and GA_BezBasis.
Compute one basis function (ie. the one with the given index) value at u.
Implemented in GA_NUBBasis, and GA_BezBasis.
Compute alphas needed for degree elevation. "increment" is the amount by which we want the degree to grow.
|
virtual |
Copy my data from the given source. If performing a compatible copy, we only do the copy if if b has the same order and length as we do.
Reimplemented in GA_NUBBasis.
|
staticprotected |
|
pure virtual |
Evaluate all the derivatives of the basis from 0 to deriv (inclusive).
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Evaluate on a specific domain interval, on which at least one basis function is non-zero given domain point u.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Implemented in GA_NUBBasis, and GA_BezBasis.
int GA_Basis::findApproximate | ( | fpreal | val, |
int | startidx, | ||
fpreal | tol = theBasisTolerance |
||
) | const |
Return the index of the first knot that is approximately equal to val. The entire sequence is searched from startidx. Return -1 if not found.
Get the greatest value knot that is smaller than the search value. Return false if search value is out of range. The default search range is from order-1 to dimension.
Find the index of a breakpoint such that the distance between it and the next breakpoint is the largest in the whole sequence. The search is done between two specified indices.
Find index in the knot vector for the break point corresponding to k.
Implemented in GA_NUBBasis, and GA_BezBasis.
Return either the break-point (Bezier) or the first valid segment for NURBs. Returns -1 on an error.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Return the number of breakpoints (ie. unique knots) in the knot vector, in the valid interval.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Compute an array of breakpoints (i.e. unique knots) in the valid interval and return their number. The tolerance is used to differentiate between close knots.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Given valid breakpoint index, compute the range of CVs that have a non-zero influence at the knot of the breakpoint. Since the basis doesn't know about wrapping, the endcv index might be higher than the spline's number of CVs.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Given a domain range in the valid interval, compute the range of CVs that will be involved in the evaluation of the curve in that range. Since the basis doesn't know about wrapping, the endcv index might be higher than the spline's number of CVs.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Implemented in GA_NUBBasis, and GA_BezBasis.
|
inlineprotected |
Definition at line 387 of file GA_Basis.h.
|
pure virtual |
Return the dimension of the basis. For NURBS, this will be equivalent to (getLength()-getOrder()). For Beziers the dimension is equivalent to the length of the knot vector.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
virtual |
Return the expected multiplicity of the end knots (1 by default):
Reimplemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Compute the idx'th greville abscissa of the domain vector. Clamping to the valid interval is optional and might not make any difference for some spline types.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
inline |
Get the knot vector for the basis
Definition at line 374 of file GA_Basis.h.
|
inline |
Get the knot vector for the basis
Definition at line 375 of file GA_Basis.h.
|
inline |
Return the length of the knot vector.
Definition at line 83 of file GA_Basis.h.
|
inlinevirtual |
Return the amount of memory used.
Reimplemented in GA_NUBBasis.
Definition at line 379 of file GA_Basis.h.
int GA_Basis::getMultiplicities | ( | UT_IntArray & | arr | ) | const |
Compute an array of multiplicities for each knot in the knot sequence. Return the number of breakpoints (i.e. unique knots).
Return the multiplicity of a domain point or -1 if outside the domain. "uidx" is the index of the largest breakpoint <= u.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
inline |
Return the order of the basis.
Definition at line 80 of file GA_Basis.h.
|
pure virtual |
Return the type of the basis.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Return the name of the basis.
Implemented in GA_NUBBasis, and GA_BezBasis.
Get the boundaries of the valid evaluation interval (as indices)
Implemented in GA_NUBBasis, and GA_BezBasis.
Get the boundaries of the valid range of evaluation.
|
inline |
Get the knot vector for the basis
Definition at line 372 of file GA_Basis.h.
|
inline |
Get the knot vector for the basis
Definition at line 373 of file GA_Basis.h.
|
pure virtual |
Grow the length of the basis by one, and set the value of the new entry to last knot+1. The method returns the index of the appended element.
Implemented in GA_NUBBasis, and GA_BezBasis.
Insert a knot value at a specific location
Definition at line 284 of file GA_Basis.h.
|
pure virtual |
Compare to see whether the basis is equal.
Implemented in GA_NUBBasis, and GA_BezBasis.
bool GA_Basis::jsonLoad | ( | UT_JSONParser & | p | ) |
Load basis from a JSON parser.
bool GA_Basis::jsonLoad | ( | UT_JSONParser & | p, |
const UT_JSONValue & | v | ||
) |
Load basis from a JSON value.
bool GA_Basis::jsonSave | ( | UT_JSONWriter & | w | ) | const |
Save data to a JSON stream.
bool GA_Basis::jsonSave | ( | UT_JSONValue & | v | ) | const |
Save to a JSON value.
Given the index of a knot (kidx) and two bounds in the knot sequence (a and b) find out the index of the breakpoint that the knot represents, and possibly adjust kidx so that knot[kidx+1] > knot[kidx]. Return -1 if not found.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Implemented in GA_NUBBasis, and GA_BezBasis.
Make the basis uniform of just find out if it is uniform:
Implemented in GA_NUBBasis, and GA_BezBasis.
Normalize the vector to the new length and optionally shift it to a new origin. If "knots" is given, the resulting values are put in it. The first method maps us to the interval of basis "b". In other words, our extremities will be changed to match those of basis "b".
|
static |
Definition at line 320 of file GA_Basis.h.
Map domain value "u", which should be between our min and max knots, to a domain value in basis "b". If you know the index of the knot in our sequence such that k[uoffset] <= u, enter in as the last parameter. The method returns -1 if it has failed (the two bases don't have the same length or u is out of range). Otherwise it returns the uoffset.
bool GA_Basis::merge | ( | const GA_Basis & | b | ) |
Merge the given basis into ours provided they both have the same order. If their order is different returns false. Otherwise return true. A copy of "b"'s knots is mapped to our knot interval first, then merged with us. The second method stres the mapping into "b" itself.
bool GA_Basis::merge | ( | GA_Basis & | b | ) |
|
static |
Generate a new basis of the species specified in the name or type respectively.
Convenience method to normalize this basis.
Convert from real to unit values. Usually, you'll want to map only within the valid interval.
Rebuild the basis as a uniform sequence with a given step.
Implemented in GA_NUBBasis, and GA_BezBasis.
Remove a knot value (by index)
Definition at line 289 of file GA_Basis.h.
|
pure virtual |
Re-initializes the basis to default values.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Reverse the breakpoints in the basis.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
I/O functions for houdini9 format.
Implemented in GA_NUBBasis, and GA_BezBasis.
Set the order of the basis. Careful when you use it because it must be <= GA_MAXORDER and must be appropriate for the number of knots.
Definition at line 348 of file GA_Basis.h.
|
pure virtual |
Change the size of the basis (and maybe some of its values too) to make it a valid basis for wrapped splines.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
pure virtual |
Shrink the basis by one. The basis should not shrink beyond a valid length. Return the new length.
Implemented in GA_NUBBasis, and GA_BezBasis.
Slide the knots found in the given range left or right by an amount at most as large as the distance to the nearest knot outside the range. The bias is a percentage value of the left-right distance, its default value is 0.5 (i.e. don't change anything), and is clamped to [0,1].
Implemented in GA_NUBBasis, and GA_BezBasis.
bool GA_Basis::testForNan | ( | ) | const |
Returns true if any NANs snuck into this vector.
Convert a value from unit to real knot. Usually you'll want to map only within the valid interval.
|
pure virtual |
The validate() method will force the basis to be valid (if possible). The adapt enum can be used to control the behaviour of this method.
Implemented in GA_NUBBasis, and GA_BezBasis.
|
protected |
Definition at line 388 of file GA_Basis.h.
|
protected |
Definition at line 389 of file GA_Basis.h.
|
static |
Tolerance used to check equality of knot values. The default of 1e-5 used by SYSisEqual et al. is too large for NURBS curves with 45K vertices.
Definition at line 55 of file GA_Basis.h.
|
static |
Table of binomial coefficients.
Definition at line 58 of file GA_Basis.h.