#define LEFT_EDGE 0x1
#define RIGHT_EDGE 0x2
#define BOTTOM_EDGE 0x4
#define TOP_EDGE 0x8
#define INSIDE(a) (!a)
#define REJECT(a,b) (a&b)
#define ACCEPT(a,b) (!(a|b))
#define FALSE 0
#define TRUE 1
struct point2d
{
int x;
int y;
};
unsigned char encode(struct point2d pt,struct point2d winMin,struct point2d winMax)
{
unsigned char code=0x00;
if(pt.x<winMin.x)
code = code | LEFT_EDGE;
if(pt.x>winMax.x)
code = code | RIGHT_EDGE;
if(pt.y<winMin.y)
code = code | BOTTOM_EDGE;
if(pt.y>winMax.y)
code = code | TOP_EDGE;
return code;
}
void swapPts(struct point2d *p1,struct point2d *p2)
{
struct point2d tmp;
tmp=*p1;
*p1=*p2;
*p2=tmp;
}
void swapCodes(unsigned char *c1,unsigned char * c2)
{
unsigned char tmp;
评论0
最新资源