Index: topoly.c =================================================================== --- topoly.c (revision 32414) +++ topoly.c (revision 32415) @@ -169,15 +169,11 @@ return NULL; /* nothing found */ } -static int map_contour(pcb_data_t *data, vtp0_t *list, vti0_t *endlist, pcb_any_obj_t *start) +static int map_contour_with(pcb_data_t *data, vtp0_t *list, vti0_t *endlist, pcb_any_obj_t *start, pcb_dynf_t df) { long i; pcb_any_obj_t *n; - pcb_dynf_t df; - df = pcb_dynflag_alloc("topoly_map_contour"); - pcb_data_dynflag_clear(data, df); - /*rnd_trace("loop start: %d\n", start->ID);*/ vtp0_append(list, start); PCB_DFLAG_SET(&start->Flags, df); @@ -190,10 +186,22 @@ PCB_DFLAG_CLR(&start->Flags, df); /* allow finding the start object again for proper closing */ } - pcb_dynflag_free(df); return 0; } +static int map_contour(pcb_data_t *data, vtp0_t *list, vti0_t *endlist, pcb_any_obj_t *start) +{ + int res; + pcb_dynf_t df; + df = pcb_dynflag_alloc("topoly_map_contour"); + pcb_data_dynflag_clear(data, df); + + res = map_contour_with(data, list, endlist, start, df); + + pcb_dynflag_free(df); + return res; +} + static int contour2poly_cb(void *uctx, rnd_coord_t x, rnd_coord_t y) { pcb_poly_t *poly = uctx; @@ -245,7 +253,7 @@ return poly; } -pcb_poly_t *pcb_topoly_conn(pcb_board_t *pcb, pcb_any_obj_t *start, pcb_topoly_t how) +pcb_poly_t *pcb_topoly_conn_with(pcb_board_t *pcb, pcb_any_obj_t *start, pcb_topoly_t how, pcb_dynf_t df) { vtp0_t objs; vti0_t ends; @@ -259,7 +267,10 @@ vtp0_init(&objs); vti0_init(&ends); - res = map_contour(pcb->Data, &objs, &ends, start); + if (df == 0) + res = map_contour(pcb->Data, &objs, &ends, start); + else + res = map_contour_with(pcb->Data, &objs, &ends, start, df); if (res != 0) { rnd_message(RND_MSG_ERROR, "pcb_topoly_conn(): failed to find a closed loop of lines and arcs\n"); vtp0_uninit(&objs); @@ -274,6 +285,12 @@ return poly; } +pcb_poly_t *pcb_topoly_conn(pcb_board_t *pcb, pcb_any_obj_t *start, pcb_topoly_t how) +{ + return pcb_topoly_conn_with(pcb, start, how, 0); +} + + #define check(x, y, obj) \ do { \ double dist = (double)x*(double)x + (double)y*(double)y; \ Index: topoly.h =================================================================== --- topoly.h (revision 32414) +++ topoly.h (revision 32415) @@ -37,9 +37,12 @@ } pcb_topoly_t; /* Convert a loop of connected objects into a polygon (with no holes); the first - object is named in start. */ + object is named in start. The _with version uses a caller provided dynamic + flag that is not cleared within the call so multiple loops can be mapped. */ pcb_poly_t *pcb_topoly_conn(pcb_board_t *pcb, pcb_any_obj_t *start, pcb_topoly_t how); +pcb_poly_t *pcb_topoly_conn_with(pcb_board_t *pcb, pcb_any_obj_t *start, pcb_topoly_t how, pcb_dynf_t df); + /* Find the first line/arc on the outline layer from top-left */ pcb_any_obj_t *pcb_topoly_find_1st_outline(pcb_board_t *pcb);