예제 #1
0
void BuildEdgeList(ILuint cnt, ILpointi *pts, Edge **edges)
{
	Edge *edge;
	ILpointi v1, v2;
	ILuint i;
	ILint yPrev = pts[cnt - 2].y;

	v1.x = pts[cnt-1].x;
	v1.y = pts[cnt-1].y;

	for (i = 0; i < cnt; i++) {
		v2 = pts[i];
		if (v1.y != v2.y) {			// nonhorizontal line
			edge = (Edge*)ialloc(sizeof(Edge));
			if (v1.y < v2.y) {		// up-going edge
				MakeEdgeRec(v1, v2, yNext(i, cnt, pts), edge, edges);
			}
			else {					// down-going edge
				MakeEdgeRec(v2, v1, yPrev, edge, edges);
			}
		}
		yPrev = v1.y;
		v1 = v2;
	}
}
예제 #2
0
void buildEdgeList (int cnt, struct Point2D * pts, Edge * edges[])
{
    Edge * edge;
    struct Point2D v1, v2;
    int i, yPrev = (int) pts[cnt - 2].y;

    v1.x = pts[cnt-1].x; v1.y = pts[cnt-1].y;
    for (i=0; i<cnt; i++) {
        v2 = pts[i];
        if (v1.y != v2.y) {                /* nonhorizontal line */
            edge = (Edge *) malloc (sizeof (Edge));
            if (v1.y < v2.y)                 /* up-going edge      */
                makeEdgeRec (v1, v2, yNext (i, cnt, pts), edge, edges);
            else                             /* down-going edge    */
                makeEdgeRec (v2, v1, yPrev, edge, edges);
        }
        yPrev = v1.y;
        v1 = v2;
    }
}