Index: cdt.c =================================================================== --- cdt.c (revision 33929) +++ cdt.c (revision 33930) @@ -967,7 +967,43 @@ } } +static void fdump_triangle_anim(FILE *f, cdt_t *cdt, triangle_t *t, int first) +{ + static int last_c; + int i; + pos_t c; + c = triangle_center_pos(t); + fprintf(f, "text %f %f \"%ld\"\n", c.x, c.y, triangle_id(cdt, t)); + for (i = 0; i < 3; i++) { + edge_t *edge = t->e[i]; + if(last_c != edge->is_constrained) { + fprintf(f, "color %s\n", edge->is_constrained ? "red" : "black"); + fprintf(f, "thick %s\n", edge->is_constrained ? "2" : "1"); + last_c = edge->is_constrained; + } + fprintf(f, "line %f %f %f %f\n", (double)edge->endp[0]->pos.x, (double)edge->endp[0]->pos.y, (double)edge->endp[1]->pos.x, (double)edge->endp[1]->pos.y); + } +} + +void cdt_fdump_adj_triangles_anim(FILE *f, cdt_t *cdt, triangle_t *t) +{ + int i; + fprintf(f, "frame\n"); + fprintf(f, "scale 0.9\n"); + fprintf(f, "viewport %f %f - %f %f\n", (double)cdt->bbox_tl.x - 1.0, (double)cdt->bbox_tl.y - 1.0, (double)cdt->bbox_br.x + 1.0, (double)cdt->bbox_br.y + 1.0); + fprintf(f, "title \"%ld\"\n", triangle_id(cdt, t)); + + fdump_triangle_anim(f, cdt, t, 1); + for (i = 0; i < 3; i++) { + if (t->adj_t[i] != NULL) + fdump_triangle_anim(f, cdt, t->adj_t[i], 0); + } + + fprintf(f, "flush\n"); +} + + int cdt_check_delaunay(cdt_t *cdt, pointlist_node_t **point_violations, trianglelist_node_t **triangle_violations) { int delaunay = 1; Index: cdt.h =================================================================== --- cdt.h (revision 33929) +++ cdt.h (revision 33930) @@ -60,6 +60,7 @@ int cdt_check_delaunay(cdt_t *cdt, pointlist_node_t **point_violations, trianglelist_node_t **triangle_violations); void cdt_dump_animator(cdt_t *cdt, int show_circles, pointlist_node_t *point_violations, trianglelist_node_t *triangle_violations); void cdt_fdump_animator(FILE *f, cdt_t *cdt, int show_circles, pointlist_node_t *point_violations, trianglelist_node_t *triangle_violations); +void cdt_fdump_adj_triangles_anim(FILE *f, cdt_t *cdt, triangle_t *t); /* Dump a cdt script in the format that's suitable for the tester to include */ void cdt_fdump(FILE *f, cdt_t *cdt); Index: cdt_test.c =================================================================== --- cdt_test.c (revision 33929) +++ cdt_test.c (revision 33930) @@ -328,7 +328,37 @@ } } +static void cmd_dump_triangles(char *args, int anim) +{ + FILE *f; + char *end = strpbrk(args, " \t\r\n"); + long tid; + char fn[1024]; + if (end != NULL) + *end = '\0'; + + for (tid = 0; tid < cdt.triangles.used; tid++) { + sprintf(fn, "%s_%03ld", args, tid); + + f = fopen(fn, "w"); + if (f == NULL) { + fprintf(stderr, "dump_triangles: failed to open '%s' for write\n", args); + return; + } + + if (anim) { + cdt_fdump_adj_triangles_anim(f, &cdt, cdt.triangles.array[tid]); + } +/* + else + cdt_fdump(f, &cdt); +*/ + fclose(f); + } +} + + static void cmd_print_events(char *args) { switch(*args) { @@ -394,6 +424,7 @@ else if (strcmp(cmd, "raw_triangle") == 0) cmd_raw_triangle(args); else if (strcmp(cmd, "dump") == 0) cmd_dump(args, 0); else if (strcmp(cmd, "dump_anim") == 0) cmd_dump(args, 1); + else if (strcmp(cmd, "dump_triangles_anim") == 0) cmd_dump_triangles(args, 1); else if (strcmp(cmd, "print") == 0) cmd_print(args); else if (strcmp(cmd, "print_events") == 0) cmd_print_events(args); else fprintf(stderr, "syntax error: unknown command '%s'\n", cmd);