]> granicus.if.org Git - graphviz/commitdiff
change GD_bb to floatingpoint
authorellson <devnull@localhost>
Sat, 16 Aug 2008 10:52:00 +0000 (10:52 +0000)
committerellson <devnull@localhost>
Sat, 16 Aug 2008 10:52:00 +0000 (10:52 +0000)
17 files changed:
cmd/tools/gvpack.c
lib/common/emit.c
lib/common/output.c
lib/common/postproc.c
lib/common/shapes.c
lib/common/splines.c
lib/common/types.h
lib/common/utils.c
lib/dotgen/compound.c
lib/dotgen/dotsplines.c
lib/dotgen/position.c
lib/fdpgen/clusteredges.c
lib/fdpgen/layout.c
lib/neatogen/neatoinit.c
lib/neatogen/neatosplines.c
lib/pack/pack.c
lib/patchwork/patchwork.c

index a6f2943ba8f64fd6409c92f3a8331f6482b7f6d2..aca6a2e099c827b3b55e22dedfece1215d1cafc2 100644 (file)
@@ -712,9 +712,9 @@ static Agraph_t **readGraphs(int *cp, GVC_t* gvc)
  * Compute the bounding box containing the graphs.
  * We can just use the bounding boxes of the graphs.
  */
-box compBB(Agraph_t ** gs, int cnt)
+boxf compBB(Agraph_t ** gs, int cnt)
 {
-    box bb, bb2;
+    boxf bb, bb2;
     int i;
 
     bb = GD_bb(gs[0]);
@@ -767,7 +767,6 @@ int main(int argc, char *argv[])
     Agraph_t *g;
     int cnt;
     pack_info pinfo;
-    box bb;
     GVC_t * gvc;
 
     init(argc, argv);
@@ -794,8 +793,7 @@ int main(int argc, char *argv[])
 
     /* compute new top-level bb and set */
     if (DOPACK) {
-       bb = compBB(gs, cnt);
-       GD_bb(g) = bb;
+       GD_bb(g) = compBB(gs, cnt);
        dotneato_postprocess(g);
        attach_attrs(g);
     }
index 599f139408bf1f35fa5d36774a92115249cbecc8..6e753741e2c72d6885f26e8cfd2bc64d69b8957e 100644 (file)
@@ -1985,7 +1985,7 @@ static void init_gvc(GVC_t * gvc, graph_t * g)
             gvc->pagedir = p;
 
     /* bounding box */
-    B2BF(GD_bb(g),gvc->bb);
+    gvc->bb = GD_bb(g);
 
     /* clusters have peripheries */
     G_peripheries = agfindattr(g, "peripheries");
@@ -2500,7 +2500,6 @@ static void emit_end_cluster(GVJ_t * job, Agraph_t * g)
 void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
 {
     int c, istyle, filled;
-    boxf BF;
     pointf AF[4];
     char *color, *fillcolor, *pencolor, **style, *s;
     graph_t *sg;
@@ -2515,7 +2514,6 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
        sg = GD_clust(g)[c];
        if (clust_in_layer(job, sg) == FALSE)
            continue;
-       B2BF(GD_bb(sg), BF);
        /* when mapping, detect events on clusters after sub_clusters */
        if (flags & EMIT_CLUSTERS_LAST)
            emit_clusters(job, sg, flags);
@@ -2525,7 +2523,7 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
        setColorScheme (agget (sg, "colorscheme"));
        gvrender_begin_context(job);
        if (doAnchor && !(flags & EMIT_CLUSTERS_LAST)) {
-           emit_map_rect(job, BF);
+           emit_map_rect(job, GD_bb(sg));
            gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target);
        }
        filled = FALSE;
@@ -2579,8 +2577,8 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
 
        if (istyle & ROUNDED) {
            if (late_int(sg, G_peripheries, 1, 0) || filled) {
-               AF[0] = BF.LL;
-               AF[2] = BF.UR;
+               AF[0] = GD_bb(sg).LL;
+               AF[2] = GD_bb(sg).UR;
                AF[1].x = AF[2].x;
                AF[1].y = AF[0].y;
                AF[3].x = AF[0].x;
@@ -2592,11 +2590,11 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
            gvrender_set_pencolor(job, pencolor);
            gvrender_set_fillcolor(job, fillcolor);
            if (late_int(sg, G_peripheries, 1, 0))
-               gvrender_box(job, BF, filled);
+               gvrender_box(job, GD_bb(sg), filled);
            else if (filled) { 
                if (fillcolor && fillcolor != pencolor)
                    gvrender_set_pencolor(job, fillcolor);
-               gvrender_box(job, BF, filled);
+               gvrender_box(job, GD_bb(sg), filled);
            }
        }
        if ((lab = GD_label(sg)))
@@ -2604,7 +2602,7 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
 
        if (doAnchor) {
            if (flags & EMIT_CLUSTERS_LAST) {
-               emit_map_rect(job, BF);
+               emit_map_rect(job, GD_bb(sg));
                gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target);
            }
            gvrender_end_anchor(job);
index 85027142de0da97b058369df026ee39b0d80f768..a922bb1b485d17a01e7551ac2c144468727269a3 100644 (file)
@@ -42,7 +42,7 @@ static void printptf(FILE * f, pointf pt)
 static void setYInvert(graph_t * g)
 {
     if (Y_invert) {
-       Y_off = GD_bb(g).UR.y + GD_bb(g).LL.y;
+       Y_off = ROUND(GD_bb(g).UR.y + GD_bb(g).LL.y);
        YF_off = PS2INCH(Y_off);
     }
 }
@@ -73,7 +73,7 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend)
     node_t *n;
     edge_t *e;
     bezier bz;
-    point pt;
+    pointf pt;
     char *lbl;
 
 //    setup_graph(job, g);
@@ -158,8 +158,8 @@ static void rec_attach_bb(graph_t * g)
     char buf[BUFSIZ];
     pointf pt;
 
-    sprintf(buf, "%d,%d,%d,%d", GD_bb(g).LL.x, YDIR(GD_bb(g).LL.y),
-           GD_bb(g).UR.x, YDIR(GD_bb(g).UR.y));
+    sprintf(buf, "%.3g,%.3g,%.3g,%.3g", GD_bb(g).LL.x, YFDIR(GD_bb(g).LL.y),
+           GD_bb(g).UR.x, YFDIR(GD_bb(g).UR.y));
     agset(g, "bb", buf);
     if (GD_label(g) && GD_label(g)->text[0]) {
        pt = GD_label(g)->pos;
index 5a63bc0fe8c1f667712042c09f9450bb689f5f50..f53d8861e8caa454fa345b7143f24a3f2bf87db1 100644 (file)
 
 static int Rankdir;
 static boolean Flip;
-static point Offset;
+static pointf Offset;
 
 static void place_flip_graph_label(graph_t * g);
 
 #define M1 \
 "/pathbox {\n\
-    /Y exch %d sub def\n\
-    /X exch %d sub def\n\
-    /y exch %d sub def\n\
-    /x exch %d sub def\n\
+    /Y exch %.3g sub def\n\
+    /X exch %.3g sub def\n\
+    /y exch %.3g sub def\n\
+    /x exch %.3g sub def\n\
     newpath x y moveto\n\
     X y lineto\n\
     X Y lineto\n\
     x Y lineto\n\
     closepath stroke\n \
 } def\n\
-/dbgstart { gsave %d %d translate } def\n\
+/dbgstart { gsave %.3g %.3g translate } def\n\
 /arrowlength 10 def\n\
 /arrowwidth arrowlength 2 div def\n\
 /arrowhead {\n\
@@ -68,12 +68,13 @@ static void place_flip_graph_label(graph_t * g);
     X Y moveto\n\
     x y makearrow\n\
 } def\n"
+
 #define M2 \
 "/pathbox {\n\
-    /X exch neg %d sub def\n\
-    /Y exch %d sub def\n\
-    /x exch neg %d sub def\n\
-    /y exch %d sub def\n\
+    /X exch neg %.3g sub def\n\
+    /Y exch %.3g sub def\n\
+    /x exch neg %.3g sub def\n\
+    /y exch %.3g sub def\n\
     newpath x y moveto\n\
     X y lineto\n\
     X Y lineto\n\
@@ -138,15 +139,15 @@ static void map_edge(edge_t * e)
 void translate_bb(graph_t * g, int rankdir)
 {
     int c;
-    box bb, new_bb;
+    boxf bb, new_bb;
 
     bb = GD_bb(g);
     if (rankdir == RANKDIR_LR || rankdir == RANKDIR_BT) {
-       new_bb.LL = map_point(pointof(bb.LL.x, bb.UR.y));
-       new_bb.UR = map_point(pointof(bb.UR.x, bb.LL.y));
+       new_bb.LL = map_pointf(pointfof(bb.LL.x, bb.UR.y));
+       new_bb.UR = map_pointf(pointfof(bb.UR.x, bb.LL.y));
     } else {
-       new_bb.LL = map_point(pointof(bb.LL.x, bb.LL.y));
-       new_bb.UR = map_point(pointof(bb.UR.x, bb.UR.y));
+       new_bb.LL = map_pointf(pointfof(bb.LL.x, bb.LL.y));
+       new_bb.UR = map_pointf(pointfof(bb.UR.x, bb.UR.y));
     }
     GD_bb(g) = new_bb;
     if (GD_label(g)) {
@@ -209,9 +210,9 @@ static void translate_drawing(graph_t * g)
  * flipped drawing has been transposed, so we don't have
  * to worry about switching x and y.
  */
-static void place_root_label(graph_t * g, point d)
+static void place_root_label(graph_t * g, pointf d)
 {
-    point p;
+    pointf p;
 
     if (GD_label_pos(g) & LABEL_AT_RIGHT) {
        p.x = GD_bb(g).UR.x - d.x / 2;
@@ -227,7 +228,7 @@ static void place_root_label(graph_t * g, point d)
        p.y = GD_bb(g).LL.y + d.y / 2;
     }
 
-    P2PF(p, GD_label(g)->pos);
+    GD_label(g)->pos = p;
     GD_label(g)->set = TRUE;
 }
 
@@ -240,9 +241,8 @@ static void place_root_label(graph_t * g, point d)
  */
 void dotneato_postprocess(Agraph_t * g)
 {
-    int diff;
-    pointf dimen;
-    point d = { 0, 0 };
+    double diff;
+    pointf dimen = {0., 0.};
 
     Rankdir = GD_rankdir(g);
     Flip = GD_flip(g);
@@ -254,36 +254,35 @@ void dotneato_postprocess(Agraph_t * g)
     if (GD_label(g) && !GD_label(g)->set) {
        dimen = GD_label(g)->dimen;
        PAD(dimen);
-       PF2P(dimen, d);
        if (Flip) {
            if (GD_label_pos(g) & LABEL_AT_TOP) {
-               GD_bb(g).UR.x += d.y;
+               GD_bb(g).UR.x += dimen.y;
            } else {
-               GD_bb(g).LL.x -= d.y;
+               GD_bb(g).LL.x -= dimen.y;
            }
 
-           if (d.x > GD_bb(g).UR.y - GD_bb(g).LL.y) {
-               diff = d.x - (GD_bb(g).UR.y - GD_bb(g).LL.y);
-               diff = diff / 2;
+           if (dimen.x > (GD_bb(g).UR.y - GD_bb(g).LL.y)) {
+               diff = dimen.x - (GD_bb(g).UR.y - GD_bb(g).LL.y);
+               diff = diff / 2.;
                GD_bb(g).LL.y -= diff;
                GD_bb(g).UR.y += diff;
            }
        } else {
            if (GD_label_pos(g) & LABEL_AT_TOP) {
                if (Rankdir == RANKDIR_TB)
-                   GD_bb(g).UR.y += d.y;
+                   GD_bb(g).UR.y += dimen.y;
                else
-                   GD_bb(g).LL.y -= d.y;
+                   GD_bb(g).LL.y -= dimen.y;
            } else {
                if (Rankdir == RANKDIR_TB)
-                   GD_bb(g).LL.y -= d.y;
+                   GD_bb(g).LL.y -= dimen.y;
                else
-                   GD_bb(g).UR.y += d.y;
+                   GD_bb(g).UR.y += dimen.y;
            }
 
-           if (d.x > GD_bb(g).UR.x - GD_bb(g).LL.x) {
-               diff = d.x - (GD_bb(g).UR.x - GD_bb(g).LL.x);
-               diff = diff / 2;
+           if (dimen.x > (GD_bb(g).UR.x - GD_bb(g).LL.x)) {
+               diff = dimen.x - (GD_bb(g).UR.x - GD_bb(g).LL.x);
+               diff = diff / 2.;
                GD_bb(g).LL.x -= diff;
                GD_bb(g).UR.x += diff;
            }
@@ -294,18 +293,18 @@ void dotneato_postprocess(Agraph_t * g)
        Offset = GD_bb(g).LL;
        break;
     case RANKDIR_LR:
-       Offset = pointof(-GD_bb(g).UR.y, GD_bb(g).LL.x);
+       Offset = pointfof(-GD_bb(g).UR.y, GD_bb(g).LL.x);
        break;
     case RANKDIR_BT:
-       Offset = pointof(GD_bb(g).LL.x, -GD_bb(g).UR.y);
+       Offset = pointfof(GD_bb(g).LL.x, -GD_bb(g).UR.y);
        break;
     case RANKDIR_RL:
-       Offset = pointof(GD_bb(g).LL.y, GD_bb(g).LL.x);
+       Offset = pointfof(GD_bb(g).LL.y, GD_bb(g).LL.x);
        break;
     }
     translate_drawing(g);
     if (GD_label(g) && !GD_label(g)->set)
-       place_root_label(g, d);
+       place_root_label(g, dimen);
 
     if (Show_boxes) {
        char buf[BUFSIZ];
@@ -348,58 +347,26 @@ void osize_label(textlabel_t * label, int *b, int *t, int *l, int *r)
 static void place_flip_graph_label(graph_t * g)
 {
     int c;
-    point p, d;
-#ifdef OLD
-    int maxx, minx;
-    int maxy, miny;
-    pointf dimen;
-#endif
+    pointf p, d;
 
     if ((g != g->root) && (GD_label(g)) && !GD_label(g)->set) {
 
        if (GD_label_pos(g) & LABEL_AT_TOP) {
-           d = GD_border(g)[RIGHT_IX];
+           P2PF(GD_border(g)[RIGHT_IX], d);
            p.x = GD_bb(g).UR.x - d.x / 2;
-#ifdef OLD
-           maxx = GD_bb(g).UR.x + d.y;
-           GD_bb(g).UR.x = maxx;
-           if (GD_bb(g->root).UR.x < maxx)
-               GD_bb(g->root).UR.x = maxx;
-#endif
        } else {
-           d = GD_border(g)[LEFT_IX];
+           P2PF(GD_border(g)[LEFT_IX], d);
            p.x = GD_bb(g).LL.x + d.x / 2;
-#ifdef OLD
-           minx = GD_bb(g).LL.x - d.y;
-           GD_bb(g).LL.x = minx;
-           if (GD_bb(g->root).LL.x > minx)
-               GD_bb(g->root).LL.x = minx;
-#endif
        }
 
        if (GD_label_pos(g) & LABEL_AT_RIGHT) {
            p.y = GD_bb(g).LL.y + d.y / 2;
-#ifdef OLD
-           maxy = p.y + d.x / 2;
-           if (GD_bb(g->root).UR.y < maxy)
-               GD_bb(g->root).UR.y = maxy;
-#endif
        } else if (GD_label_pos(g) & LABEL_AT_LEFT) {
            p.y = GD_bb(g).UR.y - d.y / 2;
-#ifdef OLD
-           miny = p.y - d.x / 2;
-           if (GD_bb(g->root).LL.y > miny)
-               GD_bb(g->root).LL.y = miny;
-#endif
        } else {
            p.y = (GD_bb(g).LL.y + GD_bb(g).UR.y) / 2;
-#ifdef OLD
-           maxy = p.y + d.x / 2;
-           miny = p.y - d.x / 2;
-#endif
        }
-
-       P2PF(p, GD_label(g)->pos);
+       GD_label(g)->pos = p;
        GD_label(g)->set = TRUE;
     }
 
@@ -416,54 +383,25 @@ static void place_flip_graph_label(graph_t * g)
 void place_graph_label(graph_t * g)
 {
     int c;
-#ifdef OLD
-    int minx, maxx;
-#endif
-    point p, d;
+    pointf p, d;
 
     if ((g != g->root) && (GD_label(g)) && !GD_label(g)->set) {
        if (GD_label_pos(g) & LABEL_AT_TOP) {
-           d = GD_border(g)[TOP_IX];
+           P2PF(GD_border(g)[TOP_IX], d);
            p.y = GD_bb(g).UR.y - d.y / 2;
        } else {
-           d = GD_border(g)[BOTTOM_IX];
+           P2PF(GD_border(g)[BOTTOM_IX], d);
            p.y = GD_bb(g).LL.y + d.y / 2;
        }
 
        if (GD_label_pos(g) & LABEL_AT_RIGHT) {
            p.x = GD_bb(g).UR.x - d.x / 2;
-#ifdef OLD
-           minx = p.x - d.x / 2;
-           if (GD_bb(g).LL.x > minx)
-               GD_bb(g).LL.x = minx;
-           if (GD_bb(g->root).LL.x > minx)
-               GD_bb(g->root).LL.x = minx;
-#endif
        } else if (GD_label_pos(g) & LABEL_AT_LEFT) {
            p.x = GD_bb(g).LL.x + d.x / 2;
-#ifdef OLD
-           maxx = p.x + d.x / 2;
-           if (GD_bb(g).UR.x < maxx)
-               GD_bb(g).UR.x = maxx;
-           if (GD_bb(g->root).UR.x < maxx)
-               GD_bb(g->root).UR.x = maxx;
-#endif
        } else {
            p.x = (GD_bb(g).LL.x + GD_bb(g).UR.x) / 2;
-#ifdef OLD
-           maxx = p.x + d.x / 2;
-           minx = p.x - d.x / 2;
-           if (GD_bb(g).UR.x < maxx)
-               GD_bb(g).UR.x = maxx;
-           if (GD_bb(g).LL.x > minx)
-               GD_bb(g).LL.x = minx;
-           if (GD_bb(g->root).UR.x < maxx)
-               GD_bb(g->root).UR.x = maxx;
-           if (GD_bb(g->root).LL.x > minx)
-               GD_bb(g->root).LL.x = minx;
-#endif
        }
-       P2PF(p, GD_label(g)->pos);
+       GD_label(g)->pos = p;
        GD_label(g)->set = TRUE;
     }
 
index f66fae908abadf80c9655986520f2d8a899f5f0d..05d427e7d967336fcb3b9e483da69300628d4464 100644 (file)
@@ -761,8 +761,7 @@ static void poly_init(node_t * n)
     dimen = ND_label(n)->dimen;
 
     /* minimal whitespace around label */
-// FIXME - is this an FP safe test?
-    if ((dimen.x > 0.0) || (dimen.y > 0.0)) {
+    if (ROUND(abs(dimen.x)) || ROUND(abs(dimen.y))) {
        /* padding */
        if ((p = agget(n, "margin"))) {
            i = sscanf(p, "%lf,%lf", &marginx, &marginy);
index d39118e2fd4ae967fc162e4db4803fac5d5cf3a6..bc30f0157a7567caae094872647fd07779cc6fa4 100644 (file)
@@ -240,7 +240,7 @@ clip_and_install(edge_t * fe, node_t * hn, point * ps, int pn,
     int start, end, i, clipTail, clipHead;
     graph_t *g;
     edge_t *orig;
-    boxf *tbox, *hbox, bb;
+    boxf *tbox, *hbox;
     inside_t inside_context;
 
     tn = fe->tail;
@@ -302,7 +302,6 @@ 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);
-    B2BF(GD_bb(g), bb);
     for (i = start; i < end + 4; ) {
        pointf cp[4];
        newspl->list[i - start] = ps[i];
@@ -317,9 +316,8 @@ clip_and_install(edge_t * fe, node_t * hn, point * ps, int pn,
        P2PF(ps[i], cp[2]);
        i++;
        P2PF(ps[i], cp[3]);
-       update_bb_bz(&bb, cp);
+       update_bb_bz(&GD_bb(g), cp);
     }
-    BF2B(bb, GD_bb(g));
     newspl->size = end - start + 4;
 }
 
index d2d43b069592ac57b4b26fd716bc9026008d7202..db634716265971b4f35716b2d7f9238f57ebd6d9 100644 (file)
@@ -331,7 +331,7 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind;
        /* to generate code */
        layout_t *drawing;
        textlabel_t *label;     /* if the cluster has a title */
-       box bb;                 /* bounding box */
+       boxf bb;                        /* bounding box */
        point border[4];        /* sizes of margins for graph labels */
        unsigned char gui_state; /* Graph state for GUI ops */
        unsigned char has_labels;
index a158a550e6820906bed12011b201753ea3171715..46b39d9cfc034049f5e0d0b7223e52445cb48492 100644 (file)
@@ -842,12 +842,7 @@ static boxf addLabelBB(boxf bb, textlabel_t * lp, boolean flipxy)
  */
 void updateBB(graph_t * g, textlabel_t * lp)
 {
-    boxf BF;
-    box B = GD_bb(g);
-
-    B2BF(B,BF);
-    BF = addLabelBB(BF, lp, GD_flip(g));
-    BF2B(BF, GD_bb(g));
+    GD_bb(g) = addLabelBB(GD_bb(g), lp, GD_flip(g));
 }
 
 /* compute_bb:
@@ -859,22 +854,22 @@ void compute_bb(graph_t * g)
 {
     node_t *n;
     edge_t *e;
-    box b, bb;
+    boxf b, bb;
     boxf BF;
-#ifdef SPLINESF
-    pointf ptf;
+    pointf ptf, s2;
+#ifndef SPLINESF
+    point pt;
 #endif
-    point pt, s2;
     int i, j;
 
-    bb.LL = pointof(INT_MAX, INT_MAX);
-    bb.UR = pointof(-INT_MAX, -INT_MAX);
+    bb.LL = pointfof(INT_MAX, INT_MAX);
+    bb.UR = pointfof(-INT_MAX, -INT_MAX);
     for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
-       pt = coord(n);
-       s2.x = ND_xsize(n) / 2 + 1;
-       s2.y = ND_ysize(n) / 2 + 1;
-       b.LL = sub_points(pt, s2);
-       b.UR = add_points(pt, s2);
+       P2PF(coord(n), ptf);
+       s2.x = ND_xsize(n) / 2. + 1;
+       s2.y = ND_ysize(n) / 2. + 1;
+       b.LL = sub_pointfs(ptf, s2);
+       b.UR = add_pointfs(ptf, s2);
 
        EXPANDBB(bb,b);
        for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
@@ -884,23 +879,22 @@ void compute_bb(graph_t * g)
                for (j = 0; j < ED_spl(e)->list[i].size; j++) {
 #ifdef SPLINESF
                    ptf = ED_spl(e)->list[i].list[j];
-                   PF2P(ptf, pt);
 #else
                    pt = ED_spl(e)->list[i].list[j];
+                   P2PF(pt, ptf);
 #endif
-                   EXPANDBP(bb,pt);
+                   EXPANDBP(bb,ptf);
                }
            }
            if (ED_label(e) && ED_label(e)->set) {
-               B2BF(bb,BF);
-               BF = addLabelBB(BF, ED_label(e), GD_flip(g));
-               BF2B(BF,bb);
+               bb = addLabelBB(bb, ED_label(e), GD_flip(g));
            }
        }
     }
 
     for (i = 1; i <= GD_n_cluster(g); i++) {
-       EXPANDBB(bb,GD_clust(g)[i]->u.bb);
+       B2BF(GD_clust(g)[i]->u.bb, BF);
+       EXPANDBB(bb,BF);
     }
 
     GD_bb(g) = bb;
index 5b844f9eaf36103c223253454d3ede379d78bdf3..e4a5dc6ba3176d7bdeb04b96c3cafa7aa57d40ff 100644 (file)
@@ -20,6 +20,8 @@
 
 #include       "dot.h"
 
+#define P2PF(p, pf) (pf.x = p.x, pf.y = p.y)
+#define PF2P(pf, p) (p.x = ROUND (pf.x), p.y = ROUND (pf.y))
 
 /* midPt:
  * Return midpoint between two given points.
@@ -46,16 +48,18 @@ static char *p2s(point p, char *buf)
  * the box bp. Assume cp is outside the box, and pp is
  * on or in the box. 
  */
-static point boxIntersect(point pp, point cp, box * bp)
+static point boxIntersect(point pp, point cp, boxf * bp)
 {
     point ipp;
     double ppx = pp.x;
     double ppy = pp.y;
     double cpx = cp.x;
     double cpy = cp.y;
-    point ll = bp->LL;
-    point ur = bp->UR;
+    point ll;
+    point ur;
 
+    PF2P(bp->LL, ll);
+    PF2P(bp->UR, ur);
     if (cp.x < ll.x) {
        ipp.x = ll.x;
        ipp.y = pp.y + (int) ((ipp.x - ppx) * (ppy - cpy) / (ppx - cpx));
@@ -97,10 +101,10 @@ static point boxIntersect(point pp, point cp, box * bp)
 /* inBox:
  * Returns true if p is on or in box bb
  */
-static int inBox(point p, box * bb)
+static int inBox(point p, boxf * bb)
 {
-    return ((p.x >= bb->LL.x) && (p.x <= bb->UR.x) &&
-           (p.y >= bb->LL.y) && (p.y <= bb->UR.y));
+    return (((double)p.x >= bb->LL.x) && ((double)p.x <= bb->UR.x) &&
+           ((double)p.y >= bb->LL.y) && ((double)p.y <= bb->UR.y));
 }
 
 /* getCluster:
@@ -187,7 +191,7 @@ static int countHorzCross(pointf * pts, int ycoord)
  */
 static double
 findVertical(pointf * pts, double tmin, double tmax,
-            int xcoord, int ymin, int ymax)
+            double xcoord, double ymin, double ymax)
 {
     pointf Left[4];
     pointf Right[4];
@@ -198,7 +202,7 @@ findVertical(pointf * pts, double tmin, double tmax,
        return -1.0;
 
     /* if 1 crossing and on the line x = xcoord */
-    if ((no_cross == 1) && (ROUND(pts[3].x) == xcoord)) {
+    if ((no_cross == 1) && (ROUND(pts[3].x) == ROUND(xcoord))) {
        if ((ymin <= pts[3].y) && (pts[3].y <= ymax)) {
            return tmax;
        } else
@@ -225,7 +229,7 @@ findVertical(pointf * pts, double tmin, double tmax,
  */
 static double
 findHorizontal(pointf * pts, double tmin, double tmax,
-              int ycoord, int xmin, int xmax)
+              double ycoord, double xmin, double xmax)
 {
     pointf Left[4];
     pointf Right[4];
@@ -236,7 +240,7 @@ findHorizontal(pointf * pts, double tmin, double tmax,
        return -1.0;
 
     /* if 1 crossing and on the line y = ycoord */
-    if ((no_cross == 1) && (ROUND(pts[3].y) == ycoord)) {
+    if ((no_cross == 1) && (ROUND(pts[3].y) == ROUND(ycoord))) {
        if ((xmin <= pts[3].x) && (pts[3].x <= xmax)) {
            return tmax;
        } else
@@ -251,12 +255,8 @@ findHorizontal(pointf * pts, double tmin, double tmax,
        return t;
     return findHorizontal(Right, (tmin + tmax) / 2.0, tmax, ycoord, xmin,
                          xmax);
-
 }
 
-#define P2PF(p, pf) (pf.x = p.x, pf.y = p.y)
-#define PF2P(pf, p) (p.x = ROUND (pf.x), p.y = ROUND (pf.y))
-
 /* splineIntersect:
  * Given four spline control points and a box,
  * find the shortest portion of the spline from
@@ -265,7 +265,7 @@ findHorizontal(pointf * pts, double tmin, double tmax,
  * with ipts[3] being on the box, and 1 is returned. Otherwise, ipts
  * is left unchanged and 0 is returned.
  */
-static int splineIntersect(point * ipts, box * bb)
+static int splineIntersect(point * ipts, boxf * bb)
 {
     double tmin = 2.0;
     double t;
@@ -309,7 +309,6 @@ static int splineIntersect(point * ipts, box * bb)
        return 1;
     } else
        return 0;
-
 }
 
 /* makeCompoundEdge:
@@ -328,7 +327,7 @@ static void makeCompoundEdge(graph_t * g, edge_t * e)
     int starti = 0, endi = 0;  /* index of first and last control point */
     node_t *head;
     node_t *tail;
-    box *bb;
+    boxf *bb;
     int i, j;
     int size;
     point pts[4];
@@ -504,7 +503,6 @@ static void makeCompoundEdge(graph_t * g, edge_t * e)
     free(bez->list);
     free(bez);
     ED_spl(e)->list = nbez;
-
 }
 
 /* dot_compoundEdges:
index f932ceed65ee59d6f7606f648ff6005c5eec0e4f..a13bef088aad7b172304ba7b95d0f894637ea1ed 100644 (file)
@@ -858,7 +858,6 @@ make_flat_adj_edges(path* P, edge_t** edges, int ind, int cnt, edge_t* e0,
     int     i, j, midx, midy, leftx, rightx;
     point   del;
     edge_t* hvye = NULL;
-    boxf bb;
 
     g = e0->tail->graph;
     tn = e0->tail, hn = e0->head;
@@ -959,7 +958,6 @@ 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);
        }
-       B2BF(GD_bb(g), bb);
        for (j = 0; j <  auxbz->size; ) {
            point pt;
            pointf cp[4];
@@ -976,9 +974,8 @@ make_flat_adj_edges(path* P, edge_t** edges, int ind, int cnt, edge_t* e0,
            j++;
            pt = transform(auxbz->list[j], del, GD_flip(g));
            P2PF(pt,cp[3]);
-           update_bb_bz(&bb, cp);
+           update_bb_bz(&GD_bb(g), cp);
         }
-       BF2B(bb, GD_bb(g));
        if (ED_label(e)) {
            point pt;
            PF2P(ED_label(auxe)->pos, pt);
@@ -2236,8 +2233,8 @@ point closest(splines * spl, point p)
 
 static int cl_vninside(graph_t * cl, node_t * n)
 {
-    return (BETWEEN(GD_bb(cl).LL.x, ND_coord_i(n).x, GD_bb(cl).UR.x) &&
-           BETWEEN(GD_bb(cl).LL.y, ND_coord_i(n).y, GD_bb(cl).UR.y));
+    return (BETWEEN(GD_bb(cl).LL.x, (double)(ND_coord_i(n).x), GD_bb(cl).UR.x) &&
+           BETWEEN(GD_bb(cl).LL.y, (double)(ND_coord_i(n).y), GD_bb(cl).UR.y));
 }
 
 /* returns the cluster of (adj) that interferes with n,
@@ -2286,7 +2283,7 @@ node_t *n, *adj;
 
 static box maximal_bbox(spline_info_t* sp, node_t* vn, edge_t* ie, edge_t* oe)
 {
-    int nb, b;
+    double b, nb;
     graph_t *g = vn->graph, *left_cl, *right_cl;
     node_t *left, *right;
     box rv;
@@ -2294,43 +2291,43 @@ static box maximal_bbox(spline_info_t* sp, node_t* vn, edge_t* ie, edge_t* oe)
     left_cl = right_cl = NULL;
 
     /* give this node all the available space up to its neighbors */
-    b = ND_coord_i(vn).x - ND_lw_i(vn) - FUDGE;
+    b = (double)(ND_coord_i(vn).x - ND_lw_i(vn) - FUDGE);
     if ((left = neighbor(vn, ie, oe, -1))) {
        if ((left_cl = cl_bound(vn, left)))
-           nb = GD_bb(left_cl).UR.x + sp->Splinesep;
+           nb = GD_bb(left_cl).UR.x + (double)(sp->Splinesep);
        else {
-           nb = ND_coord_i(left).x + ND_mval(left);
+           nb = (double)(ND_coord_i(left).x + ND_mval(left));
            if (ND_node_type(left) == NORMAL)
-               nb += GD_nodesep(g) / 2;
+               nb += GD_nodesep(g) / 2.;
            else
-               nb += sp->Splinesep;
+               nb += (double)(sp->Splinesep);
        }
        if (nb < b)
            b = nb;
-       rv.LL.x = b;
+       rv.LL.x = ROUND(b);
     } else
-       rv.LL.x = MIN(b, sp->LeftBound);
+       rv.LL.x = MIN(ROUND(b), sp->Splinesep);
 
     /* we have to leave room for our own label! */
     if ((ND_node_type(vn) == VIRTUAL) && (ND_label(vn)))
-       b = ND_coord_i(vn).x + 10;
+       b = (double)(ND_coord_i(vn).x + 10);
     else
-       b = ND_coord_i(vn).x + ND_rw_i(vn) + FUDGE;
+       b = (double)(ND_coord_i(vn).x + ND_rw_i(vn) + FUDGE);
     if ((right = neighbor(vn, ie, oe, 1))) {
        if ((right_cl = cl_bound(vn, right)))
-           nb = GD_bb(right_cl).LL.x - sp->Splinesep;
+           nb = GD_bb(right_cl).LL.x - (double)(sp->Splinesep);
        else {
            nb = ND_coord_i(right).x - ND_lw_i(right);
            if (ND_node_type(right) == NORMAL)
-               nb -= GD_nodesep(g) / 2;
+               nb -= GD_nodesep(g) / 2.;
            else
-               nb -= sp->Splinesep;
+               nb -= (double)(sp->Splinesep);
        }
        if (nb > b)
            b = nb;
-       rv.UR.x = b;
+       rv.UR.x = ROUND(b);
     } else
-       rv.UR.x = MAX(b, sp->RightBound);
+       rv.UR.x = MAX(ROUND(b), sp->RightBound);
 
     if ((ND_node_type(vn) == VIRTUAL) && (ND_label(vn)))
        rv.UR.x -= ND_rw_i(vn);
index f29e4d8f9ca1218af81eb2badeef467983e630a8..7ae2abc7beeb7acf8103522374135e0141c314f8 100644 (file)
@@ -872,11 +872,11 @@ static void dot_compute_bb(graph_t * g, graph_t * root)
 {
     int r, c, x, offset;
     node_t *v;
-    point LL, UR;
+    pointf LL, UR;
 
     if (g == g->root) {
-       LL.x = INT_MAX;
-       UR.x = -INT_MAX;
+       LL.x = (double)(INT_MAX);
+       UR.x = (double)(-INT_MAX);
        for (r = GD_minrank(g); r <= GD_maxrank(g); r++) {
            int rnkn = GD_rank(g)[r].n;
            if (rnkn == 0)
@@ -886,7 +886,7 @@ static void dot_compute_bb(graph_t * g, graph_t * root)
            for (c = 1; (ND_node_type(v) != NORMAL) && c < rnkn; c++)
                v = GD_rank(g)[r].v[c];
            if (ND_node_type(v) == NORMAL) {
-               x = ND_coord_i(v).x - ND_lw_i(v);
+               x = (double)(ND_coord_i(v).x - ND_lw_i(v));
                LL.x = MIN(LL.x, x);
            }
            else continue;
@@ -894,22 +894,22 @@ static void dot_compute_bb(graph_t * g, graph_t * root)
            v = GD_rank(g)[r].v[rnkn - 1];
            for (c = rnkn-2; ND_node_type(v) != NORMAL; c--)
                v = GD_rank(g)[r].v[c];
-           x = ND_coord_i(v).x + ND_rw_i(v);
+           x = (double)(ND_coord_i(v).x + ND_rw_i(v));
            UR.x = MAX(UR.x, x);
        }
        offset = CL_OFFSET;
        for (c = 1; c <= GD_n_cluster(g); c++) {
-           x = GD_clust(g)[c]->u.bb.LL.x - offset;
+           x = (double)(GD_clust(g)[c]->u.bb.LL.x - offset);
            LL.x = MIN(LL.x, x);
-           x = GD_clust(g)[c]->u.bb.UR.x + offset;
+           x = (double)(GD_clust(g)[c]->u.bb.UR.x + offset);
            UR.x = MAX(UR.x, x);
        }
     } else {
-       LL.x = ND_rank(GD_ln(g));
-       UR.x = ND_rank(GD_rn(g));
+       LL.x = (double)(ND_rank(GD_ln(g)));
+       UR.x = (double)(ND_rank(GD_rn(g)));
     }
-    LL.y = ND_rank(root)[GD_maxrank(g)].v[0]->u.coord.y - GD_ht1(g);
-    UR.y = ND_rank(root)[GD_minrank(g)].v[0]->u.coord.y + GD_ht2(g);
+    LL.y = (double)(ND_rank(root)[GD_maxrank(g)].v[0]->u.coord.y - GD_ht1(g));
+    UR.y = (double)(ND_rank(root)[GD_minrank(g)].v[0]->u.coord.y + GD_ht2(g));
     GD_bb(g).LL = LL;
     GD_bb(g).UR = UR;
 }
index aa0e58f4fde4b0b23b0e3673e3943c30c25571bf..b59b2093af97efa5974f97e1cbf50c5f4e7d3ec6 100644 (file)
@@ -105,10 +105,11 @@ static void resetObjlist(objlist * l)
 static Ppoly_t *makeClustObs(graph_t * g, expand_t* pm)
 {
     Ppoly_t *obs = NEW(Ppoly_t);
-    box bb = GD_bb(g);
+    boxf bb;
     boxf newbb;
     Ppoint_t ctr;
 
+    bb = GD_bb(g);
     obs->pn = 4;
     obs->ps = N_NEW(4, Ppoint_t);
 
index 643049b07b9e8b3119f6b9dc0a21c58c5075a525..9306b2acb3c2efe311577f374338e02a25a0ab33 100644 (file)
 #include <values.h>
 #endif
 #endif
-#include <tlayout.h>
-#include <neatoprocs.h>
-#include <adjust.h>
-#include <comp.h>
-#include <pack.h>
 #include <assert.h>
-#include <clusteredges.h>
-#include <dbg.h>
+#include "tlayout.h"
+#include "neatoprocs.h"
+#include "adjust.h"
+#include "comp.h"
+#include "pack.h"
+#include "clusteredges.h"
+#include "dbg.h"
 
 typedef struct {
     graph_t*  rootg;  /* logical root; graph passed in to fdp_layout */
@@ -92,7 +92,7 @@ finalCC(graph_t * g, int c_cnt, graph_t ** cc, point * pts, graph_t * rg,
     /* compute graph bounding box in points */
     if (c_cnt) {
        cg = *cp++;
-       bb = GD_bb(cg);
+       BF2B(GD_bb(cg), bb);
        if (c_cnt > 1) {
            pt = *pp++;
            bb.LL.x += pt.x;
@@ -100,7 +100,7 @@ finalCC(graph_t * g, int c_cnt, graph_t ** cc, point * pts, graph_t * rg,
            bb.UR.x += pt.x;
            bb.UR.y += pt.y;
            while ((cg = *cp++)) {
-               b = GD_bb(cg);
+               BF2B(GD_bb(cg), b);
                pt = *pp++;
                b.LL.x += pt.x;
                b.LL.y += pt.y;
@@ -978,8 +978,11 @@ setClustNodes(graph_t* root)
 static void setBB(graph_t * g)
 {
     int i;
-    GD_bb(g).LL = cvt2pt(BB(g).LL);
-    GD_bb(g).UR = cvt2pt(BB(g).UR);
+    box bb;
+
+    bb.LL = cvt2pt(BB(g).LL);
+    bb.UR = cvt2pt(BB(g).UR);
+    B2BF(bb, GD_bb(g));
     for (i = 1; i <= GD_n_cluster(g); i++) {
        setBB(GD_clust(g)[i]);
     }
index 57931138e4b8af8272f5c0a78bac4cfd5062c258..5a3d0046c341bf36b9f6bb86d75ba84c72a492d6 100644 (file)
@@ -421,7 +421,7 @@ static int chkBB(Agraph_t * g, attrsym_t * G_bb)
            bb.LL.y = bb.UR.y;
            bb.UR.y = tmp;
        }
-       GD_bb(g) = bb;
+       B2BF(bb, GD_bb(g));
        return 1;
     } else
        return 0;
@@ -536,11 +536,13 @@ static void translateE(edge_t * e, point offset)
 static void translateG(Agraph_t * g, point offset)
 {
     int i;
+    pointf Offset;
 
-    GD_bb(g).UR.x -= offset.x;
-    GD_bb(g).UR.y -= offset.y;
-    GD_bb(g).LL.x -= offset.x;
-    GD_bb(g).LL.y -= offset.y;
+    P2PF(offset, Offset);
+    GD_bb(g).UR.x -= Offset.x;
+    GD_bb(g).UR.y -= Offset.y;
+    GD_bb(g).LL.x -= Offset.x;
+    GD_bb(g).LL.y -= Offset.y;
 
     if (GD_label(g) && GD_label(g)->set) {
        GD_label(g)->pos.x -= offset.x;
@@ -558,8 +560,11 @@ static void translate(Agraph_t * g, pos_edge posEdges)
     node_t *n;
     edge_t *e;
     pointf offset;
+    point ll;
 
-    offset = cvt2ptf(GD_bb(g).LL);
+    PF2P(GD_bb(g).LL, ll);
+
+    offset = cvt2ptf(ll);
     for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
        ND_pos(n)[0] -= offset.x;
        ND_pos(n)[1] -= offset.y;
@@ -568,10 +573,10 @@ static void translate(Agraph_t * g, pos_edge posEdges)
        for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
            for (e = agfstout(g, n); e; e = agnxtout(g, e))
                if (ED_spl(e))
-                   translateE(e, GD_bb(g).LL);
+                   translateE(e, ll);
        }
     }
-    translateG(g, GD_bb(g).LL);
+    translateG(g, ll);
 }
 
 /* init_nop:
@@ -617,7 +622,7 @@ int init_nop(Agraph_t * g, int adjust)
     /* At this point, all bounding boxes should be correctly defined.
      * If necessary, we translate the graph to the origin.
      */
-    if (adjust && (GD_bb(g).LL.x || GD_bb(g).LL.y))
+    if (adjust && (ROUND(abs(GD_bb(g).LL.x)) || ROUND(abs(GD_bb(g).LL.y))))
        translate(g, posEdges);
 
     if (!adjust) {
index fdba2317bd330fe1a2b3c1c01a47a9f3d820376c..6d464211572a98a93e15cf3b1d36c482b2e2fee6 100644 (file)
@@ -1003,9 +1003,11 @@ void spline_edges(graph_t * g)
 {
     node_t *n;
     pointf offset;
+    point ll;
 
+    P2PF(GD_bb(g).LL, ll);
     compute_bb(g);
-    offset = cvt2ptf(GD_bb(g).LL);
+    offset = cvt2ptf(ll);
     for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
        ND_pos(n)[0] -= offset.x;
        ND_pos(n)[1] -= offset.y;
@@ -1110,10 +1112,10 @@ static void _neato_set_aspect(graph_t * g)
     /* compute_bb(g); */
     if (GD_drawing(g)->ratio_kind) {
        /* normalize */
-       assert(GD_bb(g).LL.x == 0);
-       assert(GD_bb(g).LL.y == 0);
+       assert(ROUND(GD_bb(g).LL.x) == 0);
+       assert(ROUND(GD_bb(g).LL.y) == 0);
        if (GD_flip(g)) {
-           int t = GD_bb(g).UR.x;
+           double t = GD_bb(g).UR.x;
            GD_bb(g).UR.x = GD_bb(g).UR.y;
            GD_bb(g).UR.y = t;
        }
@@ -1121,8 +1123,8 @@ static void _neato_set_aspect(graph_t * g)
            /* fill is weird because both X and Y can stretch */
            if (GD_drawing(g)->size.x <= 0)
                return;
-           xf = (double) GD_drawing(g)->size.x / (double) GD_bb(g).UR.x;
-           yf = (double) GD_drawing(g)->size.y / (double) GD_bb(g).UR.y;
+           xf = (double) GD_drawing(g)->size.x / GD_bb(g).UR.x;
+           yf = (double) GD_drawing(g)->size.y / GD_bb(g).UR.y;
            /* handle case where one or more dimensions is too big */
            if ((xf < 1.0) || (yf < 1.0)) {
                if (xf < yf) {
@@ -1136,8 +1138,8 @@ static void _neato_set_aspect(graph_t * g)
        } else if (GD_drawing(g)->ratio_kind == R_EXPAND) {
            if (GD_drawing(g)->size.x <= 0)
                return;
-           xf = (double) GD_drawing(g)->size.x / (double) GD_bb(g).UR.x;
-           yf = (double) GD_drawing(g)->size.y / (double) GD_bb(g).UR.y;
+           xf = (double) GD_drawing(g)->size.x / GD_bb(g).UR.x;
+           yf = (double) GD_drawing(g)->size.y / GD_bb(g).UR.y;
            if ((xf > 1.0) && (yf > 1.0)) {
                double scale = MIN(xf, yf);
                xf = yf = scale;
@@ -1145,7 +1147,7 @@ static void _neato_set_aspect(graph_t * g)
                return;
        } else if (GD_drawing(g)->ratio_kind == R_VALUE) {
            desired = GD_drawing(g)->ratio;
-           actual = ((double) GD_bb(g).UR.y) / ((double) GD_bb(g).UR.x);
+           actual = (GD_bb(g).UR.y) / (GD_bb(g).UR.x);
            if (actual < desired) {
                yf = desired / actual;
                xf = 1.0;
index 0656d23a62c4c816ff20187c90fd8ce0da8662e8..75a278e55cdc1bdef8edf584773011e2aac59ab4 100644 (file)
@@ -219,9 +219,10 @@ genBox(Agraph_t * g, ginfo * info, int ssize, int margin, point center)
     PointSet *ps;
     int W, H;
     point UR, LL;
-    box bb = GD_bb(g);
+    box bb;
     int x, y;
 
+    BF2B(GD_bb(g), bb);
     ps = newPS();
 
     LL.x = center.x - margin;
@@ -288,8 +289,8 @@ genPoly(Agraph_t * root, Agraph_t * g, ginfo * info,
        eg = g;
 
     ps = newPS();
-    dx = center.x - GD_bb(g).LL.x;
-    dy = center.y - GD_bb(g).LL.y;
+    dx = center.x - ROUND(GD_bb(g).LL.x);
+    dy = center.y - ROUND(GD_bb(g).LL.y);
 
     if (pinfo->mode == l_clust) {
        int i;
@@ -305,7 +306,7 @@ genPoly(Agraph_t * root, Agraph_t * g, ginfo * info,
        /* do bbox of top clusters */
        for (i = 1; i <= GD_n_cluster(g); i++) {
            subg = GD_clust(g)[i];
-           bb = GD_bb(subg);
+           BF2B(GD_bb(subg), bb);
            if ((bb.UR.x > bb.LL.x) && (bb.UR.y > bb.LL.y)) {
                MOVEPT(bb.LL);
                MOVEPT(bb.UR);
@@ -386,8 +387,8 @@ genPoly(Agraph_t * root, Agraph_t * g, ginfo * info,
     info->graph = g;
     info->cells = pointsOf(ps);
     info->nc = sizeOf(ps);
-    W = GRID(GD_bb(g).UR.x - GD_bb(g).LL.x + 2 * margin, ssize);
-    H = GRID(GD_bb(g).UR.y - GD_bb(g).LL.y + 2 * margin, ssize);
+    W = GRID(ROUND(GD_bb(g).UR.x - GD_bb(g).LL.x) + 2 * margin, ssize);
+    H = GRID(ROUND(GD_bb(g).UR.y - GD_bb(g).LL.y) + 2 * margin, ssize);
     info->perim = W + H;
 
     if (Verbose > 2) {
@@ -425,7 +426,7 @@ fits(int x, int y, ginfo * info, PointSet * ps, point * place, int step)
        cells++;
     }
 
-    LL = GD_bb(info->graph).LL;
+    PF2P(GD_bb(info->graph).LL, LL);
     place->x = step * x - LL.x;
     place->y = step * y - LL.y;
 
@@ -484,16 +485,16 @@ placeGraph(int i, ginfo * info, PointSet * ps, point * place, int step,
 
     if (i == 0) {
        Agraph_t *g = info->graph;
-       W = GRID(GD_bb(g).UR.x - GD_bb(g).LL.x + 2 * margin, step);
-       H = GRID(GD_bb(g).UR.y - GD_bb(g).LL.y + 2 * margin, step);
+       W = GRID(ROUND(GD_bb(g).UR.x - GD_bb(g).LL.x) + 2 * margin, step);
+       H = GRID(ROUND(GD_bb(g).UR.y - GD_bb(g).LL.y) + 2 * margin, step);
        if (fits(-W / 2, -H / 2, info, ps, place, step))
            return;
     }
 
     if (fits(0, 0, info, ps, place, step))
        return;
-    W = GD_bb(info->graph).UR.x - GD_bb(info->graph).LL.x;
-    H = GD_bb(info->graph).UR.y - GD_bb(info->graph).LL.y;
+    W = ROUND(GD_bb(info->graph).UR.x - GD_bb(info->graph).LL.x);
+    H = ROUND(GD_bb(info->graph).UR.y - GD_bb(info->graph).LL.y);
     if (W >= H) {
        for (bnd = 1;; bnd++) {
            x = 0;
@@ -581,7 +582,7 @@ point *putGraphs(int ng, Agraph_t ** gs, Agraph_t * root,
     int i;
     boolean *fixed = pinfo->fixed;
     int fixed_cnt = 0;
-    box fixed_bb = { {0, 0}, {0, 0} };
+    box bb, fixed_bb = { {0, 0}, {0, 0} };
     point center;
 
     if (ng <= 0)
@@ -593,18 +594,18 @@ point *putGraphs(int ng, Agraph_t ** gs, Agraph_t * root,
        Agraph_t *g = gs[i];
        compute_bb(g);
        if (fixed && fixed[i]) {
+           BF2B(GD_bb(g), bb);
            if (fixed_cnt) {
-               box bb = GD_bb(g);
                fixed_bb.LL.x = MIN(bb.LL.x, fixed_bb.LL.x);
                fixed_bb.LL.y = MIN(bb.LL.y, fixed_bb.LL.y);
                fixed_bb.UR.x = MAX(bb.UR.x, fixed_bb.UR.x);
                fixed_bb.UR.y = MAX(bb.UR.y, fixed_bb.UR.y);
            } else
-               fixed_bb = GD_bb(g);
+               fixed_bb = bb;
            fixed_cnt++;
        }
        if (Verbose > 2) {
-           fprintf(stderr, "bb[%s] %d %d %d %d\n", g->name, GD_bb(g).LL.x,
+           fprintf(stderr, "bb[%s] %.3g %.3g %.3g %.3g\n", g->name, GD_bb(g).LL.x,
                    GD_bb(g).LL.y, GD_bb(g).UR.x, GD_bb(g).UR.y);
        }
     }
@@ -706,9 +707,10 @@ static void shiftEdge(Agedge_t * e, int dx, int dy)
 static void shiftGraph(Agraph_t * g, int dx, int dy)
 {
     graph_t *subg;
-    box bb = GD_bb(g);
+    boxf bb = GD_bb(g);
     int i;
 
+    bb = GD_bb(g);
     bb.LL.x += dx;
     bb.UR.x += dx;
     bb.LL.y += dy;
@@ -827,7 +829,7 @@ packSubgraphs(int ng, Agraph_t ** gs, Agraph_t * root, pack_info * info)
     ret = packGraphs(ng, gs, root, info);
     if (ret == 0) {
        int i, j;
-       box bb;
+       boxf bb;
        graph_t* g;
 
        compute_bb(root);
index 66b7ea62f5ebc9a54eb1d1f677c65ce347574a29..2963062c07fc25877c424753975554b77742338f 100644 (file)
@@ -203,7 +203,7 @@ void patchwork_layout(Agraph_t *g)
        printer(&root);
        walker(&root);
        compute_bb(g);
-       fprintf(stderr,"bb %d %d %d %d\n",
+       fprintf(stderr,"bb %.3g %.3g %.3g %.3g\n",
                GD_bb(g).LL.x, GD_bb(g).LL.y, GD_bb(g).UR.x, GD_bb(g).UR.y);
        dotneato_postprocess(g);
 }