EDGEPT *make_tess_edgepts( //make tess edgepts POLYPT_LIST *edgeptlist, //list to convert TPOINT &tl, //bounding box TPOINT &br) { inT32 index; POLYPT_IT it = edgeptlist; //iterator POLYPT *edgept; //current edgept EDGEPT *head; //output list EDGEPT *tail; //end of list EDGEPT *tessedgept; head = NULL; tail = NULL; tl.x = MAX_INT16; tl.y = -MAX_INT16; br.x = -MAX_INT16; br.y = MAX_INT16; for (it.mark_cycle_pt (); !it.cycled_list ();) { edgept = it.data (); tessedgept = newedgept (); tessedgept->pos.x = (inT16) edgept->pos.x (); tessedgept->pos.y = (inT16) edgept->pos.y (); if (tessedgept->pos.x < tl.x) tl.x = tessedgept->pos.x; if (tessedgept->pos.x > br.x) br.x = tessedgept->pos.x; if (tessedgept->pos.y > tl.y) tl.y = tessedgept->pos.y; if (tessedgept->pos.y < br.y) br.y = tessedgept->pos.y; if (head != NULL && tessedgept->pos.x == tail->pos.x && tessedgept->pos.y == tail->pos.y) { oldedgept(tessedgept); } else { for (index = 0; index < EDGEPTFLAGS; index++) tessedgept->flags[index] = 0; if (head != NULL) { tail->vec.x = tessedgept->pos.x - tail->pos.x; tail->vec.y = tessedgept->pos.y - tail->pos.y; tessedgept->prev = tail; } tessedgept->next = head; if (head) tail->next = tessedgept; else head = tessedgept; tail = tessedgept; } it.forward (); } head->prev = tail; tail->vec.x = head->pos.x - tail->pos.x; tail->vec.y = head->pos.y - tail->pos.y; if (head == tail) { oldedgept(head); return NULL; //empty } return head; }
/********************************************************************** * make_edgept * * Create an EDGEPT and hook it into an existing list of edge points. **********************************************************************/ EDGEPT *make_edgept(int x, int y, EDGEPT *next, EDGEPT *prev) { EDGEPT *this_edgept; /* Create point */ this_edgept = newedgept (); this_edgept->pos.x = x; this_edgept->pos.y = y; /* Hook it up */ this_edgept->next = next; this_edgept->prev = prev; prev->next = this_edgept; next->prev = this_edgept; /* Set up vec entries */ this_edgept->vec.x = this_edgept->next->pos.x - x; this_edgept->vec.y = this_edgept->next->pos.y - y; this_edgept->prev->vec.x = x - this_edgept->prev->pos.x; this_edgept->prev->vec.y = y - this_edgept->prev->pos.y; reveal_edge(this_edgept); this_edgept->flags[1] = 0; return (this_edgept); }