HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_Basis Class Referenceabstract

Bezier or NURBS basis classes which maintain knot vectors. More...

#include <GA_Basis.h>

+ Inheritance diagram for GA_Basis:

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_KnotVectorgetVector () const
 
GA_KnotVectorgetVector ()
 
const GA_KnotVectorgetKnotVector () const
 
GA_KnotVectorgetKnotVector ()
 

Static Public Member Functions

static GA_BasisnewSpecies (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_KnotFloatgetData () 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
 

Detailed Description

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:

  1. The order of the basis (degree+1)
  2. The knot vector (an array of doubles)
  3. A flag for end interpolation (NURBS only)

Definition at line 49 of file GA_Basis.h.

Member Enumeration Documentation

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.

Constructor & Destructor Documentation

GA_Basis::GA_Basis ( )

The default constructor will initialize order=0 and length=0.

GA_Basis::GA_Basis ( const GA_Basis src)
virtual GA_Basis::~GA_Basis ( )
inlinevirtual

Destructor.

Definition at line 65 of file GA_Basis.h.

Member Function Documentation

int GA_Basis::append ( fpreal  v)
inline

Append a knot value to the end of the knot vector.

Definition at line 281 of file GA_Basis.h.

virtual bool GA_Basis::attach ( const GA_Basis b,
bool  overlap = true,
bool  spread = false 
)
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.

virtual bool GA_Basis::checkValid ( int  cvLen,
int  bLen,
bool  doesWrap 
) const
pure virtual

The checkValid() methods test to see whether th basis is valid given a curve with

  1. cvLen vertices
  2. A basis length of bLen
  3. Periodicity determined by doesWrap

Implemented in GA_NUBBasis, and GA_BezBasis.

bool GA_Basis::checkValid ( int  cvLen,
bool  doesWrap 
) const
inline

Convenience method to check validity using the basis's length.

Definition at line 236 of file GA_Basis.h.

virtual void GA_Basis::chord ( UT_Vector4Array cvs)
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.

virtual fpreal GA_Basis::computeBValue ( int  index,
fpreal  u 
) const
pure virtual

Compute one basis function (ie. the one with the given index) value at u.

Implemented in GA_NUBBasis, and GA_BezBasis.

void GA_Basis::computeRaiseOrderAlphas ( int  increment,
fpreal  bezalfs[][GA_MAXORDER] 
) const

Compute alphas needed for degree elevation. "increment" is the amount by which we want the degree to grow.

virtual bool GA_Basis::copyFrom ( const GA_Basis b,
bool  compatible = false 
)
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.

static void GA_Basis::doMerge ( GA_KnotVector avec,
const GA_KnotVector bvec,
GA_KnotVector inserts = 0 
)
staticprotected
virtual void GA_Basis::evalDerivativeMatrix ( fpreal  u,
int  offset,
int  deriv,
fpreal64  bmatx[][GA_MAXORDER] 
) const
pure virtual

Evaluate all the derivatives of the basis from 0 to deriv (inclusive).

Implemented in GA_NUBBasis, and GA_BezBasis.

virtual void GA_Basis::evalDerivativeMatrix ( fpreal  u,
int  offset,
int  deriv,
fpreal32  bmatx[][GA_MAXORDER] 
) const
pure virtual

Implemented in GA_NUBBasis, and GA_BezBasis.

virtual void GA_Basis::evalInterval ( fpreal  u,
int  offset,
int  deriv,
fpreal64 vals 
) const
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.

virtual void GA_Basis::evalInterval ( fpreal  u,
int  offset,
int  deriv,
fpreal32 vals 
) const
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.

bool GA_Basis::findClosest ( fpreal  val,
int idx,
int  startidx,
int  endidx 
) const

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.

int GA_Basis::findMaxSpan ( int  start,
int  stop 
) const

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.

virtual int GA_Basis::findOffset ( fpreal  k,
int  startIdx = 0 
) const
pure virtual

Find index in the knot vector for the break point corresponding to k.

Implemented in GA_NUBBasis, and GA_BezBasis.

virtual int GA_Basis::findStartOffset ( fpreal  u,
int  uoffset 
) const
pure virtual

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.

virtual int GA_Basis::getBreakCount ( ) const
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.

virtual int GA_Basis::getBreakpoints ( GA_KnotVector a,
fpreal  tol = theBasisTolerance 
) const
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.

virtual void GA_Basis::getCvRangeOfBreakpoint ( int  bkp,
int startcv,
int stopcv 
) const
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.

virtual void GA_Basis::getCvRangeOfDomain ( int  ustartidx,
int  ustopidx,
int start_cv,
int end_cv 
) const
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.

virtual void GA_Basis::getCvRangeOfDomain ( fpreal  ustart,
fpreal  ustop,
int start_cv,
int end_cv 
) const
pure virtual

Implemented in GA_NUBBasis, and GA_BezBasis.

const GA_KnotFloat* GA_Basis::getData ( ) const
inlineprotected

Definition at line 387 of file GA_Basis.h.

virtual int GA_Basis::getDimension ( ) const
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 int GA_Basis::getEndMultiplicity ( ) const
virtual

Return the expected multiplicity of the end knots (1 by default):

Reimplemented in GA_NUBBasis, and GA_BezBasis.

virtual fpreal GA_Basis::getGreville ( int  idx,
bool  clamp = true,
bool  wrap = false 
) const
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.

const GA_KnotVector& GA_Basis::getKnotVector ( ) const
inline

Get the knot vector for the basis

Definition at line 374 of file GA_Basis.h.

GA_KnotVector& GA_Basis::getKnotVector ( )
inline

Get the knot vector for the basis

Definition at line 375 of file GA_Basis.h.

int GA_Basis::getLength ( ) const
inline

Return the length of the knot vector.

Definition at line 83 of file GA_Basis.h.

virtual int64 GA_Basis::getMemoryUsage ( bool  inclusive) const
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).

virtual int GA_Basis::getMultiplicity ( fpreal  u,
int uidx 
) const
pure virtual

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.

int GA_Basis::getOrder ( ) const
inline

Return the order of the basis.

Definition at line 80 of file GA_Basis.h.

virtual GA_BASIS_TYPE GA_Basis::getType ( ) const
pure virtual

Return the type of the basis.

Implemented in GA_NUBBasis, and GA_BezBasis.

virtual const char* GA_Basis::getTypeName ( ) const
pure virtual

Return the name of the basis.

Implemented in GA_NUBBasis, and GA_BezBasis.

virtual bool GA_Basis::getValidInterval ( int a,
int b 
) const
pure virtual

Get the boundaries of the valid evaluation interval (as indices)

Implemented in GA_NUBBasis, and GA_BezBasis.

bool GA_Basis::getValidRange ( fpreal a,
fpreal b 
) const

Get the boundaries of the valid range of evaluation.

const GA_KnotVector& GA_Basis::getVector ( ) const
inline

Get the knot vector for the basis

Definition at line 372 of file GA_Basis.h.

GA_KnotVector& GA_Basis::getVector ( )
inline

Get the knot vector for the basis

Definition at line 373 of file GA_Basis.h.

virtual int GA_Basis::grow ( bool  wrapped = false)
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.

int GA_Basis::insertKnot ( fpreal  v,
int  i 
)
inline

Insert a knot value at a specific location

Note
The order of arguments is different that UT_ValArray

Definition at line 284 of file GA_Basis.h.

virtual bool GA_Basis::isEqual ( const GA_Basis basis) const
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.

JSON Schema: GA_Basis

{
"name" : "GA_Basis",
"description" : "A basis definition.",
"type" : "orderedmap",
"properties": {
"type": {
"type" : "string",
"description" : "Type of basis (case sensitive)",
"enum" : [ "Bezier", "NURBS" ],
},
"order": {
"type" : "integer",
"description" : "Order of the basis",
"minimum" : 2,
},
"endinterpolation": {
"type" : "boolean",
"description" : "End interpolation",
"default" : true,
"optional" : true,
},
"knots": {
"type" : { "$ref" : "GA_KnotVector" }
"description" : "Knot vector",
},
}
See Also
JSON_FileFormat
bool GA_Basis::jsonSave ( UT_JSONValue v) const

Save to a JSON value.

virtual int GA_Basis::knotToBreakpoint ( int kidx,
int  a,
int  b 
) const
pure virtual

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.

virtual bool GA_Basis::loadH9 ( UT_IStream is,
int  cvs,
bool  wrapped 
)
pure virtual

Implemented in GA_NUBBasis, and GA_BezBasis.

virtual void GA_Basis::makeUniform ( fpreal  ustep = 1)
pure virtual

Make the basis uniform of just find out if it is uniform:

Implemented in GA_NUBBasis, and GA_BezBasis.

void GA_Basis::map ( const GA_Basis b)

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 void GA_Basis::map ( GA_KnotVector knots,
const GA_KnotVector src,
fpreal  newlen = 1,
const fpreal neworig = 0 
)
static
void GA_Basis::map ( fpreal  newlen = 1,
const fpreal neworig = 0 
)
inline

Definition at line 320 of file GA_Basis.h.

int GA_Basis::map ( const GA_Basis b,
fpreal u,
int  uoffset = 0 
) const

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 GA_Basis* GA_Basis::newSpecies ( GA_BASIS_TYPE  type)
static

Generate a new basis of the species specified in the name or type respectively.

void GA_Basis::normalize ( fpreal  scale = 0,
const fpreal neworig = 0 
)

Convenience method to normalize this basis.

fpreal GA_Basis::realToUnit ( fpreal  u_real,
bool  valid_interval = true 
) const

Convert from real to unit values. Usually, you'll want to map only within the valid interval.

virtual void GA_Basis::rebuild ( fpreal  ustart = 0,
fpreal  ustep = 1 
)
pure virtual

Rebuild the basis as a uniform sequence with a given step.

Implemented in GA_NUBBasis, and GA_BezBasis.

int GA_Basis::remove ( int  i)
inline

Remove a knot value (by index)

Definition at line 289 of file GA_Basis.h.

virtual void GA_Basis::reset ( )
pure virtual

Re-initializes the basis to default values.

Implemented in GA_NUBBasis, and GA_BezBasis.

void GA_Basis::resize ( int  sz)
virtual void GA_Basis::reverse ( bool  wrapped)
pure virtual

Reverse the breakpoints in the basis.

Implemented in GA_NUBBasis, and GA_BezBasis.

virtual bool GA_Basis::saveH9 ( std::ostream &  os,
bool  wrapped,
bool  binary 
) const
pure virtual

I/O functions for houdini9 format.

Implemented in GA_NUBBasis, and GA_BezBasis.

void GA_Basis::setOrder ( int  ord)
inline

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.

virtual void GA_Basis::setWrapping ( bool  wrap)
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.

virtual int GA_Basis::shrink ( bool  wrapped = false)
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.

virtual bool GA_Basis::slideRange ( fpreal  umin,
fpreal  umax,
fpreal  ubias = 0.5 
)
pure virtual

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.

fpreal GA_Basis::unitToReal ( fpreal  u_unit,
bool  valid_interval = true 
) const

Convert a value from unit to real knot. Usually you'll want to map only within the valid interval.

virtual bool GA_Basis::validate ( int  adapt = GA_Basis::GA_BASIS_ADAPT_NONE)
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.

Member Data Documentation

GA_KnotVector GA_Basis::myData
protected

Definition at line 388 of file GA_Basis.h.

int GA_Basis::myOrder
protected

Definition at line 389 of file GA_Basis.h.

const fpreal GA_Basis::theBasisTolerance
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.

const fpreal GA_Basis::theBinomial[GA_MAXORDER][GA_MAXORDER]
static

Table of binomial coefficients.

Definition at line 58 of file GA_Basis.h.


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