18 template <
typename Real>
25 template <
typename Real>
42 template <
typename Real>
112 inline operator bool()
const;
115 inline int GetNumControls()
const;
116 inline int GetDegree()
const;
117 inline int GetNumUniqueKnots()
const;
118 inline int GetNumKnots()
const;
119 inline Real GetMinDomain()
const;
120 inline Real GetMaxDomain()
const;
121 inline bool IsOpen()
const;
122 inline bool IsUniform()
const;
123 inline bool IsPeriodic()
const;
125 inline Real
const* GetKnots()
const;
130 void Evaluate(Real
t,
unsigned int order,
int& minIndex,
int& maxIndex)
138 Real GetValue(
unsigned int order,
int i)
const;
144 int GetIndex(Real& t)
const;
165 std::vector<std::pair<Real, int>>
mKeys;
172 template <
typename Real>
177 template <
typename Real>
180 numControls(inNumControls),
184 numUniqueKnots(numControls - degree + 1),
185 uniqueKnots(numUniqueKnots)
198 template <
typename Real>
203 template <
typename Real>
218 template <
typename Real>
227 template <
typename Real>
232 LogError(
"Object already created.");
244 for (
int i = 0; i < 4; ++i)
251 LogError(
"Invalid number of control points.");
263 LogError(
"Invalid number of unique knots.");
277 LogError(
"Unique knots are not strictly increasing.");
284 if (mult0 < 1 || mult0 >
mDegree + 1)
286 LogError(
"Invalid first multiplicity.");
291 if (mult1 < 1 || mult1 >
mDegree + 1)
293 LogError(
"Invalid last multiplicity.");
300 if (mult < 1 || mult >
mDegree)
302 LogError(
"Invalid interior multiplicity.");
316 for (
int k = 0; k < mult; ++k, ++j)
321 mKeys[i].first = tCommon;
322 mKeys[i].second = sum - 1;
332 size_t numBytes = numRows * numCols *
sizeof(Real);
333 for (
int i = 0; i < 4; ++i)
336 memset(
mValue[i][0], 0, numBytes);
342 template <
typename Real>
inline 348 template <
typename Real>
inline 354 template <
typename Real>
inline 360 template <
typename Real>
inline 366 template <
typename Real>
inline 369 return static_cast<int>(
mKnots.size());
372 template <
typename Real>
inline 378 template <
typename Real>
inline 384 template <
typename Real>
inline 390 template <
typename Real>
inline 396 template <
typename Real>
inline 402 template <
typename Real>
inline 408 template <
typename Real>
inline 414 template <
typename Real>
429 LogError(
"Only derivatives through order 3 are supported.");
436 mValue[0][0][i] = (Real)1;
440 mValue[1][0][i] = (Real)0;
443 mValue[2][0][i] = (Real)0;
446 mValue[3][0][i] = (Real)0;
451 Real n0 = t -
mKnots[i], n1 = mKnots[i + 1] -
t;
452 Real e0, e1, d0, d1, invD0, invD1;
456 d0 = mKnots[i + j] - mKnots[i];
457 d1 = mKnots[i + 1] - mKnots[i - j + 1];
458 invD0 = (d0 > (Real)0 ? (Real)1 / d0 : (Real)0);
459 invD1 = (d1 > (Real)0 ? (Real)1 / d1 : (Real)0);
461 e0 = n0*
mValue[0][j - 1][i];
462 mValue[0][j][i] = e0*invD0;
463 e1 = n1*mValue[0][j - 1][i - j + 1];
464 mValue[0][j][i - j] = e1*invD1;
468 e0 = n0 * mValue[1][j - 1][i] + mValue[0][j - 1][i];
469 mValue[1][j][i] = e0 * invD0;
470 e1 = n1 * mValue[1][j - 1][i - j + 1] - mValue[0][j - 1][i - j + 1];
471 mValue[1][j][i - j] = e1 * invD1;
475 e0 = n0 * mValue[2][j - 1][i] + ((Real)2) * mValue[1][j - 1][i];
476 mValue[2][j][i] = e0 * invD0;
477 e1 = n1 * mValue[2][j - 1][i - j + 1] - ((Real)2) * mValue[1][j - 1][i - j + 1];
478 mValue[2][j][i - j] = e1 * invD1;
482 e0 = n0 * mValue[3][j - 1][i] + ((Real)3) * mValue[2][j - 1][i];
483 mValue[3][j][i] = e0 * invD0;
484 e1 = n1 * mValue[3][j - 1][i - j + 1] - ((Real)3) * mValue[2][j - 1][i - j + 1];
485 mValue[3][j][i - j] = e1 * invD1;
493 for (
int k = i - j + 1; k < i; ++k)
496 n1 = mKnots[k + j + 1] -
t;
497 d0 = mKnots[k + j] - mKnots[k];
498 d1 = mKnots[k + j + 1] - mKnots[k + 1];
499 invD0 = (d0 >(Real)0 ? (Real)1 / d0 : (Real)0);
500 invD1 = (d1 > (Real)0 ? (Real)1 / d1 : (Real)0);
502 e0 = n0*
mValue[0][j - 1][k];
503 e1 = n1*mValue[0][j - 1][k + 1];
504 mValue[0][j][k] = e0 * invD0 + e1 * invD1;
508 e0 = n0 * mValue[1][j - 1][k] + mValue[0][j - 1][k];
509 e1 = n1 * mValue[1][j - 1][k + 1] - mValue[0][j - 1][k + 1];
510 mValue[1][j][k] = e0 * invD0 + e1 * invD1;
514 e0 = n0 * mValue[2][j - 1][k] + ((Real)2) * mValue[1][j - 1][k];
515 e1 = n1 * mValue[2][j - 1][k + 1] - ((Real)2) * mValue[1][j - 1][k + 1];
516 mValue[2][j][k] = e0 * invD0 + e1 * invD1;
520 e0 = n0 * mValue[3][j - 1][k] + ((Real)3) * mValue[2][j - 1][k];
521 e1 = n1 * mValue[3][j - 1][k + 1] - ((Real)3) * mValue[2][j - 1][k + 1];
522 mValue[3][j][k] = e0 * invD0 + e1 * invD1;
533 template <
typename Real>
555 template <
typename Real>
584 for (
auto const& key :
mKeys)
GLfixed GLfixed GLint GLint order
std::vector< std::pair< Real, int > > mKeys
Real GetMaxDomain() const
Real GetMinDomain() const
std::vector< UniqueKnot< Real > > mUniqueKnots
std::vector< Real > mKnots
int GetNumUniqueKnots() const
Real const * GetKnots() const
Real GetValue(unsigned int order, int i) const
#define LogError(message)
void Create(BasisFunctionInput< Real > const &input)
UniqueKnot< Real > const * GetUniqueKnots() const
void Evaluate(Real t, unsigned int order, int &minIndex, int &maxIndex) const
int GetNumControls() const
GLenum GLenum GLenum input
int GetIndex(Real &t) const