00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef UTILS_H_
00020 #define UTILS_H_
00021 #include "goo/gtypes.h"
00022
00023 inline int min(const int a, const int b)
00024 {
00025 return (a > b)? b: a;
00026 }
00027
00028 inline int max(const int a, const int b)
00029 {
00030 return (a > b)? a : b;
00031 }
00032
00033
00034 inline void swap(int & a, int & b)
00035 {
00036 int t = a; a = b; b = t;
00037 }
00038
00039 inline void swap(double & a, double & b)
00040 {
00041 double t = a; a = b; b = t;
00042 }
00043
00044 struct point
00045 {
00046 int x, y;
00047 };
00048
00049 struct rectangle
00050 {
00051 int left;
00052 int top;
00053 int right;
00054 int bottom;
00055
00056 void normalize();
00057 int isIntersect(const rectangle & r2) const;
00058 int isVerInter(const rectangle & r2) const;
00059 int ivHorInter(const rectangle & r2) const;
00060 GBool hitTest(const point & pt) const;
00061 GBool hitTest(const int x, const int y) const;
00062 };
00063
00064 #endif