Index: cdt.c =================================================================== --- cdt.c (revision 33794) +++ cdt.c (revision 33795) @@ -907,7 +907,39 @@ cdt_fdump_animator(stdout, cdt, show_circles, point_violations, triangle_violations); } +static long point_id(cdt_t *cdt, point_t *p) +{ + long pid; + for(pid = 0; pid < cdt->points.used; pid++) + if (p == cdt->points.array[pid]) + return pid; + return -1; +} + +void cdt_fdump(FILE *f, cdt_t *cdt) +{ + long n; + + fprintf(f, "raw_init\n"); + + for(n = 0; n < cdt->points.used; n++) { + point_t *p = cdt->points.array[n]; + fprintf(f, "raw_point %f %f\n", (double)p->pos.x, (double)p->pos.y); + } + + for(n = 0; n < cdt->edges.used; n++) { + edge_t *e = cdt->edges.array[n]; + fprintf(f, "raw_edge P%ld P%ld %d\n", point_id(cdt, e->endp[0]), point_id(cdt, e->endp[1]), e->is_constrained); + } + + for(n = 0; n < cdt->triangles.used; n++) { + triangle_t *t = cdt->triangles.array[n]; + fprintf(f, "raw_triangle P%ld P%ld P%ld\n", point_id(cdt, t->p[0]), point_id(cdt, t->p[1]), point_id(cdt, t->p[2])); + } +} + + 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 33794) +++ cdt.h (revision 33795) @@ -61,7 +61,10 @@ 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); +/* Dump a cdt script in the format that's suitable for the tester to include */ +void cdt_fdump(FILE *f, cdt_t *cdt); + edge_t *get_edge_from_points(point_t *p1, point_t *p2); #define ORIENT_CCW(a, b, c) (orientation(a, b, c) < 0) Index: cdt_test.c =================================================================== --- cdt_test.c (revision 33794) +++ cdt_test.c (revision 33795) @@ -240,7 +240,7 @@ } -static void cmd_dump_anim(char *args) +static void cmd_dump(char *args, int anim) { FILE *f; char *end = strpbrk(args, " \t\r\n"); @@ -254,7 +254,11 @@ return; } - cdt_fdump_animator(f, &cdt, 0, NULL, NULL); + if (anim) + cdt_fdump_animator(f, &cdt, 0, NULL, NULL); + else + cdt_fdump(f, &cdt); + fclose(f); } @@ -349,7 +353,8 @@ else if (strcmp(cmd, "del_cedge") == 0) cmd_del_cedge(args); else if (strcmp(cmd, "raw_edge") == 0) cmd_raw_edge(args); else if (strcmp(cmd, "raw_triangle") == 0) cmd_raw_triangle(args); - else if (strcmp(cmd, "dump_anim") == 0) cmd_dump_anim(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, "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);