 |
OpendTect
6.6
|
Go to the documentation of this file.
58 inline double abs()
const;
161 bool topislow=
true)
const;
238 {
return xOutside(p.
x,eps) || yOutside(p.
y,eps); }
243 {
return !isOutside(p,eps); }
252 return other.
isInside(this->topleft_,eps)
253 && other.
isInside(this->bottomright_,eps);
273 template <
class T>
inline
278 template <
class T>
template <
class TT>
inline
280 { x=a.
x; y=a.
y;
return *
this;}
282 template <
class T>
inline
286 template <
class T>
template <
class TT>
inline
290 template <
class T>
inline
292 { x = y = 0;
return *
this; }
294 template <
class T>
inline
299 template <
class T>
inline
301 {
return idx ? y : x; }
304 template <
class T>
inline
306 {
return idx ? y : x; }
309 template <
class T>
inline
311 {
return p.
x == x && p.
y == y; }
314 template <
class T>
inline
316 {
return !(*
this==p); }
318 template <
class T>
inline
320 { x += dist; y += dist;
return *
this; }
323 template <
class T>
inline
325 { x *= factor; y *= factor;
return *
this; }
328 template <
class T>
inline
330 { x /= den; y /= den;
return *
this; }
333 template <
class T>
inline
335 { x += p.
x; y += p.
y;
return *
this; }
338 template <
class T>
inline
340 { x -= p.
x; y -= p.
y;
return *
this; }
343 template <
class T>
inline
348 template <
class T>
inline
353 template <
class T>
inline
358 template <
class T>
inline
363 template <
class T>
inline
368 template <
class T>
inline
375 template <
class T>
inline
380 template <
class T>
inline
382 {
return x*x + y*y; }
385 template <
class T>
inline
390 template <
class T>
inline
393 const T xdiff = x-pt.
x;
394 const T ydiff = y-pt.
y;
395 return xdiff*xdiff + ydiff*ydiff;
399 template <
class T>
template <
class TT>
inline
405 template <
class T>
inline
407 { width_=w; height_=h; }
410 template <
class T>
inline
415 template <
class T>
inline
420 template <
class T>
inline
425 template <
class T>
inline
430 template <
class T>
inline
435 template <
class T>
inline
440 template <
class T>
inline
442 {
return Size2D<T>( width_+val, height_+val); }
445 template <
class T>
inline
447 { width_ += val; height_ += val;
return *
this; }
450 template <
class T>
inline
452 { width_ -= val; height_ -= val;
return *
this; }
455 template <
class T>
inline
460 template <
class T>
inline
464 if ( width_<0 ) width_ = -width_;
465 if ( height_<0 ) height_ = -height_;
471 template <
class T>
inline
474 , bottomright_(
Point2D<T>(r,b) )
478 template <
class T>
inline
480 : topleft_( tl ) , bottomright_( br )
484 template <
class T>
inline
486 : topleft_( tl ) , bottomright_( tl.x+sz.width(), tl.y+sz.height() )
490 template <
class T>
inline
495 template <
class T>
inline
500 template <
class T>
inline
505 template <
class T>
inline
510 template <
class T>
inline
515 template <
class T>
inline
517 {
return bottomright_; }
520 template <
class T>
inline
523 return Point2D<T>( (topleft_.x+bottomright_.x)/2,
524 (topleft_.y+bottomright_.y)/2 );
528 template <
class T>
inline
533 template <
class T>
inline
535 { bottomright_ = br; }
538 template <
class T>
inline
540 { topleft_.y = tr.
y; bottomright_.x = tr.
x; }
543 template <
class T>
inline
545 { topleft_.x = tr.
x; bottomright_.y = tr.
y; }
548 template <
class T>
inline
550 { topleft_.y = rg.start; bottomright_.y = rg.stop; }
553 template <
class T>
inline
555 { topleft_.x = rg.start; bottomright_.x = rg.stop; }
558 template <
class T>
inline
565 res.
y =
mMAX( res.
y,
mMIN( bottom(), top() ) );
566 res.
y =
mMIN( res.
y,
mMAX( bottom(), top() ) );
572 template <
class T>
inline
577 template <
class T>
inline
579 {
return revY() ? bottom()-top() : top()-bottom(); }
582 template <
class T>
inline
584 {
return topleft_.x; }
587 template <
class T>
inline
589 {
return topleft_.y; }
592 template <
class T>
inline
594 {
return bottomright_.x; }
597 template <
class T>
inline
599 {
return bottomright_.y; }
602 template <
class T>
inline
604 { topleft_.x = val; }
607 template <
class T>
inline
609 { topleft_.y = val; }
612 template <
class T>
inline
614 { bottomright_.x = val; }
617 template <
class T>
inline
619 { bottomright_.y = val; }
622 template <
class T>
inline
625 if ( leftislow == (
left() >
right()) )
return false;
626 if ( topislow == (top() > bottom()) )
return false;
632 template <
class T>
inline
635 if ( leftislow == (
left() >
right()) ) swapHor();
636 if ( topislow == (top() > bottom()) ) swapVer();
640 template <
class T>
inline
642 {
return Size2D<T>( width(), height() ); }
645 template <
class T>
inline
647 { topleft_.zero(); bottomright_.zero(); }
650 template <
class T>
inline
652 {
return topleft_.isDefined() && bottomright_.isDefined(); }
655 template <
class T>
inline
657 { topleft_ += p; bottomright_ += p;
return *
this; }
660 template <
class T>
inline
662 { topleft_ -= p; bottomright_ -= p;
return *
this; }
665 template <
class T>
inline
667 { bottomright_.x += sz.
width(); bottomright_.y += sz.
height();
return *
this; }
670 template <
class T>
inline
672 { bottomright_.x -= sz.
width(); bottomright_.y -= sz.
height();
return *
this; }
675 template <
class T>
inline
679 topleft_.x = bottomright_.x;
684 template <
class T>
inline
688 topleft_.y = bottomright_.y;
693 template <
class T>
inline
698 template <
class T>
inline
700 {
return bottom() > top(); }
707 return this->revX() ? (x > this->
left() || x < this->
right())
708 : (x < this->
left() || x > this->
right());
715 return this->revY() ? (y > this->bottom() || y < this->top())
716 : (y < this->bottom() || y > this->top());
723 return (pt.
x == this->left() || pt.
x == this->right())
724 && (pt.
y == this->top() || pt.
y == this->bottom());
732 return this->revX() ? (x-this->
left() > eps || this->
right()-x > eps)
733 : (this->
left()-x > eps || x-this->
right() > eps);
740 return this->revY() ? (this->top()-y > eps || y-this->bottom() > eps)
741 : (y-this->top() > eps || this->bottom()-y > eps);
748 if ( xOutside(pt.
x) || yOutside(pt.
y) )
return false;
749 return fabs(pt.
x - this->left()) < eps || fabs(pt.
x - this->right()) < eps
750 || fabs(pt.
y - this->top()) < eps || fabs(pt.
y - this->bottom()) < eps;
757 return (this->revX() ? (this->
left()-pt.
x>eps && pt.
x-this->right()>eps)
758 : (pt.
x-this->left()>eps && this->right()-pt.
x>eps))
759 && (this->revY() ? (pt.
y-this->bottom()<-eps && this->top()-pt.
y<-eps)
760 : (this->bottom()-pt.
y<-eps && pt.
y-this->top()<-eps));
771 {
return x1 + f * (x1 - x2); }
798 template <
class T>
inline
800 {
return !xOutside( p.
x ) && !yOutside( p.
y ) && !isOnSide( p ); }
803 template <
class T>
inline
805 {
return xOutside(p.
x) || yOutside(p.
y); }
808 template <
class T>
inline
810 {
return !isOutside(p); }
813 template <
class T>
inline
820 template <
class T>
inline
823 return other.
isInside(this->topleft_) && other.
isInside(this->bottomright_);
827 template <
class T>
inline
832 iwiderPos<T>(this->top(),this->bottom(),f),
833 iwiderPos<T>(this->
right(),this->
left(),f),
834 iwiderPos<T>(this->bottom(),this->top(),f) );
845 fwiderPos(this->bottom(),this->top(),f) );
849 template <
class T>
template <
class TT>
inline
853 this->bottomright_.scale(xx,yy) );
884 bottomright_ += trans;
892 if ( !isDefined() ) *
this = r;
906 if ( r.
bottom() > bottom() ) bottomright_.y = r.
bottom();
907 if ( r.
top() < top() ) topleft_.y = r.
top();
911 if ( r.
bottom() < bottom() ) bottomright_.y = r.
bottom();
912 if ( r.
top() > top() ) topleft_.y = r.
top();
921 if ( !isDefined() ) topleft_ = bottomright_ = p;
925 if ( p.
x >
left() ) topleft_.
x = p.
x;
926 if ( p.
x <
right() ) bottomright_.x = p.
x;
930 if ( p.
x <
left() ) topleft_.x = p.
x;
931 if ( p.
x >
right() ) bottomright_.x = p.
x;
935 if ( p.
y > bottom() ) bottomright_.y = p.
y;
936 if ( p.
y < top() ) topleft_.y = p.
y;
940 if ( p.
y < bottom() ) bottomright_.y = p.
y;
941 if ( p.
y > top() ) topleft_.y = p.
y;
void Swap(T &a, T &b)
Definition: commondefs.h:46
T operator[](int idx) const
Definition: geometry.h:305
bool contains(const PosRectangle< T > &other, T eps) const
Definition: geometry.h:245
bool operator!=(const Size2D< T > &) const
Definition: geometry.h:416
void setXY(T xx, T yy)
Definition: geometry.h:283
void sortCorners(bool leftislow=true, bool topislow=true)
Definition: geometry.h:633
void setTopLeft(Point2D< T >)
Definition: geometry.h:529
bool xOutside(T) const
Definition: geometry.h:705
void setBottom(T val)
Definition: geometry.h:618
PixRectangle(T l=0, T t=0, T r=0, T b=0)
Definition: geometry.h:775
Point2D< T > topRight() const
Definition: geometry.h:506
Point2D< float > PointF
Definition: geometry.h:72
T iwiderPos(int x1, int x2, double f)
Definition: geometry.h:765
T bottom() const
Definition: geometry.h:598
void translate(const Point2D< T > &)
Definition: geometry.h:881
PixRectangle(const Point2D< T > &tl, const Size2D< T > &sz)
Definition: geometry.h:787
void swapXY()
Definition: geometry.h:369
Point2D< T > & operator-=(const Point2D< T > &)
Definition: geometry.h:339
bool contains(const Point2D< T > &) const
Definition: geometry.h:809
bool isOutside(const Point2D< T > &) const
Definition: geometry.h:804
Point2D< T > scale(TT xx, TT yy) const
Definition: geometry.h:400
@ left
Definition: i_layout.h:28
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
void setBottomRight(Point2D< T >)
Definition: geometry.h:534
static Point2D< T > udf()
Definition: geometry.h:65
void setTopBottom(const Interval< T > &)
Definition: geometry.h:549
#define sCast(tp, v)
Definition: commondefs.h:141
Point2D< T > operator-(const Point2D< T > &) const
Definition: geometry.h:349
bool operator>(const Rectangle< T > &) const
Definition: geometry.h:858
bool isOnSide(const Point2D< T > &) const
Definition: geometry.h:721
#define mMAX(x, y)
Definition: commondefs.h:61
bool isDefined() const
Definition: geometry.h:651
void setRight(T val)
Definition: geometry.h:613
void setTopRight(Point2D< T >)
Definition: geometry.h:539
bool isInside(const PixRectangle< T > &) const
Definition: geometry.h:821
void setLeft(T val)
Definition: geometry.h:603
Rectangle(T l=0, T t=0, T r=0, T b=0)
Definition: geometry.h:472
Rectangle< T > & operator-=(const Point2D< T > &)
Definition: geometry.h:661
T height_
Definition: geometry.h:101
PixRectangle< T > grownBy(double sidesincreasebyfactor=1) const
Definition: geometry.h:828
double abs() const
Definition: geometry.h:376
Point2D< T > bottomRight() const
Definition: geometry.h:516
T top() const
Definition: geometry.h:588
Point2D< T > & setFrom(const Point2D< TT > &)
Definition: geometry.h:279
Point2D< T > centre() const
Definition: geometry.h:521
void limitTo(const Rectangle< T > &)
Definition: geometry.h:873
bool isInside(const Point2D< T > &) const
Definition: geometry.h:799
void swapHor()
Definition: geometry.h:676
Rectangle< T > & operator+=(const Point2D< T > &)
Definition: geometry.h:656
T right() const
Definition: geometry.h:593
bool isOnSide(const Point2D< T > &p, T eps) const
Definition: geometry.h:746
void setWidth(T val)
Definition: geometry.h:431
bool operator!=(const Rectangle< T > &) const
Definition: geometry.h:496
Point2D< T > & zero()
Definition: geometry.h:291
PixRectangle(const Point2D< T > &tl, const Point2D< T > &br)
Definition: geometry.h:781
bool isInside(const PosRectangle< T > &other, T eps) const
Definition: geometry.h:250
void include(const Rectangle< T > &)
Definition: geometry.h:889
void zero()
Definition: geometry.h:646
Size2D< T > & operator+=(T val)
Definition: geometry.h:446
T fwiderPos(T x1, T x2, T f)
Definition: geometry.h:770
Point2D< T > operator/(const T den) const
Definition: geometry.h:359
PosRectangle< float > RectF
Definition: geometry.h:269
void setBottomLeft(Point2D< T >)
Definition: geometry.h:544
bool checkCorners(bool leftislow=true, bool topislow=true) const
Definition: geometry.h:623
T & operator[](int idx)
Definition: geometry.h:300
void include(const Point2D< T > &)
Definition: geometry.h:918
T left() const
Definition: geometry.h:583
Size2D< T > size() const
Definition: geometry.h:641
bool isDefined() const
Definition: geometry.h:364
PosRectangle< T > grownBy(T sidesincreasebyfactor=1) const
Definition: geometry.h:839
bool yOutside(T, T) const
Definition: geometry.h:738
void swapVer()
Definition: geometry.h:685
PosRectangle(Point2D< T > tl, Point2D< T > br)
Definition: geometry.h:234
PosRectangle(T l=0, T t=0, T r=0, T b=0)
Definition: geometry.h:232
Floating-point rectangle class.
Definition: geometry.h:230
#define mClass(module)
Definition: commondefs.h:181
PosRectangle< double > RectD
Definition: geometry.h:270
double distTo(const Point2D< T > &) const
Definition: geometry.h:386
Point2D< T > bottomright_
Definition: geometry.h:182
PixRectangle(const Rectangle< T > &)
Definition: geometry.h:793
bool operator!=(const Point2D< T > &) const
Definition: geometry.h:315
Point2D< T > operator-()
Definition: geometry.h:295
T width_
Definition: geometry.h:100
bool operator==(const Point2D< T > &) const
Definition: geometry.h:310
Rectangle(const Point2D< T > &tl, const Point2D< T > &br)
Definition: geometry.h:479
T sqDistTo(const Point2D< T > &) const
Definition: geometry.h:391
bool revY() const
Definition: geometry.h:699
Point2D< T > & operator/=(T den)
Definition: geometry.h:329
bool contains(const PixRectangle< T > &) const
Definition: geometry.h:814
Point2D< int > PointI
Definition: geometry.h:71
Size2D< T > & operator-=(const Size2D< T > &)
Definition: geometry.h:461
Point2D< T > & operator+=(const Point2D< T > &)
Definition: geometry.h:334
PosRectangle< int > RectI
Definition: geometry.h:268
bool xOutside(T, T) const
Definition: geometry.h:730
void setLeftRight(const Interval< T > &)
Definition: geometry.h:554
Point2D< T > & operator+=(T dist)
Definition: geometry.h:319
bool contains(const Point2D< T > &p, T eps) const
Definition: geometry.h:242
Integer rectangle class.
Definition: geometry.h:197
Size2D(T w=0, T h=0)
Definition: geometry.h:406
@ right
Definition: i_layout.h:28
Point2D< T > topLeft() const
Definition: geometry.h:501
Point2D< T > operator+(const Point2D< T > &) const
Definition: geometry.h:344
T sqAbs() const
Definition: geometry.h:381
Point2D< double > PointD
Definition: geometry.h:73
T width() const
Definition: geometry.h:573
Size2D< T > & operator-=(T val)
Definition: geometry.h:451
T width() const
Definition: geometry.h:421
bool revX() const
Definition: geometry.h:694
bool yOutside(T) const
Definition: geometry.h:713
PosRectangle< T > scale(TT xx, TT yy) const
Definition: geometry.h:850
Definition: geometry.h:19
Basic point class.
Definition: geometry.h:27
#define mMIN(x, y)
Definition: commondefs.h:62
Rectangle(const Point2D< T > &tl, const Size2D< T > &sz)
Definition: geometry.h:485
Size2D< T > & operator+=(const Size2D< T > &)
Definition: geometry.h:456
T y
Definition: geometry.h:68
bool operator==(const Size2D< T > &) const
Definition: geometry.h:411
void setXY(TT xx, TT yy)
Definition: geometry.h:287
Point2D< T > bottomLeft() const
Definition: geometry.h:511
T x
Definition: geometry.h:67
Basic 2D sizes (width/height) class.
Definition: geometry.h:81
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
T height() const
Definition: geometry.h:578
bool operator>(const ObjectWithName &obj1, const ObjectWithName &obj2)
Definition: namedobj.h:95
Size2D< T > operator+(T val) const
Definition: geometry.h:441
Rectangle< T > & operator+=(const Size2D< T > &)
Definition: geometry.h:666
Point2D< T > moveInside(const Point2D< T > &) const
Definition: geometry.h:559
Point2D(T xx=0, T yy=0)
Definition: geometry.h:274
Point2D< T > operator*(const T factor) const
Definition: geometry.h:354
Rectangle< T > & operator-=(const Size2D< T > &)
Definition: geometry.h:671
void setHeight(T val)
Definition: geometry.h:436
Basic 2D rectangle class.
Definition: geometry.h:118
bool operator==(const Rectangle< T > &) const
Definition: geometry.h:491
Interval of values.
Definition: commontypes.h:30
Point2D< T > topleft_
Definition: geometry.h:181
bool isOutside(const Point2D< T > &p, T eps) const
Definition: geometry.h:237
Point2D< T > & operator*=(T factor)
Definition: geometry.h:324
#define mNINT32(x)
Definition: commondefs.h:58
bool isInside(const Point2D< T > &, T eps) const
Definition: geometry.h:755
T height() const
Definition: geometry.h:426
void setTop(T val)
Definition: geometry.h:608
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021