From e113aa7bf01757fa694be2d9a378366665ea8757 Mon Sep 17 00:00:00 2001 From: ellson Date: Tue, 8 Apr 2008 18:58:13 +0000 Subject: [PATCH] a fix for the extra space problem from bezier control points in bb code needs refactoring. same code is used in three places. --- lib/common/emit.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 785108703..5aed2660b 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1945,7 +1945,7 @@ static void init_job_viewport(GVJ_t * job, graph_t * g) Agnode_t *n; char *nodename = NULL; - assert((gvc->bb.LL.x == 0) && (gvc->bb.LL.y == 0)); +// assert((gvc->bb.LL.x == 0) && (gvc->bb.LL.y == 0)); P2PF(gvc->bb.UR, UR); job->bb.LL.x = -job->pad.x; /* job->bb is bb of graph and padding - graph units */ @@ -2617,15 +2617,26 @@ char **parse_style(char *s) static boxf bezier_bb(bezier bz) { int i; - point p; + point p, p1, p2; box bb; boxf bbf; assert(bz.size > 0); bb.LL = bb.UR = bz.list[0]; - for (i = 1; i < bz.size; i++) { + for (i = 1; i < bz.size;) { p=bz.list[i]; EXPANDBP(bb,p); + i++; + if ( i >= bz.size) + break; + /* take mid-point between two control points for bb calculation */ + p1=bz.list[i]; + i++; + p2=bz.list[i]; + i++; + p.x = ( p1.x + p2.x ) / 2; + p.y = ( p1.y + p2.y ) / 2; + EXPANDBP(bb,p); } B2BF(bb, bbf); return bbf; -- 2.40.0