#include <HxSampledBSplineInterval.h>
Public Methods | |
| HxSampledBSplineInterval () | |
| Default constructor. More... | |
| HxSampledBSplineInterval (int b, int e, int max, HxBSplineType type) | |
| Construct given interval. More... | |
| ~HxSampledBSplineInterval () | |
| Destructor. More... | |
| int | begin () const |
| First sample. More... | |
| int | end () const |
| Last sample. More... | |
| int | next (int i) const |
| Next sample index in the interval (consider wrapping). More... | |
| int | contains (int i) const |
| Determine if the sample is inside the interval. More... | |
| int | middle () const |
| central sample in interval. More... | |
| int | ratio (double r) const |
| Index of sample inside the interval with given distance from begin. More... | |
| int | size () const |
| number of samples in the interval. More... | |
Interval = [first, second]. Values correspond to indices, and not to the path parameters. Possible interval: [0,max]. For open paths, first < second (always). For closed paths, first > second indicates wrap around 0.
|
|
Default constructor.
00071 : pair<int,int>()
00072 {
00073 _max = 0;
00074 _wrap = 0;
00075 }
|
|
||||||||||||||||||||
|
Construct given interval.
00079 : pair<int,int>(b,e)
00080 {
00081 _max = max;
00082 _wrap = (type == closed);
00083 }
|
|
|
Destructor.
00087 {
00088 }
|
|
|
First sample.
00092 {
00093 return first;
00094 }
|
|
|
Last sample.
00098 {
00099 return second;
00100 }
|
|
|
Next sample index in the interval (consider wrapping).
00104 {
00105 if ( _wrap ) {
00106 if ( i >= _max ) // is wrapped?
00107 return _max-i;
00108 else return i+1;
00109 } else if ( i >= _max )
00110 return _max-1;
00111 else return i+1;
00112 }
|
|
|
Determine if the sample is inside the interval. Consider wrapping for closed curves.
00116 {
00117 if ( first == second ) // special case?
00118 return (i >= 0 && i < _max);
00119 if ( first > second ) // is wrapped?
00120 return (i >= first && i < _max) || (i >= 0 && i <= second);
00121 else return (i >= first && i <= second);
00122 }
|
|
|
central sample in interval.
00126 {
00127 return ratio(0.5);
00128 }
|
|
|
Index of sample inside the interval with given distance from begin.
00132 {
00133 int index = size() * r + first;
00134 if ( index >= _max )
00135 index -= _max;
00136 return index;
00137 }
|
|
|
number of samples in the interval.
00142 {
00143 if ( first <= second ) {
00144 return second - first + 1;
00145 } else {
00146 int count = 0;
00147 for ( int i=first; i != second; i = next(i) )
00148 count++;
00149 return count+1;
00150 }
00151 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001