From: ellson Date: Tue, 8 Apr 2008 18:58:13 +0000 (+0000) Subject: a fix for the extra space problem from bezier control points in bb X-Git-Tag: LAST_LIBGRAPH~32^2~4365 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b51aec9d6b5987ea28b517cf6da21b842e868f40;p=graphviz a fix for the extra space problem from bezier control points in bb code needs refactoring. same code is used in three places. --- diff --git a/lib/common/splines.c b/lib/common/splines.c index 4703e0a19..fe3491f68 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -319,9 +319,20 @@ clip_and_install(edge_t * fe, node_t * hn, point * ps, int pn, if (ps[end].x != ps[end + 3].x || ps[end].y != ps[end + 3].y) break; arrow_clip(fe, hn, ps, &start, &end, newspl, info); - for (i = start; i < end + 4; i++) { - point pt; + for (i = start; i < end + 4; ) { + point pt, pt1, pt2; pt = newspl->list[i - start] = ps[i]; + i++; + update_bb(g, pt); + if ( i >= end + 4) + break; + /* take the mid-point between the two control points in bb calculation */ + pt1 = newspl->list[i - start] = ps[i]; + i++; + pt2 = newspl->list[i - start] = ps[i]; + i++; + pt.x = ( pt1.x + pt2.x ) / 2; + pt.y = ( pt1.y + pt2.y ) / 2; update_bb(g, pt); } newspl->size = end - start + 4; diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index 1385c22ce..4c857b558 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -936,9 +936,20 @@ make_flat_adj_edges(path* P, edge_t** edges, int ind, int cnt, edge_t* e0, bz->eflag = auxbz->eflag; bz->ep = transform(auxbz->ep, del, 0); } - for (j = 0; j < auxbz->size; j++) { - point pt; + for (j = 0; j < auxbz->size; ) { + point pt, pt1, pt2; pt = bz->list[j] = transform(auxbz->list[j], del, GD_flip(g)); + j++; + update_bb(g, pt); + if ( j >= auxbz->size ) + break; + /* take the mid-point between the two control points in bb calculation */ + pt1 = bz->list[j] = transform(auxbz->list[j], del, GD_flip(g)); + j++; + pt2 = bz->list[j] = transform(auxbz->list[j], del, GD_flip(g)); + j++; + pt.x = ( pt1.x + pt2.x ) / 2; + pt.y = ( pt1.y + pt2.y ) / 2; update_bb(g, pt); } if (ED_label(e)) {