HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GA_NUBBasis Class Reference

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

#include <GA_NUBBasis.h>

+ Inheritance diagram for GA_NUBBasis:

Public Member Functions

 GA_NUBBasis (int length=-1, int order=-1, bool end_interpolation=true)
 
 GA_NUBBasis (fpreal start, fpreal step, int length, int order=-1, bool end_interpolation=true)
 
 GA_NUBBasis (int bkpoints, int multiplicity, int ord)
 
 GA_NUBBasis (const GA_NUBBasis &src)
 
bool isEqual (const GA_Basis &basis) const
 Test to see if two bases are equal. More...
 
bool operator== (const GA_NUBBasis &a) const
 
bool operator!= (const GA_NUBBasis &a) const
 
virtual void reset ()
 Re-initializes the basis to default values. More...
 
virtual GA_BASIS_TYPE getType () const
 Return the type of the basis. More...
 
virtual const char * getTypeName () const
 Return the name of the basis. More...
 
virtual int getDimension () const
 
bool getEndInterpolation () const
 Return the end-interpolation flag. More...
 
virtual bool getValidInterval (int &a, int &b) const
 Get the boundaries of the valid evaluation interval (as indices) More...
 
int findValidStart (fpreal u, int uoffset=-1) const
 
int findStart (fpreal k, int start_idx=0) const
 
virtual void evalInterval (fpreal u, int offset, int deriv, fpreal64 *vals) const
 
virtual void evalInterval (fpreal u, int offset, int deriv, fpreal32 *vals) const
 
virtual void evalDerivativeMatrix (fpreal u, int offset, int deriv, fpreal64 bmatx[][GA_MAXORDER]) const
 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
 
virtual int findStartOffset (fpreal u, int uoffset) const
 Return the first valid segment. Returns -1 on an error. More...
 
virtual fpreal computeBValue (int index, fpreal u) const
 
bool isSimilar (const GA_NUBBasis &b) const
 
virtual int getBreakCount () const
 
virtual int knotToBreakpoint (int &kidx, int a, int b) const
 
virtual int getBreakpoints (GA_KnotVector &a, fpreal tol=theBasisTolerance) const
 
int getMultiplicity (fpreal u, int &uidx) const
 
virtual int getEndMultiplicity () const
 Return the expected multiplicity of the end knots (1 by default): More...
 
void refine (fpreal k, int kidx, int r, bool wrapped)
 
virtual void getCvRangeOfDomain (int ustartidx, int ustopidx, int &start_cv, int &end_cv) const
 
virtual void getCvRangeOfDomain (fpreal ustart, fpreal ustop, int &start_cv, int &end_cv) const
 
virtual void getCvRangeOfBreakpoint (int bkp, int &startcv, int &stopcv) const
 
virtual bool saveH9 (std::ostream &os, bool wrapped, bool binary) const
 I/O functions for houdini9 format. More...
 
virtual bool loadH9 (UT_IStream &is, int cvs, bool wrapped)
 
bool import (int order, const UT_FloatArray &knots, bool end_interpolation=true)
 
virtual bool copyFrom (const GA_Basis &b, bool compatible=false)
 
virtual bool validate (int adapt=GA_Basis::GA_BASIS_ADAPT_NONE)
 
virtual bool checkValid (int cvLen, int bLen, bool doesWrap) const
 
virtual fpreal getGreville (int idx, bool clamp=true, bool wrap=false) const
 
virtual int grow (bool wrapped=false)
 
virtual int shrink (bool wrapped=false)
 
int growAt (unsigned cvIdx, bool wrapped)
 
int shrinkAt (unsigned cvIdx, bool wrapped)
 
virtual bool attach (const GA_Basis &b, bool overlap=true, bool spread=false)
 
virtual void setWrapping (bool wrap)
 
void setEndInterpolation (bool value, bool modify_knots)
 Change end interpolation. More...
 
virtual void reverse (bool wrapped)
 Reverse the breakpoints in the basis. More...
 
virtual int findOffset (fpreal k, int startIdx=0) const
 Find index in the knot vector for the break point corresponding to k. More...
 
bool mergePartial (const GA_NUBBasis &a, const GA_NUBBasis &b, int a0, int a1, int b0, int b1, GA_KnotVector *aknots=0, GA_KnotVector *bknots=0)
 
virtual void rebuild (fpreal ustart=0, fpreal ustep=1)
 Rebuild the basis as a uniform sequence with a given step. More...
 
virtual void makeUniform (fpreal ustep=1)
 Make the basis uniform of just find out if it is uniform: More...
 
virtual void chord (UT_Vector4Array &cvs)
 
virtual bool slideRange (fpreal umin, fpreal umax, fpreal ubias=0.5)
 
bool cycle (int amount, bool keepSpan)
 Cycle the knots, optionally keeping the original span length and origin. More...
 
void toggleEndInterpolation ()
 TODO: Public for GD_PrimNURBCurve use. More...
 
void makeNURBSPeriodic ()
 
void updateEndInterpolation ()
 
virtual int64 getMemoryUsage (bool inclusive) const
 Return the amount of memory used. More...
 
bool isUniform () const
 Test whether the basis is a uniform basis. More...
 
int findBreakpoint (int idx) const
 
int findBreakpoint (fpreal t) const
 
void setKnotsByEqualSpacing (UT_Vector &param, bool wrapped=false)
 
void setKnotsByAveraging (UT_Vector &param, bool wrapped=false)
 
void setKnotsBySpreading (UT_Vector &param)
 
void setKnotsByBreakpoints (UT_Vector &param)
 
- Public Member Functions inherited from GA_Basis
 GA_Basis ()
 The default constructor will initialize order=0 and length=0. More...
 
 GA_Basis (const GA_Basis &src)
 
virtual ~GA_Basis ()
 Destructor. More...
 
int getOrder () const
 Return the order of the basis. More...
 
int getLength () const
 Return the length of the knot vector. More...
 
bool getValidRange (fpreal &a, fpreal &b) const
 Get the boundaries of the valid range of evaluation. More...
 
int getMultiplicities (UT_IntArray &arr) const
 
bool testForNan () const
 Returns true if any NANs snuck into this vector. More...
 
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...
 
bool checkValid (int cvLen, bool doesWrap) const
 Convenience method to check validity using the basis's length. 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...
 
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
 
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)
 
const GA_KnotVectorgetVector () const
 
GA_KnotVectorgetVector ()
 
const GA_KnotVectorgetKnotVector () const
 
GA_KnotVectorgetKnotVector ()
 

Additional Inherited Members

- Public Types inherited from GA_Basis
enum  { GA_BASIS_ADAPT_NONE, GA_BASIS_ADAPT_FLAGS, GA_BASIS_ADAPT_KNOTS }
 
- Static Public Member Functions inherited from GA_Basis
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 inherited from GA_Basis
static const fpreal theBasisTolerance
 
static const fpreal theBinomial [GA_MAXORDER][GA_MAXORDER]
 Table of binomial coefficients. More...
 
- Protected Member Functions inherited from GA_Basis
const GA_KnotFloatgetData () const
 
- Static Protected Member Functions inherited from GA_Basis
static void doMerge (GA_KnotVector &avec, const GA_KnotVector &bvec, GA_KnotVector *inserts=0)
 
- Protected Attributes inherited from GA_Basis
GA_KnotVector myData
 
int myOrder
 

Detailed Description

NURBS basis classes which maintain knot vectors.

The GA_NUBBasis class maintains the knot vectors for NURBS. 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
Examples:
SOP/SOP_NURBS.C.

Definition at line 44 of file GA_NUBBasis.h.

Constructor & Destructor Documentation

GA_NUBBasis::GA_NUBBasis ( int  length = -1,
int  order = -1,
bool  end_interpolation = true 
)

The default constructor will choose length/order based on the defaults for the basis type. default: order=4, length=8

GA_NUBBasis::GA_NUBBasis ( fpreal  start,
fpreal  step,
int  length,
int  order = -1,
bool  end_interpolation = true 
)
GA_NUBBasis::GA_NUBBasis ( int  bkpoints,
int  multiplicity,
int  ord 
)
GA_NUBBasis::GA_NUBBasis ( const GA_NUBBasis src)

Member Function Documentation

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

Implements GA_Basis.

virtual bool GA_NUBBasis::checkValid ( int  cvLen,
int  bLen,
bool  doesWrap 
) const
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

Implements GA_Basis.

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

Implements GA_Basis.

virtual fpreal GA_NUBBasis::computeBValue ( int  index,
fpreal  u 
) const
virtual

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

Implements GA_Basis.

virtual bool GA_NUBBasis::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 from GA_Basis.

bool GA_NUBBasis::cycle ( int  amount,
bool  keepSpan 
)

Cycle the knots, optionally keeping the original span length and origin.

virtual void GA_NUBBasis::evalDerivativeMatrix ( fpreal  u,
int  offset,
int  deriv,
fpreal64  bmatx[][GA_MAXORDER] 
) const
virtual

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

Implements GA_Basis.

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

Implements GA_Basis.

virtual void GA_NUBBasis::evalInterval ( fpreal  u,
int  offset,
int  deriv,
fpreal64 vals 
) const
virtual

Evaluate on a specific domain interval, on which at least one basis function is non-zero given domain point u.

Implements GA_Basis.

virtual void GA_NUBBasis::evalInterval ( fpreal  u,
int  offset,
int  deriv,
fpreal32 vals 
) const
virtual

Implements GA_Basis.

int GA_NUBBasis::findBreakpoint ( int  idx) const

Find the index of the last knot in the sequence that defines the given breakpoint, or the breakpoint of the domain value. Returns -1 if not found.

Note
The search is done within the limits of the valid interval.
int GA_NUBBasis::findBreakpoint ( fpreal  t) const

Find the index of the last knot in the sequence that defines the given breakpoint, or the breakpoint of the domain value. Returns -1 if not found.

Note
The search is done within the limits of the valid interval.
virtual int GA_NUBBasis::findOffset ( fpreal  k,
int  startIdx = 0 
) const
virtual

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

Implements GA_Basis.

int GA_NUBBasis::findStart ( fpreal  k,
int  start_idx = 0 
) const
inline

Return the index in the knot vector such that knotVec[idx] <= k and k < knotVec[idx+1]. If k is less than the first valid knot, return -1, and if k is greater than the last valid knot, return the index of the last valid knot (i.e. the dimension).

Definition at line 98 of file GA_NUBBasis.h.

virtual int GA_NUBBasis::findStartOffset ( fpreal  u,
int  uoffset 
) const
virtual

Return the first valid segment. Returns -1 on an error.

Implements GA_Basis.

int GA_NUBBasis::findValidStart ( fpreal  u,
int  uoffset = -1 
) const
inline

Return the index of the knot where the valid evaluation begins. Typically, for a cubic spline, this index is 3 in the end-point interpolating case and 1 otherwise. If u is completely outside the valid knot sequence, this method returns -1.

Equivalent to findStartOffset(u, uoffset).

Definition at line 91 of file GA_NUBBasis.h.

virtual int GA_NUBBasis::getBreakCount ( ) const
virtual

Return the number of breakpoints (ie. unique knots) in the knot vector, in the valid interval.

Implements GA_Basis.

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

Implements GA_Basis.

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

Implements GA_Basis.

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

Implements GA_Basis.

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

Implements GA_Basis.

virtual int GA_NUBBasis::getDimension ( ) const
virtual

Return the dimension of the basis. For NURBS, this will be equivalent to (getLength()-getOrder()).

Implements GA_Basis.

bool GA_NUBBasis::getEndInterpolation ( ) const
inline

Return the end-interpolation flag.

Definition at line 79 of file GA_NUBBasis.h.

virtual int GA_NUBBasis::getEndMultiplicity ( ) const
virtual

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

Reimplemented from GA_Basis.

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

Implements GA_Basis.

virtual int64 GA_NUBBasis::getMemoryUsage ( bool  inclusive) const
inlinevirtual

Return the amount of memory used.

Reimplemented from GA_Basis.

Definition at line 304 of file GA_NUBBasis.h.

int GA_NUBBasis::getMultiplicity ( fpreal  u,
int uidx 
) const
virtual

Return the multiplicity of a domain point or -1 if outside the domain. "uidx" is the index of the largest breakpoint <= u.

Implements GA_Basis.

virtual GA_BASIS_TYPE GA_NUBBasis::getType ( ) const
virtual

Return the type of the basis.

Implements GA_Basis.

virtual const char* GA_NUBBasis::getTypeName ( ) const
virtual

Return the name of the basis.

Implements GA_Basis.

virtual bool GA_NUBBasis::getValidInterval ( int a,
int b 
) const
virtual

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

Implements GA_Basis.

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

Implements GA_Basis.

int GA_NUBBasis::growAt ( unsigned  cvIdx,
bool  wrapped 
)

Insert a new knot as a result of a CV insertion at index cvIdx. The knot index is cvIdx + 1, which is returned by growAt() if all goes OK. -1 is returned upon failure. (NURBS basis only)

bool GA_NUBBasis::import ( int  order,
const UT_FloatArray knots,
bool  end_interpolation = true 
)

Transitional method while we might need to import data from a GB_Basis. Be careful calling this method as the order must be appropriate for the number of knots. TODO: Remove when no longer necessary.

bool GA_NUBBasis::isEqual ( const GA_Basis basis) const
virtual

Test to see if two bases are equal.

Implements GA_Basis.

bool GA_NUBBasis::isSimilar ( const GA_NUBBasis b) const

Find out if two knot sequences are similar (ie if the knot spacings are the same all over) and their knot count is the same.

bool GA_NUBBasis::isUniform ( ) const

Test whether the basis is a uniform basis.

virtual int GA_NUBBasis::knotToBreakpoint ( int kidx,
int  a,
int  b 
) const
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.

Implements GA_Basis.

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

Implements GA_Basis.

void GA_NUBBasis::makeNURBSPeriodic ( )
virtual void GA_NUBBasis::makeUniform ( fpreal  ustep = 1)
virtual

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

Implements GA_Basis.

bool GA_NUBBasis::mergePartial ( const GA_NUBBasis a,
const GA_NUBBasis b,
int  a0,
int  a1,
int  b0,
int  b1,
GA_KnotVector aknots = 0,
GA_KnotVector bknots = 0 
)

Create a new basis containing the partial merging of bases a and b If their order is different return -1. Otherwise return 0. The resultant basis contains knots a0..a1 of basis a merged with knots b0..b1 from basis b (after being mapped onto a0..a1) If the aknot or bknot array is given, they are set with the (appropriately mapped) knots values corresponding to the new insertions

bool GA_NUBBasis::operator!= ( const GA_NUBBasis a) const
inline

Definition at line 62 of file GA_NUBBasis.h.

bool GA_NUBBasis::operator== ( const GA_NUBBasis a) const
virtual void GA_NUBBasis::rebuild ( fpreal  ustart = 0,
fpreal  ustep = 1 
)
virtual

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

Implements GA_Basis.

void GA_NUBBasis::refine ( fpreal  k,
int  kidx,
int  r,
bool  wrapped 
)

Change the multiplicity of the knot by inserting it "r" times WITHOUT checking its current multiplicity. kidx is the index of a knot t such that k >= t.

virtual void GA_NUBBasis::reset ( )
virtual

Re-initializes the basis to default values.

Implements GA_Basis.

virtual void GA_NUBBasis::reverse ( bool  wrapped)
virtual

Reverse the breakpoints in the basis.

Implements GA_Basis.

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

I/O functions for houdini9 format.

Implements GA_Basis.

void GA_NUBBasis::setEndInterpolation ( bool  value,
bool  modify_knots 
)

Change end interpolation.

void GA_NUBBasis::setKnotsByAveraging ( UT_Vector param,
bool  wrapped = false 
)

Set up the knot vector with the given parameterization for the approximiation.

void GA_NUBBasis::setKnotsByBreakpoints ( UT_Vector param)

Set up the knot vector with the given parameterization for the approximiation.

void GA_NUBBasis::setKnotsByEqualSpacing ( UT_Vector param,
bool  wrapped = false 
)

Set up the knot vector with the given parameterization for the approximiation.

void GA_NUBBasis::setKnotsBySpreading ( UT_Vector param)

Set up the knot vector with the given parameterization for the approximiation.

virtual void GA_NUBBasis::setWrapping ( bool  wrap)
virtual

Change the size of the basis (and maybe some of its values too) to make it a valid basis for wrapped splines.

Implements GA_Basis.

virtual int GA_NUBBasis::shrink ( bool  wrapped = false)
virtual

Shrink the basis by one. The basis should not shrink beyond a valid length. Return the new length.

Implements GA_Basis.

int GA_NUBBasis::shrinkAt ( unsigned  cvIdx,
bool  wrapped 
)

Delete a knot as a result of a CV removal at index cvIdx. The knot index is cvIdx + 1. The method returns the new length if successful, and -1 otherwise.

virtual bool GA_NUBBasis::slideRange ( fpreal  umin,
fpreal  umax,
fpreal  ubias = 0.5 
)
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].

Implements GA_Basis.

void GA_NUBBasis::toggleEndInterpolation ( )
inline

TODO: Public for GD_PrimNURBCurve use.

Definition at line 296 of file GA_NUBBasis.h.

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

Implements GA_Basis.


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