#include <HxSampledBSplineCurve.h>
Public Methods | |
HxSampledBSplineCurve () | |
Construct default curve. More... | |
HxSampledBSplineCurve (const HxBSplineCurve &curve, int nSamples, HxBSplineSamplingAlg algorithm=samplingResolution) | |
Construct a curve with given number of samples. More... | |
HxSampledBSplineCurve (const HxBSplineCurve &curve, double pathInterval, HxBSplineSamplingAlg algorithm) | |
Construct a curve with given path interval between samples. More... | |
~HxSampledBSplineCurve () | |
Destructor. More... | |
int | ident () const |
Get the identifier. More... | |
HxBSplineCurve | continuousCurve () const |
Get the continuous curve of this object. More... | |
HxBSplineType | curveType () const |
Get the type of this curve. More... | |
HxBSplineSamplingAlg | samplingAlg () const |
Get the sampling algorithm. More... | |
int | nSamples () const |
Get the number of samples. More... | |
double | sampledT (int j) const |
Get value of t for sample j. More... | |
vector< double > | allSampledT () const |
Get value of t for all samples. More... | |
int | indexOfT (double t) const |
Get index of sample corresponding to given t. More... | |
double | dT (int j) const |
sampling interval at sample j . More... | |
HxSampledBSplineInterval | sampledInterval (int j1, int j2) const |
Get curve interval defined by two curve samples j1, j2. More... | |
vector< int > | samplesAffectedBy (int i) const |
Get list of curve samples affected by control point i. More... | |
HxSampledBSplineInterval | intervalAffectedBy (int i) const |
Get curve interval affected by control point i. More... | |
vector< int > | PThatAffectSample (int i) const |
Get all control points with influence on the position of curve sample i. More... | |
double | B (int i, int j) const |
Get value of basis i for sample j. More... | |
vector< double > | BAll (int j) const |
Get value of all basis that affect sample j. More... | |
double | dB (int order, int i, int j) const |
Get derivative of basis i for sample j. More... | |
vector< double > | dBAll (int order, int j) const |
Get derivative of all basis that affect sample j (given order). More... | |
HxPointR2 | C (int j) const |
Get curve point for sample j. More... | |
HxPointSetR2 | AllC () const |
Get all sampled curve points. More... | |
HxPolyline2d | CPoly () const |
Polyline with all sampled curve points. More... | |
HxVectorR2 | dC (int order, int j) const |
Get curve derivative at sample j. More... | |
vector< HxVectorR2 > | dCAll (int order) const |
Get curve derivative at all samples. More... | |
double | kAtC (int j) const |
Get curvature at sample j. More... | |
vector< double > | kAtCAll () const |
Get curve derivative at all samples. More... | |
double | dTurnAngleAtC (int j) const |
Derivative of turning angle at sample j. More... | |
vector< double > | dTurnAngleAtCAll () const |
Derivative of turning angle at all samples. More... | |
double | length () const |
total curve length. More... | |
double | length (int j1, int j2) const |
length of interval between given samples. More... | |
double | length (const HxSampledBSplineInterval &interval) const |
length of given interval. More... | |
int | closestSample (const HxPointR2 &p) const |
Get index of sample that is closest to the given point. More... | |
int | numP () const |
Get number of control points. More... | |
HxPointSetR2 | allP () const |
Get all control points. More... | |
HxPolyline2d | controlP () const |
Get the control polygon. More... | |
HxSampledBSplineCurve | changeAllP (const HxPointSetR2 &p) const |
Replace all control points by given points. More... | |
HxSampledBSplineCurve | translateCurve (const HxVectorR2 &v, const HxSampledBSplineInterval &interval) const |
Add vector to control points that affect the curve in the given interval. More... | |
STD_OSTREAM & | dump (STD_OSTREAM &) const |
Dump the curve on the given stream. More... | |
Static Public Methods | |
HxSampledBSplineCurve | makeUniform (HxPolyline2d cp, int degree, double distance) |
Make a curve with uniform knots. More... | |
HxSampledBSplineCurve | makeInterpolating (HxPolyline2d cp, double distance) |
Make an interpolating curve. More... |
|
Construct default curve.
00019 { 00020 _ident = _nr++; 00021 makeDefault(); 00022 } |
|
Construct a curve with given number of samples.
00025 : _curve(curve) 00026 { 00027 _ident = _nr++; 00028 if ( algorithm != samplingResolution ) { 00029 message("(constructor) invalid parameters - using default"); 00030 makeDefault(); 00031 } 00032 else 00033 sampleWithResolution(n); 00034 } |
|
Construct a curve with given path interval between samples.
00037 : _curve(curve) 00038 { 00039 _ident = _nr++; 00040 if ( algorithm != samplingInterval || 00041 delta < 0 || delta > (_curve.maxT() -_curve.minT()) ) { 00042 message("(constructor) invalid sampling interval - using default"); 00043 makeDefault(); 00044 } 00045 else 00046 sampleWithInterval(delta); 00047 } |
|
Destructor.
00073 { 00074 } |
|
Make a curve with uniform knots.
00052 { 00053 HxBSplineCurve cc = HxBSplineCurve::makeUniform(cp, degree); 00054 double l = cc.length(); 00055 int n = int(l / distance); 00056 if (n < cc.numP()) 00057 n = cc.numP(); 00058 return HxSampledBSplineCurve(cc, n); 00059 } |
|
Make an interpolating curve.
00063 { 00064 HxBSplineCurve cc = HxBSplineCurve::makeInterpolating(cp); 00065 double l = cc.length(); 00066 int n = int(l / distance); 00067 if (n < cc.numP()) 00068 n = cc.numP(); 00069 return HxSampledBSplineCurve(cc, n); 00070 } |
|
Get the identifier.
00219 { 00220 return _ident; 00221 } |
|
Get the continuous curve of this object.
00225 { 00226 return _curve; 00227 } |
|
Get the type of this curve.
00231 { 00232 return _curve.curveType(); 00233 } |
|
Get the sampling algorithm.
00255 { 00256 return _samplingAlg; 00257 } |
|
Get the number of samples.
00261 { 00262 return _t.size(); 00263 } |
|
Get value of t for sample j.
00110 { 00111 if ( j < 0 || j >= nSamples() ) { 00112 message("(sampledT) invalid j - setting to 0"); 00113 j = 0; 00114 } 00115 return _t[j]; 00116 } |
|
Get value of t for all samples.
00267 { 00268 return _t; 00269 } |
|
Get index of sample corresponding to given t.
00083 { 00084 if ( t < _curve.minT() ) { 00085 message("(indexOfT) invalid t - setting to minT()"); 00086 return 0; 00087 } 00088 if ( t >= _curve.maxT() ) { 00089 message("(indexOfT) invalid t - setting near to maxT()"); 00090 return nSamples()-1; 00091 } 00092 int last = _t.size()-1; 00093 int j; 00094 for ( j=0; j < last && t > _t[j]; j++ ); 00095 if ( t == _t[j] ) 00096 return j; 00097 else { // get closest 00098 double da = absolute(t - _t[j]); 00099 double db = absolute(t - _t[j-1]); 00100 return (da <= db) ? j : j-1; 00101 } 00102 } |
|
sampling interval at sample j . fixed value -> only works for uniform sampling!
00297 { 00298 if ( j < 0 || j >= nSamples() ) { 00299 message("(dT) invalid j - setting to 0"); 00300 j = 0; 00301 } 00302 return _dt; // only for uniform! 00303 } |
|
Get curve interval defined by two curve samples j1, j2.
00124 { 00125 if ( j1 >= j2 && curveType() != closed ) { 00126 message("(sampledInterval) invalid interval - setting to complete curve]"); 00127 j1 = 0; 00128 j2 = nSamples()-1; 00129 } 00130 return HxSampledBSplineInterval(j1,j2, 00131 nSamples()-1, curveType()); 00132 } |
|
Get list of curve samples affected by control point i.
00141 { 00142 HxBSplineInterval tmp = _curve.pathAffectedBy(i); 00143 vector<int> vec; 00144 00145 for ( int j=0; j < nSamples(); j++ ) 00146 if ( tmp.contains(_t[j]) ) 00147 vec.push_back(j); 00148 00149 return vec; 00150 } |
|
Get curve interval affected by control point i.
00158 { 00159 vector<int> tmp = samplesAffectedBy(j); 00160 int j1; 00161 int j2; 00162 00163 if ( curveType() == closed ) { 00164 // special treatment for wrapping 00165 for ( int i=0; i<tmp.size()-1; i++ ) 00166 if ( (tmp[i+1] - tmp[i]) != 1 ) { 00167 j1 = tmp[i+1]; 00168 j2 = tmp[i]; 00169 return HxSampledBSplineInterval(j1,j2, 00170 nSamples(), curveType()); 00171 } 00172 } 00173 j1 = tmp[0]; 00174 j2 = tmp[ tmp.size()-1 ]; 00175 return HxSampledBSplineInterval(j1,j2, 00176 nSamples(), curveType()); 00177 } |
|
Get all control points with influence on the position of curve sample i.
00273 { 00274 return _curve.PThatAffectCAt(_t[i]); 00275 } |
|
Get value of basis i for sample j.
|
|
Get value of all basis that affect sample j.
|
|
Get derivative of basis i for sample j.
|
|
Get derivative of all basis that affect sample j (given order).
|
|
Get curve point for sample j.
|
|
Get all sampled curve points.
|
|
Polyline with all sampled curve points.
00327 { 00328 return HxPolyline2d(AllC(), (curveType() == closed)); 00329 } |
|
Get curve derivative at sample j.
|
|
Get curve derivative at all samples.
|
|
Get curvature at sample j.
|
|
Get curve derivative at all samples.
|
|
Derivative of turning angle at sample j.
00353 { 00354 if ( j < 0 || j >= nSamples() ) { 00355 message("(dTurnAngleAtC) invalid j - setting to 0"); 00356 j = 0; 00357 } 00358 return _curve.dTurnAngleAtC(_t[j]); 00359 } |
|
Derivative of turning angle at all samples.
00252 { 00253 vector<double> tmp(nSamples()); 00254 for ( int j=0; j < nSamples(); j++) 00255 tmp[j] = _curve.dTurnAngleAtC(_t[j]); 00256 return tmp; 00257 } |
|
total curve length.
|
|
length of interval between given samples.
00369 { 00370 return length( HxSampledBSplineInterval(j1, j2, 00371 nSamples(), curveType()) ); 00372 } |
|
length of given interval.
|
|
Get index of sample that is closest to the given point.
00280 { 00281 vector<HxPointR2> s = AllC(); 00282 int iMin = 0; 00283 double dMin = HxVectorR2(p,s[iMin]).magnitude(); 00284 for ( int i=1; i < s.size(); i++ ){ 00285 HxVectorR2 v(p,s[i]); 00286 double d = v.magnitude(); 00287 if ( d < dMin ) { 00288 dMin = d; 00289 iMin = i; 00290 } 00291 } 00292 00293 return iMin; 00294 } |
|
Get number of control points.
00237 { 00238 return _curve.numP(); 00239 } |
|
Get all control points.
00243 { 00244 return _curve.allP(); 00245 } |
|
Get the control polygon.
00249 { 00250 return HxPolyline2d(allP(), (curveType() == closed)); 00251 } |
|
Replace all control points by given points.
00279 { 00280 HxSampledBSplineCurve tmp = *this; 00281 tmp._curve = _curve.changeAllP(p); 00282 return tmp; 00283 } |
|
Add vector to control points that affect the curve in the given interval. This will translate a part of the curve in the given direction.
00305 { 00306 HxVectorR2 v = translVec; 00307 HxPointSetR2 P = _curve.allP(); 00308 HxBSplineInterval tmp(sampledT(interval.begin()), sampledT(interval.end()), 00309 _curve.minT(), _curve.maxT(), curveType()); 00310 vector<int> index = _curve.PThatAffectCAt(tmp); 00311 for ( int i =0; i < index.size(); i++) { 00312 int j = index[i]; 00313 P[j] = P[j].add(v); 00314 } 00315 00316 return changeAllP(P); 00317 } |
|
Dump the curve on the given stream.
00325 { 00326 _curve.dump(os); 00327 00328 os << "Sampling Algorithm: " << samplingAlg(); 00329 00330 if ( _t.empty() ) { 00331 os << "\nNo Samples"; 00332 } else { 00333 os << "\nT Vector: " << _t.size() << " samples\n"; 00334 for ( int i = 0; i < _t.size(); i++ ) { 00335 os << _t[i] << ","; 00336 } 00337 } 00338 00339 os << STD_ENDL; 00340 return os; 00341 } |