34 inline BasicInterval();
35 inline BasicInterval(
const T& start,
const T& stop);
38 inline void set(
const T& start,
const T& stop);
48 inline T width(
bool allowrev=
true)
const;
49 inline T center()
const;
50 inline float getfCenter()
const;
51 inline void shift(
const T& len);
52 inline void widen(
const T& len,
bool allowrev=
true);
54 inline T atIndex(
int,
const T& step)
const;
56 inline int getIndex(
const X&,
const T& step)
const;
58 inline float getfIndex(
const X&,
const T& step)
const;
60 inline int nearestIndex(
const X& x,
const T& step)
const;
62 inline int indexOnOrAfter(X x,
const T& step,
63 float eps=1e-5)
const;
69 inline X limitValue(
const X&)
const;
73 bool allrev=
true)
const;
75 inline bool includes(
const X&,
bool allowrev )
const;
78 bool allowrev=
true)
const;
81 bool allowrev=
true)
const;
84 inline float pos(X val,
bool limit=
true,
85 bool allowrev=
true)
const;
88 inline void include(
const T&,
bool allowrev=
true);
97 inline bool isRev()
const {
return start > stop; }
114 inline Interval(
const T& start,
const T& stop);
119 virtual bool inline isUdf()
const;
122 inline virtual void scale(
const T&);
124 virtual void sort(
bool asc=
true );
126 virtual bool hasStep()
const {
return false; }
152 virtual bool inline isUdf()
const;
161 inline void set(
const T& start,
const T& stop,
const T& step);
169 inline T atIndex(
int)
const;
171 inline int getIndex(
const X&)
const;
172 template <
class X>
inline 173 int indexOnOrAfter( X x,
float eps )
const;
176 inline float getfIndex(
const X&)
const;
178 inline int nearestIndex(
const X&)
const;
180 inline T snap(
const X&)
const;
182 inline T snap(
const X&,
int dir)
const;
185 inline int nrSteps()
const;
186 inline float nrfSteps()
const;
187 virtual inline void sort(
bool asc=
true);
188 inline void scale(
const T&);
189 inline T snappedCenter()
const;
196 inline T snapStep(
const T& inpstep)
const;
219 int nDim()
const {
return ndim; }
220 bool isSet()
const {
return isset; }
223 template <
class X>
inline 224 void setRange(
const X& val);
225 template <
class X>
inline 226 void setRange(
const X& start,
const X& stop);
227 template <
class X>
inline 228 void include(
const X& val);
230 template <
class X>
inline 231 bool includes(
const X& val,
bool allowrev)
const;
233 bool allowrev)
const;
247 template <
class T>
template <
class X>
inline 250 for (
int dim=0; dim<ndim; dim++ )
251 ranges[dim].start = ranges[dim].stop = (T) val[dim];
258 template <
class T>
template <
class X>
inline 261 for (
int dim=0; dim<ndim; dim++ )
263 ranges[dim].start = start[dim];
264 ranges[dim].stop = stop[dim];
271 template <
class T>
template <
class X>
inline 276 pErrMsg(
"Doing include on undefined IntervalND");
279 for (
int dim=0; dim<ndim; dim++ )
280 ranges[dim].include((T) val[dim]);
286 template <
class T>
template <
class X>
inline 292 pErrMsg(
"Doing includes on undefined IntervalND");
297 for (
int dim=0; dim<ndim; dim++ )
299 if ( !ranges[dim].includes(val[dim], allowrev ) )
307 template <
class T>
inline 312 pErrMsg(
"Invalid intersection");
318 for (
int dim=0; dim<ndim; dim++ )
320 vector[dim] = ranges[dim].start;
326 if ( b.
includes((T*)vector, allowrev ) )
334 isstart[dim] =
false;
335 vector[dim] = ranges[dim].stop;
341 vector[dim] = ranges[dim].start;
356 template <
class T1,
class T2>
364 si1->step = (T1)si2->step;
368 template <
class T1,
class T2>
379 { start = intv.
start; stop = intv.
stop;
return *
this; }
382 template <
class T>
template <
class X>
inline 390 template <
class X>
inline 398 : start(0), stop(0) {}
401 template <
class T>
inline 406 template <
class T>
inline 411 template <
class T>
inline 416 template <
class T>
inline 421 template <
class T>
inline 426 template <
class T>
inline 428 {
return ! (i == *
this); }
431 template <
class T>
inline 436 template <
class T>
inline 441 template <
class T>
template <
class X>
inline 450 template <
class T>
inline 455 #define mCenterImpl(func,typ) \ 456 template <class T> inline \ 457 typ BasicInterval<T>::func() const \ 458 { return ((typ)(start+stop))/2; } 466 template <
class T>
inline 471 template <
class T>
inline 474 if ( allowrev &&
isRev() )
481 template <
class T>
template <
class X>
inline 484 return allowrev &&
isRev()
486 : t>=start &&
stop>=t;
490 template <
class T>
template <
class X>
inline 497 template <
class T>
template <
class X>
inline 504 template <
class T>
template <
class X>
inline 507 float res = allowrev &&
isRev()
513 if ( res<0 ) res = 0;
514 else if ( res>1 ) res = 1;
521 template <
class T>
template <
class X>
inline 523 bool allowrev )
const 530 template <
class T>
inline 533 if ( allowrev &&
isRev() )
540 template <
class T>
inline 545 template <
class T>
inline 547 {
return start + step * idx; }
550 template <
class T>
template <
class X>
inline 552 {
return (
int)(( t -
start ) / step); }
555 template <
class T>
template <
class X>
inline 560 template <
class T>
template <
class X>
inline 563 const bool isrev =
isRev();
572 template <
class T>
inline 578 template <
class T>
inline 584 template <
class T>
inline 593 template <
class T>
inline 598 template <
class T>
inline 605 template <
class T>
inline 630 step = sintv ? sintv->step : 1;
637 {
assign( *
this, intv );
return *
this; }
640 template <
class T>
inline 645 template <
class T>
inline 650 template <
class T>
inline 655 template <
class T>
inline 660 template <
class T>
inline 665 template <
class T>
inline 670 template <
class T>
inline 672 {
return ! (i == *
this); }
675 template <
class T>
template <
class X>
inline 686 template <
class T>
inline 691 template <
class T>
template <
class X>
inline 696 template <
class T>
template <
class X>
inline 701 template <
class T>
template <
class X>
inline 708 template <
class T>
template <
class X>
inline 713 template <
class T>
template <
class X>
inline 718 template <
class T>
template <
class X>
inline 730 template <
class T>
inline 734 if ( (asc &&
step < 0) || (!asc &&
step > 0) )
739 template <
class T>
inline 747 template <
class T>
inline 752 template <
class T>
inline 755 const float relstep = (float) inputstep/
step;
756 int nrsteps =
mNINT32(relstep);
757 if ( nrsteps<1 ) nrsteps = 1;
762 template <
class T>
inline 773 if ( !
step )
return 0;
774 int ret = (((int)this->
start) - ((int) this->
stop)) / ((
int)
step);
775 return ret < 0 ? -ret : ret;
779 #define mDefFNrSteps(typ) \ 781 inline int StepInterval<typ>::nrSteps() const \ 783 if ( !step ) return 0; \ 784 typ ns = ( (start > stop ? start : stop) \ 785 - (start > stop ? stop : start) ) \ 786 / (step > 0 ? step : -step); \ 787 return mNINT32(ns); \ 801 const T diff = this->
start - b.start;
806 #define mDefFltisCompat(typ,releps) \ 808 inline bool StepInterval<typ>::isCompatible( const StepInterval<typ>& b, \ 811 const typ castedeps = (typ) eps; \ 812 if ( !mIsEqual(step,b.step, castedeps) ) return false; \ 814 typ nrsteps = (start - b.start) / step; \ 815 const int nrstepsi = mNINT32( nrsteps ); \ 817 return mIsEqual( start, b.start, \ 818 mIsZero(start,releps) ? releps \ 819 : start < 0. ? -start * releps \ 822 typ reldiff = (nrsteps - nrstepsi) / nrsteps; \ 823 return ( (reldiff) < (releps) && (reldiff) > (-releps) ); \ #define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
virtual StepInterval< T > * clone() const
Definition: ranges.h:651
bool intersects(const IntervalND< T > &, bool allowrev) const
Definition: ranges.h:308
virtual bool isUdf() const
Definition: ranges.h:599
T snappedCenter() const
Definition: ranges.h:748
void set(const T &start, const T &stop, const T &step)
Definition: ranges.h:656
const BasicInterval< T > & setFrom(const BasicInterval< X > &)
Definition: ranges.h:442
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
bool isRev() const
Definition: ranges.h:97
BasicInterval< T > operator+(const BasicInterval< T > &) const
Definition: ranges.h:432
T atIndex(int, const T &step) const
Definition: ranges.h:546
bool operator!=(const StepInterval< T > &) const
Definition: ranges.h:671
int getIndex(const X &, const T &step) const
Definition: ranges.h:551
virtual ~Interval()
Definition: ranges.h:113
virtual bool isUdf() const
Definition: ranges.h:641
Interval< float > ZGate
Definition: ranges.h:132
T center() const
Definition: ranges.h:460
int nrSteps() const
Definition: ranges.h:771
BasicInterval< T > & operator+=(const BasicInterval< T > &)
Definition: ranges.h:437
int nDim() const
Definition: ranges.h:219
X limitValue(const X &) const
Definition: ranges.h:561
void limitTo(const BasicInterval< X > &i)
Definition: ranges.h:65
T atIndex(int) const
Definition: ranges.h:687
void widen(const T &len, bool allowrev=true)
Definition: ranges.h:472
Interval< T > * ranges
Definition: ranges.h:238
bool operator==(const StepInterval< T > &) const
Definition: ranges.h:666
int getIndex(const X &) const
Definition: ranges.h:692
virtual void sort(bool asc=true)
Definition: ranges.h:731
static Interval< T > udf()
Definition: ranges.h:127
virtual bool hasStep() const
Definition: ranges.h:157
Interval of values.
Definition: commontypes.h:31
BasicInterval()
Definition: ranges.h:397
#define mIsEqual(x, y, eps)
Definition: commondefs.h:54
void scale(const T &)
Definition: ranges.h:740
Base class for Interval. Has no virtual functions and can hence be used in places where no virtual fu...
Definition: ranges.h:31
int indexOnOrAfter(X x, const T &step, float eps=1e-5) const
Definition: ranges.h:391
#define mNINT32(x)
Definition: commondefs.h:45
T step
Definition: ranges.h:199
float getfIndex(const X &, const T &step) const
Definition: ranges.h:556
static StepInterval< T > udf()
Definition: ranges.h:154
Interval< int > SampleGate
Definition: ranges.h:131
bool operator!=(const BasicInterval< T > &) const
Definition: ranges.h:427
static BasicInterval< T > udf()
Definition: ranges.h:95
float getfCenter() const
Definition: ranges.h:461
Interval()
Definition: ranges.h:112
T width(bool allowrev=true) const
Definition: ranges.h:451
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
bool isSet() const
Definition: ranges.h:220
const Interval< T > & getRange(int dim) const
Definition: ranges.h:222
#define mDefFNrSteps(typ)
Definition: ranges.h:779
Interval with step.
Definition: commontypes.h:33
void Swap(T &a, T &b)
Definition: commondefs.h:36
void assign(Interval< T1 > &i1, const Interval< T2 > &i2)
Definition: ranges.h:357
bool overlaps(const BasicInterval< X > &, bool allrev=true) const
Definition: ranges.h:522
void include(const X &val)
Definition: ranges.h:272
Class to store ranges in N dimensions.
Definition: ranges.h:209
StepInterval< T > & operator=(const Interval< T > &)
Definition: ranges.h:636
virtual void scale(const T &)
Definition: ranges.h:594
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:62
float pos(X val, bool limit=true, bool allowrev=true) const
Definition: ranges.h:505
float getfIndex(const X &) const
Definition: ranges.h:697
#define mDynamicCastGet(typ, out, in)
Definition: commondefs.h:131
#define mDefEps
Definition: commondefs.h:58
void setRange(const X &val)
Definition: ranges.h:248
void shift(const T &len)
Definition: ranges.h:467
T stop
Definition: ranges.h:93
void include(const T &, bool allowrev=true)
Definition: ranges.h:531
T snap(const X &) const
Definition: ranges.h:714
bool isEqual(const StepInterval< T > &i, const T &eps) const
Definition: ranges.h:661
void sort(ObjectSet< T > &os)
Sort ObjectSet. Must have operator > defined for elements.
Definition: objectset.h:220
#define mDefFltisCompat(typ, releps)
Definition: ranges.h:806
virtual bool hasStep() const
Definition: ranges.h:126
bool operator==(const BasicInterval< T > &) const
Definition: ranges.h:422
int indexOnOrAfter(X x, float eps) const
Definition: ranges.h:702
bool includes(const X &, bool allowrev) const
Definition: ranges.h:482
#define mAllocLargeVarLenArr(type, varnm, __size)
Definition: varlenarray.h:31
StepInterval(const StepInterval< T > &si)
Definition: ranges.h:148
T snapStep(const T &inpstep) const
Definition: ranges.h:753
virtual ~IntervalND()
Definition: ranges.h:217
void set(const T &start, const T &stop)
Definition: ranges.h:412
int ndim
Definition: ranges.h:237
T & setUdf(T &u)
Definition: undefval.h:262
int nearestIndex(const X &x, const T &step) const
Definition: ranges.h:383
T start
Definition: ranges.h:92
virtual void setUdf()
Definition: ranges.h:646
Holds the fundamental sampling info: start and interval.
Definition: samplingdata.h:22
virtual void sort(bool asc=true)
Definition: ranges.h:585
float nrfSteps() const
Definition: ranges.h:763
StepInterval()
Definition: ranges.h:613
#define mCenterImpl(func, typ)
Definition: ranges.h:455
#define mClass(module)
Definition: commondefs.h:164
#define pErrMsg(msg)
Definition: errmsg.h:60
bool isUdf(const T &t)
Definition: undefval.h:243
const StepInterval< T > & setFrom(const Interval< X > &)
Definition: ranges.h:676
IntervalND(int ndim_)
Definition: ranges.h:212
bool isEqual(const BasicInterval< T > &i, const T &eps) const
Definition: ranges.h:417
BasicInterval< T > & operator=(const BasicInterval< T > &)
Definition: ranges.h:378
int nearestIndex(const X &) const
Definition: ranges.h:709
virtual void setUdf()
Definition: ranges.h:606
bool isset
Definition: ranges.h:239
bool isCompatible(const StepInterval< T > &, float eps=(1e-10)) const
Definition: ranges.h:794
bool includes(const X &val, bool allowrev) const
Definition: ranges.h:287
virtual Interval< T > * clone() const
Definition: ranges.h:407