From e74f3329579fac8062618aceb4f57e1ab5663a22 Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Tue, 28 Jan 2014 14:28:06 -0500 Subject: [PATCH] Provide two entry points for "straight" line generation since dot works on different assumptions than other routing --- lib/common/render.h | 1 + lib/common/routespl.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/common/render.h b/lib/common/render.h index a468856c5..9515ded74 100644 --- a/lib/common/render.h +++ b/lib/common/render.h @@ -87,6 +87,7 @@ extern "C" { boolean left_inside); extern shape_desc *bind_shape(char *name, node_t *); extern void makeStraightEdge(graph_t * g, edge_t * e, int edgetype, splineInfo * info); + extern void makeStraightEdges(graph_t* g, edge_t** edges, int e_cnt, int et, splineInfo* sinfo); extern void clip_and_install(edge_t * fe, node_t * hn, pointf * ps, int pn, splineInfo * info); extern char* charsetToStr (int c); diff --git a/lib/common/routespl.c b/lib/common/routespl.c index 7e66c4381..a84eefa98 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -930,22 +930,52 @@ static void bend(pointf spl[4], pointf centroid) * * FIX: handle ports on boundary? */ +#define MAX_EDGE 20 void makeStraightEdge(graph_t * g, edge_t * e, int et, splineInfo* sinfo) +{ + edge_t *e0; + edge_t** edges; + edge_t* elist[MAX_EDGE]; + int i, e_cnt; + + e_cnt = 0; + e0 = e; + while ((e0 = ED_to_virt(e0))) e_cnt++; + + if (e_cnt <= MAX_EDGE) + edges = elist; + else + edges = N_NEW(e_cnt,edge_t*); + e0 = e; + for (i = 0; i < e_cnt; i++) { + edges[i] = e0; + e0 = ED_to_virt(e0); + } + makeStraightEdges (g, edges, e_cnt, et, sinfo); + if (e_cnt > MAX_EDGE) free (edges); + +} + +void +makeStraightEdges(graph_t * g, edge_t** edges, int e_cnt, int et, splineInfo* sinfo) { pointf dumb[4]; - node_t *n = agtail(e); - node_t *head = aghead(e); - int e_cnt = ED_count(e); + node_t *n; + node_t *head; int curved = (et == ET_CURVED); pointf perp; pointf del; edge_t *e0; + edge_t *e; int i, j, xstep, dx; double l_perp; pointf dumber[4]; pointf p, q; + e = edges[0]; + n = agtail(e); + head = aghead(e); p = dumb[1] = dumb[0] = add_pointf(ND_coord(n), ED_tail_port(e).p); q = dumb[2] = dumb[3] = add_pointf(ND_coord(head), ED_head_port(e).p); if ((e_cnt == 1) || Concentrate) { @@ -978,6 +1008,7 @@ makeStraightEdge(graph_t * g, edge_t * e, int et, splineInfo* sinfo) } for (i = 0; i < e_cnt; i++) { + e0 = edges[i]; if (aghead(e0) == head) { p = dumb[0]; q = dumb[3]; @@ -1007,7 +1038,6 @@ makeStraightEdge(graph_t * g, edge_t * e, int et, splineInfo* sinfo) clip_and_install(e0, aghead(e0), dumber, 4, sinfo); addEdgeLabels(g, e0, p, q); - e0 = ED_to_virt(e0); dumb[1].x += del.x; dumb[1].y += del.y; dumb[2].x += del.x; -- 2.40.0