int main(int argc, char *argv[]) { FILE* fwrite = fopen("topology","w+"); FILE* fdraw = fopen("draw_combine.dot","w+"); struct dirent *pDirEntry = NULL; DIR *pDir = NULL; if( (pDir = opendir("./")) == NULL ) { printf("opendir failed!\n"); return 1; } else { while( pDirEntry = readdir(pDir) ) { if ( strstr(pDirEntry->d_name, "out") && pDirEntry->d_name[0]=='o' && pDirEntry->d_name[1]=='u' && pDirEntry->d_name[2]=='t') { printf("输入文件:%s \n",pDirEntry->d_name); load_edge(pDirEntry->d_name); printf("------------------------------------\n"); } } closedir(pDir); } fprintf(fdraw, "digraph G {\n\t rankdir=LR;\n"); display_table(fwrite,fdraw); print_router(fdraw); fprintf(fdraw, "}"); fclose(fwrite); fclose(fdraw); cluster(); return 0; }
static void fz_paint_triangle(fz_pixmap *pix, float poly_in[3][MAXN], int n, const fz_irect *bbox) { float poly[MAXV][MAXN]; float temp[MAXV][MAXN]; float cx0 = bbox->x0; float cy0 = bbox->y0; float cx1 = bbox->x1; float cy1 = bbox->y1; int gel[MAXV][MAXN]; int ael[2][MAXN]; int del[2][MAXN]; int y, s0, s1, e0, e1; int top, bot, len; int i, k; len = clip_poly(poly_in, temp, 3, n, cx0, 0, 0); len = clip_poly(temp, poly, len, n, cx1, 0, 1); len = clip_poly(poly, temp, len, n, cy0, 1, 0); len = clip_poly(temp, poly, len, n, cy1, 1, 1); if (len < 3) return; for (i = 0; i < len; i++) { gel[i][0] = floorf(poly[i][0] + 0.5f) * 65536; /* trunc and fix */ gel[i][1] = floorf(poly[i][1] + 0.5f); /* y is not fixpoint */ for (k = 2; k < n; k++) gel[i][k] = poly[i][k] * 65536; /* fix with precision */ } top = bot = 0; for (i = 0; i < len; i++) { if (gel[i][1] < gel[top][1]) top = i; if (gel[i][1] > gel[bot][1]) bot = i; } if (gel[bot][1] - gel[top][1] == 0) return; y = gel[top][1]; if (find_next(gel, len, top, &s0, &e0, 1)) return; if (find_next(gel, len, top, &s1, &e1, -1)) return; load_edge(gel, s0, e0, ael[0], del[0], n); load_edge(gel, s1, e1, ael[1], del[1], n); while (1) { int x0 = ael[0][0] >> 16; int x1 = ael[1][0] >> 16; if (ael[0][0] < ael[1][0]) paint_scan(pix, y, x0, x1, ael[0]+2, ael[1]+2, n-2); else paint_scan(pix, y, x1, x0, ael[1]+2, ael[0]+2, n-2); step_edge(ael[0], del[0], n); step_edge(ael[1], del[1], n); y ++; if (y >= gel[e0][1]) { if (find_next(gel, len, e0, &s0, &e0, 1)) return; load_edge(gel, s0, e0, ael[0], del[0], n); } if (y >= gel[e1][1]) { if (find_next(gel, len, e1, &s1, &e1, -1)) return; load_edge(gel, s1, e1, ael[1], del[1], n); } } }