/* makePolyline: */ static void makePolyline(graph_t* g, edge_t * e) { Ppolyline_t spl, line = ED_path(e); Ppoint_t p0, q0; p0 = line.ps[0]; q0 = line.ps[line.pn - 1]; make_polyline (line, &spl); if (Verbose > 1) fprintf(stderr, "polyline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); clip_and_install(e, aghead(e), spl.ps, spl.pn, &sinfo); addEdgeLabels(g, e, p0, q0); }
/* makeMultiSpline: * FIX: we don't really use the shortest path provided by ED_path, * so avoid in neato spline code. * Return 0 on success. */ int makeMultiSpline(graph_t* g, edge_t* e, router_t * rtr, int doPolyline) { Ppolyline_t line = ED_path(e); node_t *t = agtail(e); node_t *h = aghead(e); pointf t_p = line.ps[0]; pointf h_p = line.ps[line.pn - 1]; tripoly_t *poly; int idx; int *sp; int t_id = rtr->tn; int h_id = rtr->tn + 1; int ecnt = rtr->tg->nedges; PPQ pq; PQTYPE *idxs; PQVTYPE *vals; int ret; /* Add endpoints to triangle graph */ addEndpoint(rtr, t_p, t, t_id, ED_tail_port(e).side); addEndpoint(rtr, h_p, h, h_id, ED_head_port(e).side); /* Initialize priority queue */ PQgen(&pq.pq, rtr->tn + 2, -1); idxs = N_GNEW(pq.pq.PQsize + 1, PQTYPE); vals = N_GNEW(pq.pq.PQsize + 1, PQVTYPE); vals[0] = 0; pq.vals = vals + 1; pq.idxs = idxs + 1; /* Find shortest path of triangles */ sp = triPath(rtr->tg, rtr->tn+2, h_id, t_id, (PQ *) & pq); free(vals); free(idxs); PQfree(&(pq.pq), 0); /* Use path of triangles to generate guiding polygon */ poly = mkPoly(rtr, sp, h_id, t_id, h_p, t_p, &idx); free(sp); /* Generate multiple splines using polygon */ ret = genroute(g, poly, 0, idx, e, doPolyline); freeTripoly (poly); resetGraph(rtr->tg, rtr->tn, ecnt); return ret; }
/* makeSpline: * Construct a spline connecting the endpoints of e, avoiding the npoly * obstacles obs. * The resultant spline is attached to the edge, the positions of any * edge labels are computed, and the graph's bounding box is recomputed. * * If chkPts is true, the function checks if one or both of the endpoints * is on or inside one of the obstacles and, if so, tells the shortest path * computation to ignore them. */ void makeSpline(graph_t* g, edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts) { Ppolyline_t line, spline; Pvector_t slopes[2]; int i, n_barriers; int pp, qp; Ppoint_t p, q; Pedge_t *barriers; line = ED_path(e); p = line.ps[0]; q = line.ps[line.pn - 1]; /* determine the polygons (if any) that contain the endpoints */ pp = qp = POLYID_NONE; if (chkPts) for (i = 0; i < npoly; i++) { if ((pp == POLYID_NONE) && in_poly(*obs[i], p)) pp = i; if ((qp == POLYID_NONE) && in_poly(*obs[i], q)) qp = i; } make_barriers(obs, npoly, pp, qp, &barriers, &n_barriers); slopes[0].x = slopes[0].y = 0.0; slopes[1].x = slopes[1].y = 0.0; if (Proutespline(barriers, n_barriers, line, slopes, &spline) < 0) { agerr (AGERR, "makeSpline: failed to make spline edge (%s,%s)\n", agnameof(agtail(e)), agnameof(aghead(e))); return; } /* north why did you ever use int coords */ if (Verbose > 1) fprintf(stderr, "spline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); clip_and_install(e, aghead(e), spline.ps, spline.pn, &sinfo); free(barriers); addEdgeLabels(g, e, p, q); }