#include <HxBSplineBasis.h>
Public Methods | |
HxBSplineBasis () | |
Construct default basis. More... | |
HxBSplineBasis (HxBSplineType typeCurve, int degree, int nIntervals, HxBSplineKnotsAlg typeKnots=uniformKnots, double minT=0.0, double maxT=1.0) | |
Construct basis with uniformily distributed knots, given number of intervals, and path interval: minT <= t < maxT. More... | |
HxBSplineBasis (HxBSplineType typeCurve, int degree, const std::vector< double > &knots) | |
Construct basis with given knots. More... | |
~HxBSplineBasis () | |
Destructor. More... | |
HxBSplineType | curveType () const |
Get the type of the cuve. More... | |
int | degree () const |
Get the degree. More... | |
int | nIntervals () const |
Get the number of intervals. More... | |
HxBSplineKnotsAlg | knotsType () const |
Get the type of the knots generating algorithm. More... | |
double | minT () const |
Get the minimum value for t. More... | |
double | maxT () const |
Get the maximum value for t. More... | |
double | knot (int j) const |
Get the value of the given knot. More... | |
std::vector< double > | allKnots () const |
Get values of all knots. More... | |
int | numB () const |
Get the number of basis functions. More... | |
double | B (int index, double t) const |
Get value of given basis at path position t. More... | |
double | dB (int order, int index, double t) const |
Get derivative of given basis at path position t. More... | |
HxBSplineInterval | pathAffectedBy (int index) const |
Get path interval affected by given basis. More... | |
HxBSplineBasis | insertKnot (double t, int n=1) const |
Insert one knot at given position. More... | |
STD_OSTREAM & | dump (STD_OSTREAM &) const |
Dump the basis on the given stream. More... | |
double | node (int i) const |
int | maxBasis (double t) const |
double | nearestKnot (double t) const |
Friends | |
class | HxBSplineCurve |
Based on "Curve and Surface Fitting with Splines", by "Dierckx,P.", "Oxford", "1993", chapter "Univariate Splines", and "The NURBS book", "Piegl, L. and Tiller, W.", Springer, 1997.
|
Construct default basis.
00017 { 00018 makeDefault(); 00019 } |
|
Construct basis with uniformily distributed knots, given number of intervals, and path interval: minT <= t < maxT.
00032 { 00033 _curveType = t; 00034 _degree = d; 00035 _minT = min; 00036 _maxT = max; 00037 _nIntervals = n; 00038 00039 if ( _degree <= 0 || max <= min || _nIntervals < 1 || 00040 ( t==closed && _nIntervals <= d ) || 00041 alg != uniformKnots ) { 00042 message("(constructor) invalid parameters - using default"); 00043 makeDefault(); 00044 return; 00045 } 00046 // parameters ok 00047 _knotsType = uniformKnots; 00048 vector<double> knots = makeUniformKnots(); 00049 completeKnots(knots); 00050 } |
|
Construct basis with given knots. The number of intervals and path are determined from the given knots. |
|
Destructor.
00089 { 00090 } |
|
Get the type of the cuve.
00156 { 00157 return _curveType; 00158 } |
|
Get the degree.
00162 { 00163 return _degree; 00164 } |
|
Get the number of intervals.
00169 { 00170 return _nIntervals; 00171 } |
|
Get the type of the knots generating algorithm.
00175 { 00176 return _knotsType; 00177 } |
|
Get the minimum value for t.
00181 { 00182 return _minT; 00183 } |
|
Get the maximum value for t.
00187 { 00188 return _maxT; 00189 } |
|
Get the value of the given knot.
00208 { 00209 return _knotsVec[i]; 00210 } |
|
Get values of all knots.
00214 { 00215 return _knotsVec; 00216 } |
|
Get the number of basis functions.
|
|
Get value of given basis at path position t.
00102 { 00103 if ( t < minT() ) { 00104 message("(B) invalid t - setting to minT()"); 00105 t = minT(); 00106 } 00107 else if ( t >= maxT() ) { 00108 message("(B) invalid t - setting near to maxT()"); 00109 t = maxT() - EPS; 00110 } 00111 if ( ! inRange(i, 0, numB()) ) { 00112 message("(B) invalid index - setting to 0"); 00113 i = 0; 00114 } 00115 00116 // return 0 if i doesn't affect point at t 00117 if ( isNullAt(i, t) ) 00118 return 0.0; 00119 00120 // Calculate basis 00121 return nim(t, internalBasisIndex(i, t), degree()+1); 00122 } |
|
Get derivative of given basis at path position t.
00135 { 00136 if ( t < minT() ) { 00137 message("(dB) invalid t - setting to minT()"); 00138 t = minT(); 00139 } 00140 else if ( t >= maxT() ) { 00141 message("(dB) invalid t - setting near to maxT()"); 00142 t = maxT() - EPS; 00143 } 00144 if ( ! inRange(i, 0, numB()) ) { 00145 message("(dB) invalid index - setting to 0"); 00146 i = 0; 00147 } 00148 if ( ! inRange(order, 0, degree()-1) ) { 00149 message("(dB) derivative not defined - setting to zero"); 00150 order = 0; 00151 } 00152 00153 // return 0 if i doesn't affect point at t 00154 if ( isNullAt(i, t) ) 00155 return 0.0; 00156 00157 // Calculate basis or derivative 00158 int index = internalBasisIndex(i,t); 00159 if ( order ) 00160 return dNim(order, t, index, degree()+1); 00161 else return nim(t, index, degree()+1); 00162 } |
|
Get path interval affected by given basis.
00171 { 00172 if ( ! inRange(i, 0, numB()) ) { 00173 message("(pathAffectedBy) invalid i - fixing to 0"); 00174 i = 0; 00175 } 00176 00177 double t1 = _knotsVec[i]; 00178 if ( t1 < minT() ) { 00179 if ( curveType() == closed ) 00180 t1 = maxT() - absolute(minT() - t1); 00181 else t1 = minT(); //ZZZ 00182 } 00183 double t2 = _knotsVec[i+degree()+1]; 00184 if ( t2 >= maxT() ) { 00185 if ( curveType() == closed ) 00186 t2 = minT() + (t2 - maxT()); 00187 else t2 = maxT(); //ZZZ 00188 } 00189 00190 HxBSplineInterval tmp( t1,t2, minT(), maxT(), curveType()); 00191 00192 return tmp; 00193 } |
|
Insert one knot at given position.
00203 { 00204 if ( t < minT() ) { 00205 message("(insertKnot) invalid t - setting to minT()"); 00206 t = minT(); 00207 } 00208 else if ( t >= maxT() ) { 00209 message("(insertKnot) invalid t - setting near to maxT()"); 00210 t = maxT() - EPS; 00211 } 00212 HxBSplineBasis tmp(*this); 00213 for (int i=degree(); i < tmp._knotsVec.size(); i++ ) 00214 if ( tmp._knotsVec[i] >= t ) { 00215 tmp._nIntervals++; 00216 tmp._knotsVec.insert( tmp._knotsVec.begin()+i, n, t); 00217 tmp.correctEnds(i); 00218 break; 00219 } 00220 return tmp; 00221 } |
|
Dump the basis on the given stream.
00229 { 00230 os << "Curve Type: " << curveType(); 00231 os << " Knots Type: " << knotsType(); 00232 os << " Degree: " << degree(); 00233 os << " Interval: [" << minT() << "," << maxT() << "]" << STD_ENDL; 00234 00235 if ( _knotsVec.empty() ) { 00236 os << "No knots"; 00237 } else { 00238 os << "Knots Vector: " << _knotsVec.size() << " knots"; 00239 os << " (" << _nIntervals << " intervals,"; 00240 os << " N Basis=" << numB() << ")\n"; 00241 for ( int i = 0; i < _knotsVec.size(); i++ ) { 00242 os << _knotsVec[i] << ", "; 00243 } 00244 } 00245 00246 os << STD_ENDL; 00247 return os; 00248 } |