下面是用Visual C++实现的Sutherland-Hodgeman多边形裁剪算法:
1) global.h:
#if !defined(AFX_GLOBAL_H)
#define AFX_GLOBAL_H
typedef enum{Left, Right, Bottom, Top} Edge;
#define N_EDGE 4
typedef struct{float x,y;} Point2f;
typedef struct{int x,y;} Point2i;
int ClipPolygon(Point2i wMin,Point2i wMax,int n,Point2f *pIn,Point2f
*pOut);
#define MAXOUTPUT 200 //输出多边形的最多点数
#endif//AFX_GLOBAL_H |