22 #define NURBS_BASE_THREAD_SAFE
37 NurbsBase(
int knotsPerDim = 4,
int degree = 2,
int dimension = 1);
53 double GetKnot(
int dim,
int index)
const;
57 void SetKnot(
int dim,
int index,
double value);
73 #ifndef NURBS_BASE_THREAD_SAFE
75 std::vector<double> evalCache_;
76 #endif //NURBS_BASE_THREAD_SAFE
80 #ifdef NURBS_BASE_RECURSIVE_EVALUATION
82 inline double BaseFunc(
const int &dim,
const int &knot,
const int °ree,
const double &u)
const{
86 if (u ==
knotVector_[dim][knot+1] && u != 1.0)
return 0.0;
90 double recursiveA = 0.0;
94 double recursiveB = 0.0;
98 return recursiveA + recursiveB;
100 #else //NURBS_BASE_RECURSIVE_EVALUATION
108 inline double BaseFunc(
const int &dim,
const int &knot,
const int °ree,
const double &u)
const{
110 #ifdef NURBS_BASE_THREAD_SAFE
111 double* evalCache_ =
new double[degree+1];
115 int baseOps = degree+1;
116 for(
int k = 0; k < baseOps; k++)
120 for(
int level = 1; level <= degree; level++){
121 baseOps = baseOps -1;
122 for(
int k = 0; k < baseOps; k++){
131 #ifdef NURBS_BASE_THREAD_SAFE
132 double returnValue = evalCache_[0];
136 return evalCache_[0];
140 #endif //NURBS_BASE_RECURSIVE_EVALUATION
152 inline double BaseFunc(
const int &dim,
const int &knot,
const int °ree,
const double &u,
double* &cachePointer)
const{
155 int baseOps = degree+1;
156 for(
int k = 0; k < baseOps; k++)
160 for(
int level = 1; level <= degree; level++){
161 baseOps = baseOps -1;
162 for(
int k = 0; k < baseOps; k++){
171 return cachePointer[0];
double GetKnot(int dim, int index) const
Returns the position of a knot with a given index of a given dimension.
int degree_
Degree of the b-splines.
int knotsPerDim_
Number of knots in each dimension.
double BaseFunc(const int &dim, const int &knot, const int °ree, const double &u) const
This is a serial implementation of the recursive nurbs evaluation.
NurbsBase(int knotsPerDim=4, int degree=2, int dimension=1)
Standard Constructor.
void SetKnot(int dim, int index, double value)
Set the position of a knot with a given index and of a given dimension.
double BaseFunc(const int &dim, const int &knot, const int °ree, const double &u, double *&cachePointer) const
This is a serial implementation of the recursive nurbs evaluation.
Base class for NURBS classes.
std::vector< std::vector< double > > knotVector_
The vector of knot vectors (One for each dimension)
int GetNumCtrlPts() const
Returns the number of control points per dimension.
int GetNumKnots() const
Returns the number of knots of the NURBS.
~NurbsBase()
Empty Destructor (Virtual to make this whole thing polymorphic)
int numCtrlPoints_
The number of control points per dimension.
int GetDegree() const
Returns the degree of the NURBS.