static void fill_clipped_contour (hidGC gc, PLINE *pl, const BoxType *clip_box) { PLINE *pl_copy; POLYAREA *clip_poly; POLYAREA *piece_poly; POLYAREA *clipped_pieces; POLYAREA *draw_piece; int x; clip_poly = RectPoly (clip_box->X1, clip_box->X2, clip_box->Y1, clip_box->Y2); poly_CopyContour (&pl_copy, pl); piece_poly = poly_Create (); poly_InclContour (piece_poly, pl_copy); x = poly_Boolean_free (piece_poly, clip_poly, &clipped_pieces, PBO_ISECT); if (x != err_ok || clipped_pieces == NULL) return; draw_piece = clipped_pieces; do { /* NB: The polygon won't have any holes in it */ fill_contour (gc, draw_piece->contours); } while ((draw_piece = draw_piece->f) != clipped_pieces); poly_Free (&clipped_pieces); }
static POLYAREA * original_poly (PolygonType * p, bool *forward) { PLINE *contour = NULL; POLYAREA *np = NULL; Cardinal n; Vector v; int hole = 0; *forward = true; if ((np = poly_Create ()) == NULL) return NULL; /* first make initial polygon contour */ for (n = 0; n < p->PointN; n++) { /* No current contour? Make a new one starting at point */ /* (or) Add point to existing contour */ v[0] = p->Points[n].X; v[1] = p->Points[n].Y; if (contour == NULL) { if ((contour = poly_NewContour (v)) == NULL) return NULL; } else { poly_InclVertex (contour->head.prev, poly_CreateNode (v)); } /* Is current point last in contour? If so process it. */ if (n == p->PointN - 1 || (hole < p->HoleIndexN && n == p->HoleIndex[hole] - 1)) { poly_PreContour (contour, TRUE); /* Log the direction in which the outer contour was specified */ if (hole == 0) *forward = (contour->Flags.orient == PLF_DIR); /* make sure it is a positive contour (outer) or negative (hole) */ if (contour->Flags.orient != (hole ? PLF_INV : PLF_DIR)) poly_InvContour (contour); assert (contour->Flags.orient == (hole ? PLF_INV : PLF_DIR)); poly_InclContour (np, contour); contour = NULL; assert (poly_Valid (np)); hole++; } } return np; }