From: ellson Date: Wed, 10 Sep 2008 03:26:29 +0000 (+0000) Subject: use pointf in paths X-Git-Tag: LAST_LIBGRAPH~32^2~3423 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13d131c6cf11eb24e0ae1826ecb3b8598478e246;p=graphviz use pointf in paths --- diff --git a/lib/common/routespl.c b/lib/common/routespl.c index 477692225..5d2e64b18 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -948,10 +948,10 @@ static void printpath(path * pp) fprintf(stderr, "%d (%.3g, %.3g), (%.3g, %.3g)\n", bi, pp->boxes[bi].LL.x, pp->boxes[bi].LL.y, pp->boxes[bi].UR.x, pp->boxes[bi].UR.y); - fprintf(stderr, "start port: (%d, %d), tangent angle: %.3f, %s\n", + fprintf(stderr, "start port: (%.3g, %.3g), tangent angle: %.3g, %s\n", pp->start.p.x, pp->start.p.y, pp->start.theta, pp->start.constrained ? "constrained" : "not constrained"); - fprintf(stderr, "end port: (%d, %d), tangent angle: %.3f, %s\n", + fprintf(stderr, "end port: (%.3g, %.3g), tangent angle: %.3g, %s\n", pp->end.p.x, pp->end.p.y, pp->end.theta, pp->end.constrained ? "constrained" : "not constrained"); } diff --git a/lib/common/splines.c b/lib/common/splines.c index fee3f1d6d..7fec4f281 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -386,6 +386,7 @@ beginpath(path * P, edge_t * e, int et, pathend_t * endp, boolean merge) { int side, mask; node_t *n; + pointf np; int (*pboxfn) (node_t*, port*, int, boxf*, int*); n = e->tail; @@ -396,7 +397,8 @@ beginpath(path * P, edge_t * e, int et, pathend_t * endp, boolean merge) pboxfn = ND_shape(n)->fns->pboxfn; else pboxfn = NULL; - P->start.p = add_points(ND_coord_i(n), ED_tail_port(e).p); + P2PF(ND_coord_i(n), np); + P->start.p = add_pointfs(np, ED_tail_port(e).p); if (merge) { /*P->start.theta = - M_PI / 2; */ P->start.theta = conc_slope(e->tail); @@ -577,6 +579,7 @@ void endpath(path * P, edge_t * e, int et, pathend_t * endp, boolean merge) { int side, mask; node_t *n; + pointf np; int (*pboxfn) (node_t* n, port*, int, boxf*, int*); n = e->head; @@ -587,7 +590,8 @@ void endpath(path * P, edge_t * e, int et, pathend_t * endp, boolean merge) pboxfn = ND_shape(n)->fns->pboxfn; else pboxfn = NULL; - P->end.p = add_points(ND_coord_i(n), ED_head_port(e).p); + P2PF(ND_coord_i(n), np); + P->end.p = add_pointfs(np, ED_head_port(e).p); if (merge) { /*P->end.theta = M_PI / 2; */ P->end.theta = conc_slope(e->head) + M_PI; diff --git a/lib/common/types.h b/lib/common/types.h index e45939786..5d6ce9538 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -65,7 +65,7 @@ extern "C" { } inside_t; typedef struct port { /* internal edge endpoint specification */ - point p; /* aiming point relative to node center */ + pointf p; /* aiming point relative to node center */ double theta; /* slope in radians */ boxf *bp; /* if not null, points to bbox of * rectangular area that is port target @@ -88,7 +88,7 @@ extern "C" { typedef struct pathend_t { boxf nb; /* the node box */ - point np; /* node port */ + pointf np; /* node port */ int sidemask; int boxn; boxf boxes[20]; diff --git a/lib/neatogen/multispline.c b/lib/neatogen/multispline.c index ca0583383..195d7b244 100644 --- a/lib/neatogen/multispline.c +++ b/lib/neatogen/multispline.c @@ -786,22 +786,21 @@ finishEdge (edge_t* e, Ppoly_t spl, int flip, pointf p, pointf q) { int j; pointf *spline = N_GNEW(spl.pn, pointf); - point p1, q1; - + pointf p1, q1; if (flip) { for (j = 0; j < spl.pn; j++) { spline[spl.pn - 1 - j] = spl.ps[j]; } - PF2P(q, p1); - PF2P(p, q1); + p1 = q; + q1 = p; } else { for (j = 0; j < spl.pn; j++) { spline[j] = spl.ps[j]; } - PF2P(p, p1); - PF2P(q, q1); + p1 = p; + q1 = q; } if (Verbose > 1) fprintf(stderr, "spline %s %s\n", e->tail->name, e->head->name); diff --git a/lib/neatogen/neatoprocs.h b/lib/neatogen/neatoprocs.h index 23d7699f7..bb780c399 100644 --- a/lib/neatogen/neatoprocs.h +++ b/lib/neatogen/neatoprocs.h @@ -22,7 +22,7 @@ extern "C" { #endif #include - extern void addEdgeLabels(edge_t * e, point rp, point rq); + extern void addEdgeLabels(edge_t * e, pointf rp, pointf rq); extern int allow_edits(int); extern void avoid_cycling(graph_t *, Agnode_t *, double *); extern int checkStart(graph_t * G, int nG, int); diff --git a/lib/neatogen/neatosplines.c b/lib/neatogen/neatosplines.c index e0f2b7192..a1089d011 100644 --- a/lib/neatogen/neatosplines.c +++ b/lib/neatogen/neatosplines.c @@ -201,7 +201,7 @@ polylineMidpoint (splines* spl, pointf* pp, pointf* pq) * significantly from rp and rq, but if the spline is degenerate (e.g., * the nodes overlap), we use rp and rq. */ -void addEdgeLabels(edge_t * e, point rp, point rq) +void addEdgeLabels(edge_t * e, pointf rp, pointf rq) { int et = EDGE_TYPE (e->head->graph->root); pointf p, q; @@ -214,9 +214,10 @@ void addEdgeLabels(edge_t * e, point rp, point rq) if (ED_label(e) && !ED_label(e)->set) { endPoints(ED_spl(e), &p, &q); +// FIXME - fp equality test if ((p.x == q.x) && (p.y == q.y)) { /* degenerate spline */ - P2PF(rp, p); - P2PF(rq, q); + p = rp; + q = rq; spf = p; } else if (et == ET_SPLINE) { @@ -262,9 +263,9 @@ void addEdgeLabels(edge_t * e, point rp, point rq) typedef struct { node_t *n1; - point p1; + pointf p1; node_t *n2; - point p2; + pointf p2; } edgeinfo; typedef struct { Dtlink_t link; @@ -349,8 +350,8 @@ static edge_t *equivEdge(Dt_t * map, edge_t * e) test.n1 = e->head; test.p1 = ED_head_port(e).p; } else { - point hp = ED_head_port(e).p; - point tp = ED_tail_port(e).p; + pointf hp = ED_head_port(e).p; + pointf tp = ED_tail_port(e).p; if (tp.x < hp.x) { test.p1 = tp; test.p2 = hp; @@ -422,7 +423,7 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) node_t *head = e->head; int e_cnt = ED_count(e); pointf perp; - point del, P, Q; + pointf del; edge_t *e0; int i, j, xstep, dx; double l_perp; @@ -439,15 +440,14 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) if (e_cnt == 1) { clip_and_install(e, e->head, dumb, 4, &sinfo); - PF2P(p, P); - PF2P(q, Q); - addEdgeLabels(e, P, Q); + addEdgeLabels(e, p, q); return; } e0 = e; perp.x = dumb[0].y - dumb[3].y; perp.y = dumb[3].x - dumb[0].x; +// FIXME - fp equality test if ((perp.x == 0) && (perp.y == 0)) { /* degenerate case */ dumb[1] = dumb[0]; @@ -496,9 +496,7 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) else clip_and_install(e0, e0->head, dumber, 4, &sinfo); - PF2P(p, P); - PF2P(q, Q); - addEdgeLabels(e0, P, Q); + addEdgeLabels(e0, p, q); e0 = ED_to_virt(e0); dumb[1].x += del.x; dumb[1].y += del.y; @@ -662,12 +660,12 @@ getPath(edge_t * e, vconfig_t * vconfig, int chkPts, Ppoly_t ** obs, Ppolyline_t line; int pp, qp; Ppoint_t p, q; - point p1, q1; + pointf tp, hp; - p1 = add_points(ND_coord_i(e->tail), ED_tail_port(e).p); - q1 = add_points(ND_coord_i(e->head), ED_head_port(e).p); - P2PF(p1, p); - P2PF(q1, q); + P2PF(ND_coord_i(e->tail), tp); + p = add_pointfs(tp, ED_tail_port(e).p); + P2PF(ND_coord_i(e->head), hp); + q = add_pointfs(hp, ED_head_port(e).p); /* determine the polygons (if any) that contain the endpoints */ pp = qp = POLYID_NONE; @@ -693,7 +691,6 @@ static void makePolyline(edge_t * e) { Ppolyline_t spl, line = ED_path(e); - point p1, q1; Ppoint_t p0, q0; p0 = line.ps[0]; @@ -702,9 +699,7 @@ makePolyline(edge_t * e) if (Verbose > 1) fprintf(stderr, "polyline %s %s\n", e->tail->name, e->head->name); clip_and_install(e, e->head, spl.ps, spl.pn, &sinfo); - PF2P(p0, p1); - PF2P(q0, q1); - addEdgeLabels(e, p1, q1); + addEdgeLabels(e, p0, q0); } /* makeSpline: @@ -725,7 +720,6 @@ void makeSpline(edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts) int pp, qp; Ppoint_t p, q; Pedge_t *barriers; - point p1, q1; line = ED_path(e); p = line.ps[0]; @@ -750,9 +744,7 @@ void makeSpline(edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts) fprintf(stderr, "spline %s %s\n", e->tail->name, e->head->name); clip_and_install(e, e->head, spline.ps, spline.pn, &sinfo); free(barriers); - PF2P(p, p1); - PF2P(q, q1); - addEdgeLabels(e, p1, q1); + addEdgeLabels(e, p, q); } /* True if either head or tail has a port on its boundary */ @@ -832,10 +824,12 @@ static int _spline_edges(graph_t * g, expand_t* pmargin, int edgetype) /* fprintf (stderr, "%s -- %s %d\n", e->tail->name, e->head->name, ED_count(e)); */ node_t *head = e->head; if (useEdges && ED_spl(e)) { + pointf np, hp; + P2PF(ND_coord_i(n), np); + P2PF(ND_coord_i(head), hp); addEdgeLabels(e, - add_points(ND_coord_i(n), ED_tail_port(e).p), - add_points(ND_coord_i(head), - ED_head_port(e).p)); + add_pointfs(np, ED_tail_port(e).p), + add_pointfs(hp, ED_head_port(e).p)); } else if (ED_count(e) == 0) continue; /* only do representative */ else if (n == head) { /* self arc */