|
|
1.1 root 1: #include "ideal.h"
2: #include "y.tab.h"
3:
4: LINEPTR opqact (opqstmt, noadtree, linelist)
5: STMTPTR opqstmt;
6: NOADPTR noadtree;
7: LINEPTR linelist;
8: {
9: STMTPTR bdstmt;
10: LINEPTR inlines, outlines, both;
11: LINENODE nuline;
12: LINEPTR prevline;
13:
14: if (when_bug & 0100) bug_on;
15: prevline = &nuline;
16: prevline->next = NULL;
17: both = linelist;
18: if ((bdstmt = nextstmt (BDLIST, noadtree->defnode->parm->stmtlist))
19: || (bdstmt = nextstmt (BDLIST,findbox (noadtree->defnode->parm->name,FALSE)->stmtlist))) {
20: EDGENODE edgelist;
21: EXPRPTR bdwalk, lastbd;
22: INTLPTR prevtx, curvtx, postvtx;
23: EDGEPTR edgewalk;
24: EDGEPTR forfreeing;
25: lastbd = (EXPRPTR) tail ((BOXPTR) bdstmt->stmt);
26: lastbd->next = exprgen (((EXPRPTR) bdstmt->stmt)->expr);
27: edgewalk = &edgelist;
28: prevtx = expreval (((EXPRPTR) bdstmt->stmt)->expr, noadtree);
29: for (bdwalk = ((EXPRPTR) bdstmt->stmt)->next;
30: bdwalk;
31: bdwalk = bdwalk->next) {
32: curvtx = expreval (bdwalk->expr, noadtree);
33: if (((INTLPTR) bdwalk->expr)->oper == '^') {
34: bdwalk = bdwalk->next;
35: if (!bdwalk) {
36: fprintf (stderr, "ideal: arc point may not begin boundary specification\n");
37: return (linelist);
38: }
39: postvtx = expreval (bdwalk->expr, noadtree);
40: edgewalk->next = edgearc (
41: Re(prevtx),
42: Im(prevtx),
43: Re(curvtx),
44: Im(curvtx),
45: Re(postvtx),
46: Im(postvtx)
47: );
48: } else {
49: postvtx = curvtx;
50: edgewalk->next = edgeline (
51: Re(prevtx),
52: Im(prevtx),
53: Re(postvtx),
54: Im(postvtx)
55: );
56: }
57: prevtx = postvtx;
58: edgewalk = edgewalk->next;
59: }
60: edgewalk->next = edgelist.next;
61: lastbd->next = NULL;
62: opqpoly (
63: edgelist.next->next,
64: linelist,
65: &inlines,
66: &outlines,
67: &both
68: );
69: forfreeing = edgelist.next->next;
70: edgelist.next->next = NULL;
71: linefree (forfreeing);
72: } else {
73: fprintf(stderr, "ideal: no boundary list\n");
74: }
75: if (((MISCPTR) opqstmt->stmt)->info == INTERIOR) {
76: prevline->next = outlines;
77: linefree (inlines);
78: } else {
79: prevline->next = inlines;
80: linefree (outlines);
81: }
82: if (both) {
83: while (prevline->next)
84: prevline = prevline->next;
85: prevline->next = both;
86: }
87: linelist = lineclean (nuline.next);
88: bug_off;
89: return (linelist);
90: } /* opqact */
91:
92: void opqinsert (code, alpha, opqlist)
93: int code;
94: float alpha;
95: OPQPTR *opqlist;
96: {
97: OPQNODE head;
98: OPQPTR walk, prev, new;
99: walk = &head;
100: walk->alpha = -INFINITY;
101: walk->next = *opqlist;
102: prev = NULL;
103: while (walk->next && walk->next->alpha < alpha + EPSILON) {
104: prev = walk;
105: walk = walk->next;
106: }
107: if (walk->alpha < alpha - EPSILON) {
108: new = opqgen(code, alpha);
109: new->next = walk->next;
110: walk->next = new;
111: } else {
112: if (walk->code == EXT0 || walk->code == INFL0)
113: if (code == EXT1 || code == INFL1) {
114: walk->code = IGNORE;
115: }
116: else if (walk->code == EXT1 || walk->code == INFL1)
117: if (code == EXT0 || code == INFL0) {
118: walk->code = IGNORE;
119: }
120: else if (walk->code == SIMPLE && code != INHERIT)
121: walk->code = code;
122: }
123: *opqlist = head.next;
124: }
125:
126: LINEPTR lineclean (linelist)
127: LINEPTR linelist;
128: {
129: /* clean short lines from linelist */
130: LINEPTR prevline, linewalk;
131: LINENODE nuhead;
132: prevline = &nuhead;
133: prevline->next = linewalk = linelist;
134: while (linewalk) {
135: if ((linewalk->kind == LINE)
136: && (fabs(linewalk->x0 - linewalk->x1) < EPSILON)
137: && (fabs(linewalk->y0 - linewalk->y1) < EPSILON)) {
138: dprintf "Removing chopped line\n");
139: prevline->next = linewalk->next;
140: tryfree(linewalk);
141: linewalk = prevline->next;
142: } else {
143: prevline = linewalk;
144: linewalk = linewalk->next;
145: }
146: }
147: linelist = nuhead.next;
148: return (linelist);
149: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.