00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXEXTENTD_H
00025 #define FXEXTENTD_H
00026
00027
00028 namespace FX {
00029
00030
00032 class FXAPI FXExtentd {
00033 public:
00034 FXVec2d lower;
00035 FXVec2d upper;
00036 public:
00037
00039 FXExtentd(){}
00040
00042 FXExtentd(const FXExtentd& ext):lower(ext.lower),upper(ext.upper){}
00043
00045 FXExtentd(const FXVec2d& lo,const FXVec2d& hi):lower(lo),upper(hi){}
00046
00048 FXExtentd(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi):lower(xlo,ylo),upper(xhi,yhi){}
00049
00051 FXExtentd& operator=(const FXExtentd& ext){ lower=ext.lower; upper=ext.upper; return *this; }
00052
00054 FXVec2d& operator[](FXint i){ return (&lower)[i]; }
00055
00057 const FXVec2d& operator[](FXint i) const { return (&lower)[i]; }
00058
00060 bool operator==(const FXExtentd& ext) const { return lower==ext.lower && upper==ext.upper;}
00061 bool operator!=(const FXExtentd& ext) const { return lower!=ext.lower || upper!=ext.upper;}
00062
00064 FXdouble width() const { return upper.x-lower.x; }
00065
00067 FXdouble height() const { return upper.y-lower.y; }
00068
00070 FXdouble longest() const;
00071
00073 FXdouble shortest() const;
00074
00076 FXdouble diameter() const;
00077
00079 FXdouble radius() const;
00080
00082 FXVec2d diagonal() const;
00083
00085 FXVec2d center() const;
00086
00088 bool empty() const;
00089
00091 bool contains(FXdouble x,FXdouble y) const;
00092
00094 bool contains(const FXVec2d& p) const;
00095
00097 bool contains(const FXExtentd& ext) const;
00098
00100 FXExtentd& include(FXdouble x,FXdouble y);
00101
00103 FXExtentd& include(const FXVec2d& v);
00104
00106 FXExtentd& include(const FXExtentd& ext);
00107
00109 friend FXAPI bool overlap(const FXExtentd& a,const FXExtentd& b);
00110
00112 FXVec2d corner(FXint c) const { return FXVec2d((&lower)[c&1].x, (&lower)[(c>>1)&1].y); }
00113
00115 friend FXAPI FXExtentd unite(const FXExtentd& a,const FXExtentd& b);
00116
00118 friend FXAPI FXExtentd intersect(const FXExtentd& a,const FXExtentd& b);
00119
00121 friend FXAPI FXStream& operator<<(FXStream& store,const FXExtentd& ext);
00122
00124 friend FXAPI FXStream& operator>>(FXStream& store,FXExtentd& ext);
00125 };
00126
00127
00128 extern FXAPI bool overlap(const FXExtentd& a,const FXExtentd& b);
00129
00130 extern FXAPI FXExtentd unite(const FXExtentd& a,const FXExtentd& b);
00131 extern FXAPI FXExtentd intersect(const FXExtentd& a,const FXExtentd& b);
00132
00133 extern FXAPI FXStream& operator<<(FXStream& store,const FXExtentd& ext);
00134 extern FXAPI FXStream& operator>>(FXStream& store,FXExtentd& ext);
00135
00136 }
00137
00138 #endif
00139