OpendTect-6_4  6.4
ranges.h
Go to the documentation of this file.
1 #ifndef ranges_h
2 #define ranges_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Bril
9  Date: 23-10-1996
10  Contents: Ranges
11  RCS: $Id$
12 ________________________________________________________________________
13 
14 -*/
15 
16 #include "gendefs.h"
17 #include "math2.h"
18 #include "ptrman.h"
19 #include "varlenarray.h"
20 
21 
22 
30 template <class T>
32 {
33 public:
34  inline BasicInterval();
35  inline BasicInterval(const T& start,const T& stop);
36  inline BasicInterval<T>& operator=(const BasicInterval<T>&);
37 
38  inline void set(const T& start,const T& stop);
39  inline bool isEqual(const BasicInterval<T>& i,
40  const T& eps) const;
41  inline bool operator==(const BasicInterval<T>&) const;
42  inline bool operator!=(const BasicInterval<T>&) const;
43  inline BasicInterval<T> operator+(const BasicInterval<T>&) const;
44  inline BasicInterval<T>& operator+=(const BasicInterval<T>&);
45  template <class X>
46  const BasicInterval<T>& setFrom(const BasicInterval<X>&);
47 
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);
53 
54  inline T atIndex(int,const T& step) const;
55  template <class X>
56  inline int getIndex(const X&,const T& step) const;
57  template <class X>
58  inline float getfIndex(const X&,const T& step) const;
59  template <class X>
60  inline int nearestIndex(const X& x,const T& step) const;
61  template <class X>
62  inline int indexOnOrAfter(X x,const T& step,
63  float eps=1e-5) const;
64  template <class X>
65  inline void limitTo( const BasicInterval<X>& i )
66  { start = i.limitValue(start);
67  stop = i.limitValue(stop); }
68  template <class X>
69  inline X limitValue(const X&) const;
70 
71  template <class X>
72  inline bool overlaps(const BasicInterval<X>&,
73  bool allrev=true) const;
74  template <class X>
75  inline bool includes(const X&, bool allowrev ) const;
76  template <class X>
77  inline bool includes(const BasicInterval<X>&,
78  bool allowrev=true) const;
79  template <class X>
80  inline bool includes(const Interval<X>&,
81  bool allowrev=true) const;
82 
83  template <class X>
84  inline float pos(X val,bool limit=true,
85  bool allowrev=true) const;
88  inline void include(const T&, bool allowrev=true);
89  inline void include(const BasicInterval<T>&,
90  bool allowrev=true);
91 
92  T start;
93  T stop;
94 
95  static BasicInterval<T> udf(){return BasicInterval<T>(mUdf(T),mUdf(T));}
96 
97  inline bool isRev() const { return start > stop; }
98 };
99 
100 
108 template <class T>
109 mClass(Basic) Interval : public BasicInterval<T>
110 {
111 public:
112  inline Interval() : BasicInterval<T>() {}
113  inline virtual ~Interval() {}
114  inline Interval(const T& start,const T& stop);
115  inline Interval(const BasicInterval<T>& b );
116  inline
117  virtual Interval<T>* clone() const;
118 
119  virtual bool inline isUdf() const;
120  virtual void setUdf();
121 
122  inline virtual void scale(const T&);
123 
124  virtual void sort( bool asc=true );
125 
126  virtual bool hasStep() const { return false; }
127  static Interval<T> udf() {return Interval<T>(mUdf(T),mUdf(T));}
128 };
129 
130 
133 
134 
139 template <class T>
140 mClass(Basic) StepInterval : public Interval<T>
141 {
142 public:
143 
144  inline StepInterval();
145  inline StepInterval(const T& start,const T& stop,
146  const T& step);
147  inline StepInterval(const Interval<T>&);
148  inline StepInterval( const StepInterval<T>& si )
149  : Interval<T>(si), step(si.step) {}
150  inline StepInterval<T>& operator=(const Interval<T>&);
151 
152  virtual bool inline isUdf() const;
153  virtual void setUdf();
155  {return StepInterval<T>(mUdf(T),mUdf(T),mUdf(T));}
156 
157  virtual bool hasStep() const { return true; }
158 
159  inline
160  virtual StepInterval<T>* clone() const;
161  inline void set(const T& start,const T& stop,const T& step);
162 
163  template <class X>
164  const StepInterval<T>& setFrom(const Interval<X>&);
165 
166  inline bool isEqual(const StepInterval<T>& i,const T& eps) const;
167  inline bool operator==(const StepInterval<T>&) const;
168  inline bool operator!=(const StepInterval<T>&) const;
169  inline T atIndex(int) const;
170  template <class X>
171  inline int getIndex(const X&) const;
172  template <class X> inline
173  int indexOnOrAfter( X x, float eps ) const;
174 
175  template <class X>
176  inline float getfIndex(const X&) const;
177  template <class X>
178  inline int nearestIndex(const X&) const;
179  template <class X>
180  inline T snap(const X&) const;
181  template <class X>
182  inline T snap(const X&,int dir) const;
184 
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;
190 
191  inline bool isCompatible(const StepInterval<T>&,
192  float eps=mDefEps) const;
196  inline T snapStep(const T& inpstep) const;
199  T step;
200 
201 };
202 
203 
208 template <class T>
210 {
211 public:
212  IntervalND( int ndim_ )
213  : ranges (new Interval<T>[ndim_] )
214  , ndim( ndim_ )
215  , isset( false ) {}
216 
217  virtual ~IntervalND() { delete [] ranges; }
218 
219  int nDim() const { return ndim; }
220  bool isSet() const { return isset; }
221 
222  const Interval<T>& getRange(int dim) const { return ranges[dim]; }
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);
229 
230  template <class X> inline
231  bool includes(const X& val,bool allowrev) const;
232  inline bool intersects(const IntervalND<T>&,
233  bool allowrev) const;
234 
235 protected:
236 
237  int ndim;
239  bool isset;
240 
241 };
242 
243 
244 #include "samplingdata.h"
245 
246 
247 template <class T> template <class X> inline
248 void IntervalND<T>::setRange( const X& val )
249 {
250  for ( int dim=0; dim<ndim; dim++ )
251  ranges[dim].start = ranges[dim].stop = (T) val[dim];
252 
253  isset = true;
254 }
255 
256 
257 
258 template <class T> template <class X> inline
259 void IntervalND<T>::setRange( const X& start, const X& stop)
260 {
261  for ( int dim=0; dim<ndim; dim++ )
262  {
263  ranges[dim].start = start[dim];
264  ranges[dim].stop = stop[dim];
265  }
266 
267  isset = true;
268 }
269 
270 
271 template <class T> template <class X> inline
272 void IntervalND<T>::include( const X& val )
273 {
274 #ifdef __debug__
275  if ( !isset )
276  pErrMsg("Doing include on undefined IntervalND");
277 #endif
278 
279  for ( int dim=0; dim<ndim; dim++ )
280  ranges[dim].include((T) val[dim]);
281 
282  isset = true;
283 }
284 
285 
286 template <class T> template <class X> inline
287 bool IntervalND<T>::includes( const X& val, bool allowrev ) const
288 {
289 #ifdef __debug__
290  if ( !isset )
291  {
292  pErrMsg("Doing includes on undefined IntervalND");
293  return false;
294  }
295 #endif
296 
297  for ( int dim=0; dim<ndim; dim++ )
298  {
299  if ( !ranges[dim].includes(val[dim], allowrev ) )
300  return false;
301  }
302 
303  return true;
304 }
305 
306 
307 template <class T> inline
308 bool IntervalND<T>::intersects( const IntervalND<T>& b, bool allowrev ) const
309 {
310  if ( !isset || !b.isset || ndim!=b.ndim)
311  {
312  pErrMsg("Invalid intersection");
313  return false;
314  }
315 
316  mAllocLargeVarLenArr( T, vector, ndim );
317  mAllocLargeVarLenArr( bool, isstart, ndim );
318  for ( int dim=0; dim<ndim; dim++ )
319  {
320  vector[dim] = ranges[dim].start;
321  isstart[dim] = true;
322  }
323 
324  do
325  {
326  if ( b.includes((T*)vector, allowrev ) )
327  return true;
328 
329  int dim = 0;
330  while ( dim<ndim )
331  {
332  if ( isstart[dim] )
333  {
334  isstart[dim] = false;
335  vector[dim] = ranges[dim].stop;
336  break;
337  }
338  else
339  {
340  isstart[dim] = true;
341  vector[dim] = ranges[dim].start;
342  dim++;
343  }
344  }
345 
346  if ( dim==ndim )
347  break;
348 
349  } while ( true );
350 
351 
352  return false;
353 }
354 
355 
356 template <class T1,class T2>
357 inline void assign( Interval<T1>& i1, const Interval<T2>& i2 )
358 {
359  i1.start = (T1)i2.start;
360  i1.stop = (T1)i2.stop;
362  mDynamicCastGet(const StepInterval<T2>*,si2,&i2)
363  if ( si1 && si2 )
364  si1->step = (T1)si2->step;
365 }
366 
367 
368 template <class T1,class T2>
369 inline void assign( StepInterval<T1>& i1, const StepInterval<T2>& i2 )
370 { i1.start = (T1)i2.start; i1.stop = (T1)i2.stop; i1.step = (T1)i2.step; }
371 
372 
373 
374 // ---------------- BasicInterval ---------------------
375 
376 template <class T>
377 inline BasicInterval<T>&
379 { start = intv.start; stop = intv.stop; return *this; }
380 
381 
382 template <class T> template <class X> inline
383 int BasicInterval<T>::nearestIndex( const X& x, const T& step ) const
384 {
385  return SamplingData<T>( start, step ).nearestIndex( x );
386 }
387 
388 
389 template <class T>
390 template <class X> inline
391 int BasicInterval<T>::indexOnOrAfter( X x, const T& step, float eps ) const
392 {
393  return SamplingData<T>( start, step ).indexOnOrAfter( x, eps );
394 }
395 
396 
397 template <class T> inline BasicInterval<T>::BasicInterval()
398  : start(0), stop(0) {}
399 
400 
401 template <class T> inline
402 BasicInterval<T>::BasicInterval( const T& t1, const T& t2 )
403  : start(t1), stop(t2) {}
404 
405 
406 template <class T> inline
408 { return new Interval<T>( *this ); }
409 
410 
411 template <class T> inline
412 void BasicInterval<T>::set( const T& t1, const T& t2 )
413 { start = t1; stop = t2; }
414 
415 
416 template <class T> inline
417 bool BasicInterval<T>::isEqual( const BasicInterval<T>& i, const T& eps ) const
418 { return mIsEqual(start,i.start,eps) && mIsEqual(stop,i.stop,eps); }
419 
420 
421 template <class T> inline
423 { return start == i.start && stop == i.stop; }
424 
425 
426 template <class T> inline
428 { return ! (i == *this); }
429 
430 
431 template <class T> inline
433 { return Interval<T>(start+i.start, stop+i.stop); }
434 
435 
436 template <class T> inline
438 { start += i.start; stop += i.stop; return *this; }
439 
440 
441 template <class T> template <class X> inline
443 {
444  start = (T)i.start;
445  stop = (T)i.stop;
446  return *this;
447 }
448 
449 
450 template <class T> inline
451 T BasicInterval<T>::width( bool allowrev ) const
452 { return allowrev && isRev() ? start - stop : stop - start; }
453 
454 
455 #define mCenterImpl(func,typ) \
456 template <class T> inline \
457 typ BasicInterval<T>::func() const \
458 { return ((typ)(start+stop))/2; }
459 
462 
463 #undef mCenterImpl
464 
465 
466 template <class T> inline
467 void BasicInterval<T>::shift( const T& len )
468 { start += len; stop += len; }
469 
470 
471 template <class T> inline
472 void BasicInterval<T>::widen( const T& len, bool allowrev )
473 {
474  if ( allowrev && isRev() )
475  { start += len; stop -= len; }
476  else
477  { start -= len; stop += len; }
478 }
479 
480 
481 template <class T> template <class X> inline
482 bool BasicInterval<T>::includes( const X& t, bool allowrev ) const
483 {
484  return allowrev && isRev()
485  ? t>=stop && start>=t
486  : t>=start && stop>=t;
487 }
488 
489 
490 template <class T> template <class X> inline
491 bool BasicInterval<T>::includes( const BasicInterval<X>& t, bool allowrev )const
492 {
493  return includes( t.start, allowrev ) && includes( t.stop, allowrev );
494 }
495 
496 
497 template <class T> template <class X> inline
498 bool BasicInterval<T>::includes( const Interval<X>& t, bool allowrev ) const
499 {
500  return BasicInterval<T>::includes( static_cast<BasicInterval>( t ));
501 }
502 
503 
504 template <class T> template <class X> inline
505 float BasicInterval<T>::pos( X val, bool limit, bool allowrev ) const
506 {
507  float res = allowrev && isRev()
508  ? (val-stop)/(start-stop)
509  : (val-start)/(stop-start);
510 
511  if ( limit )
512  {
513  if ( res<0 ) res = 0;
514  else if ( res>1 ) res = 1;
515  }
516 
517  return res;
518 }
519 
520 
521 template <class T> template <class X> inline
523  bool allowrev ) const
524 {
525  return includes( t.start, allowrev ) || includes( t.stop, allowrev ) ||
526  t.includes( start, allowrev ) || t.includes( stop, allowrev );
527 }
528 
529 
530 template <class T> inline
531 void BasicInterval<T>::include( const T& i, bool allowrev )
532 {
533  if ( allowrev && isRev() )
534  { if ( stop>i ) stop=i; if ( start<i ) start=i; }
535  else
536  { if ( start>i ) start=i; if ( stop<i ) stop=i; }
537 }
538 
539 
540 template <class T> inline
541 void BasicInterval<T>::include( const BasicInterval<T>& i, bool allowrev )
542 { include( i.start, allowrev ); include( i.stop, allowrev ); }
543 
544 
545 template <class T> inline
546 T BasicInterval<T>::atIndex( int idx, const T& step ) const
547 { return start + step * idx; }
548 
549 
550 template <class T> template <class X> inline
551 int BasicInterval<T>::getIndex( const X& t, const T& step ) const
552 { return (int)(( t - start ) / step); }
553 
554 
555 template <class T> template <class X> inline
556 float BasicInterval<T>::getfIndex( const X& t, const T& step ) const
557 { return SamplingData<T>( start, step ).getfIndex( t ); }
558 
559 
560 template <class T> template <class X> inline
561 X BasicInterval<T>::limitValue( const X& t ) const
562 {
563  const bool isrev = isRev();
564  if ( (!isrev&&t>stop) || (isrev&&t<stop) ) return stop;
565  if ( (!isrev&&t<start) || (isrev&&t>start) ) return start;
566  return t;
567 }
568 
569 
570 // ---------------- Interval ------------------------
571 
572 template <class T> inline
573 Interval<T>::Interval( const T& startval, const T& stopval )
574  : BasicInterval<T>( startval, stopval )
575 {}
576 
577 
578 template <class T> inline
580  : BasicInterval<T>( b )
581 {}
582 
583 
584 template <class T> inline
585 void Interval<T>::sort( bool asc )
586 {
590 }
591 
592 
593 template <class T> inline
594 void Interval<T>::scale( const T& factor )
595 { BasicInterval<T>::start *= factor; BasicInterval<T>::stop *= factor; }
596 
597 
598 template <class T> inline
599 bool Interval<T>::isUdf() const
600 {
602 }
603 
604 
605 template <class T> inline
607 { BasicInterval<T>::set( mUdf(T), mUdf(T) ); }
608 
609 
610 // ---------------- StepInterval --------------------
611 
612 template <class T>
614  : step(1) {}
615 
616 
617 template <class T>
618 StepInterval<T>::StepInterval( const T& t1, const T& t2, const T& t3 )
619  : Interval<T>(t1,t2), step(t3) {}
620 
621 
622 template <class T>
624  : Interval<T>(intv)
625 {
626  step = 1;
627  if ( intv.hasStep() )
628  {
629  mDynamicCastGet(const StepInterval<T>*,sintv,&intv);
630  step = sintv ? sintv->step : 1;
631  }
632 }
633 
634 
635 template <class T>
637 { assign( *this, intv ); return *this; }
638 
639 
640 template <class T> inline
642 { return Interval<T>::isUdf() || mIsUdf(step); }
643 
644 
645 template <class T> inline
647 { Interval<T>::set( mUdf(T), mUdf(T) ); step = mUdf(T); }
648 
649 
650 template <class T> inline
652 { return new StepInterval<T>( *this ); }
653 
654 
655 template <class T> inline
656 void StepInterval<T>::set( const T& t1, const T& t2, const T& t3 )
657 { Interval<T>::set( t1, t2 ); step = t3; }
658 
659 
660 template <class T> inline
661 bool StepInterval<T>::isEqual( const StepInterval<T>& i, const T& eps ) const
662 { return Interval<T>::isEqual(i,eps) && mIsEqual(step,i.step,eps); }
663 
664 
665 template <class T> inline
667 { return Interval<T>::operator==(i) && i.step==step; }
668 
669 
670 template <class T> inline
672 { return ! (i == *this); }
673 
674 
675 template <class T> template <class X> inline
677 {
679  if ( i.hasStep() )
680  step = (T)(((const StepInterval<X>&)i).step);
681 
682  return *this;
683 }
684 
685 
686 template <class T> inline
687 T StepInterval<T>::atIndex( int idx ) const
688 { return Interval<T>::atIndex(idx,step); }
689 
690 
691 template <class T> template <class X> inline
692 int StepInterval<T>::getIndex( const X& t ) const
693 { return Interval<T>::getIndex( t, step ); }
694 
695 
696 template <class T> template <class X> inline
697 float StepInterval<T>::getfIndex( const X& t ) const
698 { return Interval<T>::getfIndex( t, step ); }
699 
700 
701 template <class T> template <class X> inline
702 int StepInterval<T>::indexOnOrAfter( X x, float eps ) const
703 {
704  return Interval<T>::indexOnOrAfter( x, step, eps );
705 }
706 
707 
708 template <class T> template <class X> inline
709 int StepInterval<T>::nearestIndex( const X& x ) const
710 { return Interval<T>::nearestIndex( x, step ); }
711 
712 
713 template <class T> template <class X> inline
714 T StepInterval<T>::snap( const X& t ) const
715 { return atIndex( nearestIndex(t) ); }
716 
717 
718 template <class T> template <class X> inline
719 T StepInterval<T>::snap( const X& t, int dir ) const
720 {
721  if ( dir==0 )
722  return atIndex( nearestIndex(t) );
723 
724  const float fidx = getfIndex( t );
725  const int idx = mNINT32( dir==-1 ? Math::Floor(fidx) : Math::Ceil(fidx) );
726  return atIndex( idx );
727 }
728 
729 
730 template <class T> inline
731 void StepInterval<T>::sort( bool asc )
732 {
733  Interval<T>::sort(asc);
734  if ( (asc && step < 0) || (!asc && step > 0) )
735  step = -step;
736 }
737 
738 
739 template <class T> inline
740 void StepInterval<T>::scale( const T& factor )
741 {
742  Interval<T>::scale( factor );
743  step *= factor;
744 }
745 
746 
747 template <class T> inline
749 { return snap( Interval<T>::center() ); }
750 
751 
752 template <class T> inline
753 T StepInterval<T>::snapStep( const T& inputstep ) const
754 {
755  const float relstep = (float) inputstep/step;
756  int nrsteps = mNINT32(relstep);
757  if ( nrsteps<1 ) nrsteps = 1;
758  return step*nrsteps;
759 }
760 
761 
762 template <class T> inline
764 {
765  const float w = Interval<T>::width( true );
766  return w/step;
767 }
768 
769 
770 template <class T>
771 inline int StepInterval<T>::nrSteps() const
772 {
773  if ( !step ) return 0;
774  int ret = (((int)this->start) - ((int) this->stop)) / ((int) step);
775  return ret < 0 ? -ret : ret;
776 }
777 
778 
779 #define mDefFNrSteps(typ) \
780 template <> \
781 inline int StepInterval<typ>::nrSteps() const \
782 { \
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); \
788 }
789 
792 
793 template <class T>
794 inline bool StepInterval<T>::isCompatible( const StepInterval<T>& b,
795  float ) const
796 {
797  if ( step>b.step || b.step%step )
798  return false;
799 
800  // const T diff = static_cast<const Interval<T>*>(this)->start - b.start;
801  const T diff = this->start - b.start;
802  return !(diff%step);
803 }
804 
805 
806 #define mDefFltisCompat(typ,releps) \
807 template <> \
808 inline bool StepInterval<typ>::isCompatible( const StepInterval<typ>& b, \
809  float eps ) const \
810 { \
811  const typ castedeps = (typ) eps; \
812  if ( !mIsEqual(step,b.step, castedeps) ) return false; \
813  \
814  typ nrsteps = (start - b.start) / step; \
815  const int nrstepsi = mNINT32( nrsteps ); \
816  if ( !nrstepsi ) \
817  return mIsEqual( start, b.start, \
818  mIsZero(start,releps) ? releps \
819  : start < 0. ? -start * releps \
820  : start * releps );\
821 \
822  typ reldiff = (nrsteps - nrstepsi) / nrsteps; \
823  return ( (reldiff) < (releps) && (reldiff) > (-releps) ); \
824 }
825 
826 mDefFltisCompat(float,1e-5f)
827 mDefFltisCompat(double,1e-10)
828 // Do not change the above releps values as they originate from the types.
829 
830 #endif
#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
float Ceil(float)
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
float Floor(float)
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

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019