Index: trunk/src/plugins/rt_topo/crbs.h =================================================================== --- trunk/src/plugins/rt_topo/crbs.h (revision 1364) +++ trunk/src/plugins/rt_topo/crbs.h (revision 1365) @@ -24,7 +24,8 @@ typedef struct { point_t *cstart, *cend; - rt_topo_2net_t *tn; + rt_topo_2net_t *tn; /* for nets we are routing; NULL for fixed objects */ + rtrnd_net_t *net; grbs_2net_t *gtn; unsigned int ripped_up; /* how many times this net got ripped up */ unsigned coll:1; /* collided with current routing effort */ Index: trunk/src/plugins/rt_topo/crbs_cdt.c =================================================================== --- trunk/src/plugins/rt_topo/crbs_cdt.c (revision 1364) +++ trunk/src/plugins/rt_topo/crbs_cdt.c (revision 1365) @@ -31,13 +31,30 @@ #include "geo.h" #include "gengeo2d/cline.h" -static void long_constrained_edge(cdt_t *cdt, point_t *p1, point_t *p2, double maxlen2, double maxlen, void *udata) +#warning TODO: use libualloc for ctn +#define ADD_C_EDGE(p1, p2) \ +do { \ + e = cdt_insert_constrained_edge(cdt, p1, p2); \ + e->data = obj; \ + if (add_grbs) { \ + crbs_point_t *cp1 = p1->data, *cp2 = p2->data; \ + grbs_2net_t *tn = grbs_2net_new(&crbs->grbs, cop, clr); \ + crbs_2net_t *ctn = calloc(sizeof(crbs_2net_t), 1); \ + tn->user_data = ctn; \ + ctn->tn = NULL; \ + ctn->net = obj->hdr.net; \ + grbs_line_realize(&crbs->grbs, tn, cp1->gpt, cp2->gpt); \ + } \ +} while(0) \ + + +static void long_constrained_edge(crbs_t *crbs, point_t *p1, point_t *p2, double maxlen2, double maxlen, double cop, double clr, int add_grbs, rtrnd_any_obj_t *obj) { edge_t *e; double dx = p2->pos.x - p1->pos.x, dy = p2->pos.y - p1->pos.y; double len2 = dx*dx + dy*dy; + cdt_t *cdt = &crbs->cdt; - if (len2 > maxlen2) { double d, len, x, y; long spn, n; @@ -55,22 +72,18 @@ for(n = 0; n < spn; n++) { x += dx; y += dy; - p = cdt_insert_point(cdt, x, y); + p = crbs_make_point(crbs, x, y, cop, clr, NULL); if (p == NULL) continue; - e = cdt_insert_constrained_edge(cdt, lp, p); - e->data = udata; + ADD_C_EDGE(lp, p); lp = p; } /* end */ - e = cdt_insert_constrained_edge(cdt, lp, p2); - e->data = udata; + ADD_C_EDGE(lp, p2); } - else { - e = cdt_insert_constrained_edge(cdt, p1, p2); - e->data = udata; - } + else + ADD_C_EDGE(p1, p2); } void rt_topo_crbs_cdt_init(rtrnd_t *ctx, rtrnd_layer_t *ly, crbs_t *crbs) @@ -101,7 +114,7 @@ p1 = crbs_make_point(crbs, obj->line.cline.p1.x, obj->line.cline.p1.y, cop, clr, NULL); if ((obj->line.cline.p1.x != obj->line.cline.p2.x) || (obj->line.cline.p1.y != obj->line.cline.p2.y)) { p2 = crbs_make_point(crbs, obj->line.cline.p2.x, obj->line.cline.p2.y, cop, clr, NULL); - long_constrained_edge(&crbs->cdt, p1, p2, maxl2, maxlen, obj); + long_constrained_edge(crbs, p1, p2, maxl2, maxlen, cop, clr, 1, obj); } break; case RTRND_POLY: @@ -110,7 +123,7 @@ p2 = crbs_make_point(crbs, v->x, v->y, 0, clr, NULL); for(v = gdl_first(&obj->poly.rtpoly.lst); v != NULL; v = gdl_next(&obj->poly.rtpoly.lst, v)) { p1 = crbs_make_point(crbs, v->x, v->y, 0, clr, NULL); - long_constrained_edge(&crbs->cdt, p1, p2, maxl2, maxlen, obj); + long_constrained_edge(crbs, p1, p2, maxl2, maxlen, 0, clr, 1, obj); p2 = p1; } break; Index: trunk/src/plugins/rt_topo/crbs_route.c =================================================================== --- trunk/src/plugins/rt_topo/crbs_route.c (revision 1364) +++ trunk/src/plugins/rt_topo/crbs_route.c (revision 1365) @@ -646,10 +646,12 @@ /* convert input twonets to crbs twonets, making sure they have endpoints in the cdt */ crbs.max_ripup = 0; for(t = gdl_first(tnl); t != NULL; t = t->link.next) { +#warning TODO: use libualloc crbs_2net_t *ct = calloc(sizeof(crbs_2net_t), 1); ct->cstart = cdt_insert_point(&crbs.cdt, t->x[0], t->y[0]); ct->cend = cdt_insert_point(&crbs.cdt, t->x[1], t->y[1]); ct->tn = t; + ct->net = t->net; gdl_append(&crbs.twonets, ct, link); crbs.max_ripup++; }