]> granicus.if.org Git - graphviz/commitdiff
use pointf in paths
authorellson <devnull@localhost>
Wed, 10 Sep 2008 03:26:29 +0000 (03:26 +0000)
committerellson <devnull@localhost>
Wed, 10 Sep 2008 03:26:29 +0000 (03:26 +0000)
lib/common/routespl.c
lib/common/splines.c
lib/common/types.h
lib/neatogen/multispline.c
lib/neatogen/neatoprocs.h
lib/neatogen/neatosplines.c

index 477692225aed3a13b1dd5fa899656bdb6d692ccb..5d2e64b18ebda4bd55a2d3c37f7db7b6c3b4ecc2 100644 (file)
@@ -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");
 }
index fee3f1d6d4a0873b85f53c55cd8332464453d1e4..7fec4f2812d77707ec015ab3b4ec550efb09a17c 100644 (file)
@@ -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;
index e4593978688e5290aa962b98bb80b63f4c1d8b3a..5d6ce95382bbe502c71703d9dae341848584b08e 100644 (file)
@@ -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];
index ca058338344ed806e8cc9b2aaa5c422cf52abc97..195d7b24446ed3146c98a28754e1d784c4ef3da0 100644 (file)
@@ -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);
index 23d7699f78cfa4a9e290297d6bd39b8ca1b2697e..bb780c3990c153691d6c5398f3a850538716b0a9 100644 (file)
@@ -22,7 +22,7 @@ extern "C" {
 #endif
 #include <adjust.h>
 
-    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);
index e0f2b71925e3912ec11dfa5d94e1ad45ce72fc5a..a1089d011f193ce613be78f75b7caf18e8c56321 100644 (file)
@@ -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 */