HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 override
 Test to see if two bases are equal. More...
 
bool operator== (const GA_NUBBasis &a) const
 
bool operator!= (const GA_NUBBasis &a) const
 
void reset () override
 Re-initializes the basis to default values. More...
 
GA_BASIS_TYPE getType () const override
 Return the type of the basis. More...
 
const char * getTypeName () const override
 Return the name of the basis. More...
 
int getDimension () const override
 
bool getEndInterpolation () const
 Return the end-interpolation flag. More...
 
bool getValidInterval (int &a, int &b) const override
 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
 
void evalInterval (fpreal u, int offset, int deriv, fpreal64 *vals) const override
 
void evalInterval (fpreal u, int offset, int deriv, fpreal32 *vals) const override
 
void evalDerivativeMatrix (fpreal u, int offset, int deriv, fpreal64 bmatx[][GA_MAXORDER]) const override
 Evaluate all the derivatives of the basis from 0 to deriv (inclusive). More...
 
void evalDerivativeMatrix (fpreal u, int offset, int deriv, fpreal32 bmatx[][GA_MAXORDER]) const override
 
int findStartOffset (fpreal u, int uoffset) const override
 Return the first valid segment. Returns -1 on an error. More...
 
fpreal computeBValue (int index, fpreal u) const override
 
bool isSimilar (const GA_NUBBasis &b) const
 
int getBreakCount () const override
 
int knotToBreakpoint (int &kidx, int a, int b) const override
 
int getBreakpoints (GA_KnotVector &a, fpreal tol=theBasisTolerance) const override
 
int getMultiplicity (fpreal u, int &uidx) const override
 
int getEndMultiplicity () const override
 Return the expected multiplicity of the end knots (1 by default): More...
 
void refine (fpreal k, int kidx, int r, bool wrapped)
 
void getCvRangeOfDomain (int ustartidx, int ustopidx, int &start_cv, int &end_cv) const override
 
void getCvRangeOfDomain (fpreal ustart, fpreal ustop, int &start_cv, int &end_cv) const override
 
void getCvRangeOfBreakpoint (int bkp, int &startcv, int &stopcv) const override
 
bool saveH9 (std::ostream &os, bool wrapped, bool binary) const override
 I/O functions for houdini9 format. More...
 
bool loadH9 (UT_IStream &is, int cvs, bool wrapped) override
 
bool import (int order, const UT_FloatArray &knots, bool end_interpolation=true)
 
bool copyFrom (const GA_Basis &b, bool compatible=false) override
 
bool validate (int adapt=GA_Basis::GA_BASIS_ADAPT_NONE) override
 
bool checkValid (int cv_len, int b_len, bool does_wrap) const override
 
fpreal getGreville (int idx, bool clamp=true, bool wrap=false) const override
 
int grow (bool wrapped=false) override
 
int shrink (bool wrapped=false) override
 
int growAt (unsigned cv_idx, bool wrapped)
 
int shrinkAt (unsigned cv_idx, bool wrapped)
 
bool attach (const GA_Basis &b, bool overlap=true, bool spread=false) override
 
void setWrapping (bool wrap) override
 
void setEndInterpolation (bool value, bool modify_knots)
 Change end interpolation. More...
 
void reverse (bool wrapped) override
 Reverse the breakpoints in the basis. More...
 
int findOffset (fpreal k, int start_idx=0) const override
 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=nullptr, GA_KnotVector *bknots=nullptr)
 
void rebuild (fpreal ustart=0, fpreal ustep=1) override
 Rebuild the basis as a uniform sequence with a given step. More...
 
void makeUniform (fpreal ustep=1) override
 Make the basis uniform of just find out if it is uniform: More...
 
void chord (UT_Vector4Array &cvs) override
 
bool slideRange (fpreal umin, fpreal umax, fpreal ubias=0.5) override
 
bool cycle (int amount, bool keep_span)
 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 ()
 
int64 getMemoryUsage (bool inclusive) const override
 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

bool GA_NUBBasis::attach ( const GA_Basis b,
bool  overlap = true,
bool  spread = false 
)
overridevirtual

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.

bool GA_NUBBasis::checkValid ( int  cv_len,
int  b_len,
bool  does_wrap 
) const
overridevirtual

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.

void GA_NUBBasis::chord ( UT_Vector4Array cvs)
overridevirtual

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.

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

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

Implements GA_Basis.

bool GA_NUBBasis::copyFrom ( const GA_Basis b,
bool  compatible = false 
)
overridevirtual

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  keep_span 
)

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

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

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

Implements GA_Basis.

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

Implements GA_Basis.

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

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

Implements GA_Basis.

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

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.
int GA_NUBBasis::findOffset ( fpreal  k,
int  start_idx = 0 
) const
overridevirtual

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.

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

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.

int GA_NUBBasis::getBreakCount ( ) const
overridevirtual

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

Implements GA_Basis.

int GA_NUBBasis::getBreakpoints ( GA_KnotVector a,
fpreal  tol = theBasisTolerance 
) const
overridevirtual

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.

void GA_NUBBasis::getCvRangeOfBreakpoint ( int  bkp,
int startcv,
int stopcv 
) const
overridevirtual

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.

void GA_NUBBasis::getCvRangeOfDomain ( int  ustartidx,
int  ustopidx,
int start_cv,
int end_cv 
) const
overridevirtual

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.

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

Implements GA_Basis.

int GA_NUBBasis::getDimension ( ) const
overridevirtual

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.

int GA_NUBBasis::getEndMultiplicity ( ) const
overridevirtual

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

Reimplemented from GA_Basis.

fpreal GA_NUBBasis::getGreville ( int  idx,
bool  clamp = true,
bool  wrap = false 
) const
overridevirtual

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.

int64 GA_NUBBasis::getMemoryUsage ( bool  inclusive) const
inlineoverridevirtual

Return the amount of memory used.

Reimplemented from GA_Basis.

Definition at line 306 of file GA_NUBBasis.h.

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

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.

GA_BASIS_TYPE GA_NUBBasis::getType ( ) const
overridevirtual

Return the type of the basis.

Implements GA_Basis.

const char* GA_NUBBasis::getTypeName ( ) const
overridevirtual

Return the name of the basis.

Implements GA_Basis.

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

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

Implements GA_Basis.

int GA_NUBBasis::grow ( bool  wrapped = false)
overridevirtual

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  cv_idx,
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
overridevirtual

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.

int GA_NUBBasis::knotToBreakpoint ( int kidx,
int  a,
int  b 
) const
overridevirtual

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.

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

Implements GA_Basis.

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

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 = nullptr,
GA_KnotVector bknots = nullptr 
)

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
void GA_NUBBasis::rebuild ( fpreal  ustart = 0,
fpreal  ustep = 1 
)
overridevirtual

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.

void GA_NUBBasis::reset ( )
overridevirtual

Re-initializes the basis to default values.

Implements GA_Basis.

void GA_NUBBasis::reverse ( bool  wrapped)
overridevirtual

Reverse the breakpoints in the basis.

Implements GA_Basis.

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

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.

void GA_NUBBasis::setWrapping ( bool  wrap)
overridevirtual

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.

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

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  cv_idx,
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.

bool GA_NUBBasis::slideRange ( fpreal  umin,
fpreal  umax,
fpreal  ubias = 0.5 
)
overridevirtual

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 298 of file GA_NUBBasis.h.

void GA_NUBBasis::updateEndInterpolation ( )
bool GA_NUBBasis::validate ( int  adapt = GA_Basis::GA_BASIS_ADAPT_NONE)
overridevirtual

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: