rectangle Struct Reference

#include <utils.h>

List of all members.

Public Member Functions

void normalize ()
int isIntersect (const rectangle &r2) const
int isVerInter (const rectangle &r2) const
int ivHorInter (const rectangle &r2) const
GBool hitTest (const point &pt) const
GBool hitTest (const int x, const int y) const

Public Attributes

int left
int top
int right
int bottom


Detailed Description

Definition at line 49 of file utils.h.


Member Function Documentation

void rectangle::normalize (  ) 

Definition at line 62 of file utils.cpp.

00063 {
00064     if (left > right) { swap(left, right);}
00065     if (top > bottom) { swap(top, bottom);}
00066 }

Here is the call graph for this function:

int rectangle::isIntersect ( const rectangle r2  )  const

Definition at line 25 of file utils.cpp.

00026 {
00027     if ((r2.left > right  || r2.right < left || 
00028          r2.top > bottom  || r2.bottom < top ))
00029     {
00030         return 0;
00031     }
00032     // calculate size
00033     int width  = min(right, r2.right) - max(left, r2.left);
00034     int height = min(bottom, r2.bottom) - max(top, r2.top);
00035     return width * height;
00036 }

Here is the call graph for this function:

int rectangle::isVerInter ( const rectangle r2  )  const

Definition at line 40 of file utils.cpp.

00041 {
00042     if (r2.top > bottom || r2.bottom < top)
00043     {
00044         return 0;
00045     }
00046     int height = min(bottom, r2.bottom) - max(top, r2.top);
00047     return height;
00048 }

Here is the call graph for this function:

int rectangle::ivHorInter ( const rectangle r2  )  const

Definition at line 52 of file utils.cpp.

00053 {
00054     if (r2.left > right || r2.right < left)
00055     {
00056         return 0;
00057     }
00058     int width = min(right, r2.right) - max(left, r2.left);
00059     return width;
00060 }

Here is the call graph for this function:

GBool rectangle::hitTest ( const point pt  )  const

Definition at line 68 of file utils.cpp.

00069 {
00070     return (left <= pt.x && right >= pt.x &&
00071             top <= pt.y && bottom >= pt.y);
00072 }

GBool rectangle::hitTest ( const int  x,
const int  y 
) const

Definition at line 74 of file utils.cpp.

00075 {
00076     return (left <= x && right >= x &&
00077             top <= y && bottom >= y);
00078 }


Member Data Documentation

Definition at line 51 of file utils.h.

Definition at line 52 of file utils.h.

Definition at line 53 of file utils.h.

Definition at line 54 of file utils.h.


The documentation for this struct was generated from the following files:

Generated on Wed Feb 4 18:26:36 2009 by  doxygen 1.5.6