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

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