return 0;
}
+/* update bounding box to contain a bezier segment */
+void update_bb_bz(boxf *bb, pointf *cp)
+{
+
+ /* if any control point of the segment is outside the bounding box */
+ if (cp[0].x > bb->UR.x || cp[0].x < bb->LL.x ||
+ cp[0].y > bb->UR.y || cp[0].y < bb->LL.y ||
+ cp[1].x > bb->UR.x || cp[1].x < bb->LL.x ||
+ cp[1].y > bb->UR.y || cp[1].y < bb->LL.y ||
+ cp[2].x > bb->UR.x || cp[2].x < bb->LL.x ||
+ cp[2].y > bb->UR.y || cp[2].y < bb->LL.y ||
+ cp[3].x > bb->UR.x || cp[3].x < bb->LL.x ||
+ cp[3].y > bb->UR.y || cp[3].y < bb->LL.y) {
+
+ /* if the segment is sufficiently refined */
+ if (check_control_points(cp)) {
+ int i;
+ /* expand the bounding box */
+ for (i = 0; i < 4; i++) {
+ if (cp[i].x > bb->UR.x)
+ bb->UR.x = cp[i].x;
+ else if (cp[i].x < bb->LL.x)
+ bb->LL.x = cp[i].x;
+ if (cp[i].y > bb->UR.y)
+ bb->UR.y = cp[i].y;
+ else if (cp[i].y < bb->LL.y)
+ bb->LL.y = cp[i].y;
+ }
+ }
+ else { /* else refine the segment */
+ pointf left[4], right[4];
+ Bezier (cp, 3, 0.5, left, right);
+ update_bb_bz(bb, left);
+ update_bb_bz(bb, right);
+ }
+ }
+}
+
#ifdef DEBUG
static void psmapOutput (pointf* ps, int n)
{
extern void start_timer(void);
extern pointf textsize(graph_t *g, textpara_t * para, char *fontname, double fontsize);
extern void translate_bb(Agraph_t *, int);
+ extern void update_bb_bz(boxf *bb, pointf *cp);
extern void write_attributed_dot(graph_t *g, FILE *f);
extern void write_canonical_dot(graph_t *g, FILE *f);
extern void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend);
return rv;
}
-/* update_bb:
- * Update the bounding box of g based on the addition of
- * point p.
- */
-void update_bb(graph_t * g, point pt)
-{
- if (pt.x > GD_bb(g).UR.x)
- GD_bb(g).UR.x = pt.x;
- if (pt.y > GD_bb(g).UR.y)
- GD_bb(g).UR.y = pt.y;
- if (pt.x < GD_bb(g).LL.x)
- GD_bb(g).LL.x = pt.x;
- if (pt.y < GD_bb(g).LL.y)
- GD_bb(g).LL.y = pt.y;
-}
-
/* clip_and_install:
* Given a raw spline (pn control points in ps), representing
* a path from edge fe->tail ending in node hn, clip the ends to
int start, end, i, clipTail, clipHead;
graph_t *g;
edge_t *orig;
- box* tbox;
- box* hbox;
+ box *tbox, *hbox;
+ boxf bb;
inside_t inside_context;
tn = fe->tail;
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; ) {
- point pt, pt1, pt2;
- pt = newspl->list[i - start] = ps[i];
+ pointf cp[4];
+ newspl->list[i - start] = ps[i];
+ P2PF(ps[i], cp[0]);
i++;
- update_bb(g, pt);
- if ( i >= end + 4)
+ if ( i >= end + 4)
break;
- /* take the mid-point between the two control points in bb calculation */
- pt1 = newspl->list[i - start] = ps[i];
+ newspl->list[i - start] = ps[i];
+ P2PF(ps[i], cp[1]);
i++;
- pt2 = newspl->list[i - start] = ps[i];
+ newspl->list[i - start] = ps[i];
+ P2PF(ps[i], cp[2]);
i++;
- pt.x = ( pt1.x + pt2.x ) / 2;
- pt.y = ( pt1.y + pt2.y ) / 2;
- update_bb(g, pt);
+ P2PF(ps[i], cp[3]);
+ update_bb_bz(&bb, cp);
}
+ BF2B(bb, GD_bb(g));
newspl->size = end - start + 4;
}
extern int common_init_edge(edge_t * e);
extern void updateBB(graph_t * g, textlabel_t * lp);
- extern void update_bb(graph_t * g, point p);
extern void compute_bb(Agraph_t *);
extern boolean overlap_node(node_t *n, boxf b);
extern boolean overlap_label(textlabel_t *lp, boxf b);
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;
bz->eflag = auxbz->eflag;
bz->ep = transform(auxbz->ep, del, 0);
}
+ B2BF(GD_bb(g), bb);
for (j = 0; j < auxbz->size; ) {
- point pt, pt1, pt2;
+ point pt;
+ pointf cp[4];
pt = bz->list[j] = transform(auxbz->list[j], del, GD_flip(g));
+ P2PF(pt,cp[0]);
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));
+ pt = bz->list[j] = transform(auxbz->list[j], del, GD_flip(g));
+ P2PF(pt,cp[1]);
j++;
- pt2 = bz->list[j] = transform(auxbz->list[j], del, GD_flip(g));
+ pt = bz->list[j] = transform(auxbz->list[j], del, GD_flip(g));
+ P2PF(pt,cp[2]);
j++;
- pt.x = ( pt1.x + pt2.x ) / 2;
- pt.y = ( pt1.y + pt2.y ) / 2;
- update_bb(g, pt);
+ pt = transform(auxbz->list[j], del, GD_flip(g));
+ P2PF(pt,cp[3]);
+ update_bb_bz(&bb, cp);
}
+ BF2B(bb, GD_bb(g));
if (ED_label(e)) {
ED_label(e)->p = transform(ED_label(auxe)->p, del, GD_flip(g));
updateBB(g, ED_label(e));