Polygonal filling algorithm
// ---------- ------- Define basic data ------------------ // // -------------------- Struct_Def.h ------ ---------------------------------------------------------------------------------------------------------------------------------------
Const int max_y = 1028; const Int max_x = 1024; const Int max_arc = 100; // The total number of fixed edges is up to 100
TypedEf struct arcnode // definitions Belt {INT X1, Y1; INT X2, Y2;} ArcNode; typef struct node // definition EOT, the list of linked list in the AET table {int ymin; float xs; float xx; node * next; Elemnode, * elemlink; typedef struct nodey // Y barrel table {elemlink link; int y;} nodey; typef strunt table // Table EOT and table AET also structure {nodey nodey [max_y];} * TableList;
TableList createEOTList (ArcNode arrayARC [MAX_ARC], int n); void ShowTable (const Table * table); void InsertArcNode (TableList table, Node * const node, int Y); TableList EOT_to_AET (const TableList table);
// -------------------------------- Decreated algorithm ------------ -----------------------
TableList CreateEotList (ArcNode Arrayarc [MAX_ARC], INT N) {TableList Eotlist = New Table; INT i; for (i = 0; I
Int y; for (i = 0; i
Void InsertarcNode (TableList Table, Node * const node, int y) {if (Table-> Nodey [Y] .LINK == NULL) {// Header is empty Table-> Nodey [y] .LINK = Node; Node -> next = null; return; else {elemlink head_node = table-> node = Table-> nodey [y] .link; elemony * temp_node = head_node; if (((Node-> xs
For (i = 0; i
void CTestHTView :: OnDraw (CDC * pDC) {CTestHTDoc * pDoc = GetDocument (); ASSERT_VALID (pDoc); int i, j; TableList tableEOT = new Table; tableEOT = createEOTList (pDoc-> ArrayARC, pDoc-> num); // TableList Tableaet = New Table; Tableaet = Eot_to_aet (Tableeot);
Node; int x1, x2; for (i = max_y-1; i> = 0; i -) {head = Tableaet-> node [i] .link; while (head) {x1 = head -> xs; head = head-> next; x2 = head-> xs; for (j = x1; j