Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
multispline.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include <assert.h>
12#include <float.h>
13#include <limits.h>
15#include <neatogen/delaunay.h>
16#include <neatogen/neatoprocs.h>
17#include <math.h>
18#include <stdbool.h>
19#include <stddef.h>
20#include <util/alloc.h>
21
22static bool spline_merge(node_t * n)
23{
24 (void)n;
25 return false;
26}
27
28static bool swap_ends_p(edge_t * e)
29{
30 (void)e;
31 return false;
32}
33
35 .splineMerge = spline_merge};
36
37typedef struct {
38 int i, j;
39} ipair;
40
41typedef struct _tri {
43 struct _tri *nxttri;
45
46typedef struct {
47 Ppoly_t poly; /* base polygon used for routing an edge */
48 tri **triMap; /* triMap[j] is list of all opposite sides of
49 triangles containing vertex j, represented
50 as the indices of the two points in poly */
51} tripoly_t;
52
53/*
54 * Support for map from I x I -> I
55 */
56typedef struct {
57 Dtlink_t link; /* cdt data */
58 int a[2]; /* key */
59 int t;
60} item;
61
62static int cmpItem(void *item1, void *item2) {
63 const int *p1 = item1;
64 const int *p2 = item2;
65 if (p1[0] < p2[0]) return -1;
66 if (p1[0] > p2[0]) return 1;
67 if (p1[1] < p2[1]) return -1;
68 if (p1[1] > p2[1]) return 1;
69 return 0;
70}
71
72/* newItem:
73 */
74static void *newItem(void *p, Dtdisc_t *disc) {
75 item *objp = p;
76 item *newp = gv_alloc(sizeof(item));
77
78 (void)disc;
79 newp->a[0] = objp->a[0];
80 newp->a[1] = objp->a[1];
81 newp->t = objp->t;
82
83 return newp;
84}
85
87 .key = offsetof(item, a),
88 .size = 2 * sizeof(int),
89 .link = offsetof(item, link),
90 .makef = newItem,
91 .freef = free,
92 .comparf = cmpItem,
93};
94
95static void addMap(Dt_t * map, int a, int b, int t)
96{
97 item it;
98 int tmp;
99 if (a > b) {
100 tmp = a;
101 a = b;
102 b = tmp;
103 }
104 it.a[0] = a;
105 it.a[1] = b;
106 it.t = t;
107 dtinsert(map, &it);
108}
109
110/* mapSegToTri:
111 * Create mapping from indices of side endpoints to triangle id
112 * We use a set rather than a bag because the segments used for lookup
113 * will always be a side of a polygon and hence have a unique triangle.
114 */
116{
117 Dt_t *map = dtopen(&itemdisc, Dtoset);
118 int i, a, b, c;
119 int *ps = sf->faces;
120 for (i = 0; i < sf->nfaces; i++) {
121 a = *ps++;
122 b = *ps++;
123 c = *ps++;
124 addMap(map, a, b, i);
125 addMap(map, b, c, i);
126 addMap(map, c, a, i);
127 }
128 return map;
129}
130
131static int findMap(Dt_t * map, int a, int b)
132{
133 item it;
134 item *ip;
135 if (a > b) {
136 int tmp = a;
137 a = b;
138 b = tmp;
139 }
140 it.a[0] = a;
141 it.a[1] = b;
142 ip = dtsearch(map, &it);
143 assert(ip);
144 return ip->t;
145}
146
147/*
148 * Support for map from I -> I
149 */
150
151typedef struct {
152 Dtlink_t link; /* cdt data */
153 int i; /* key */
154 int j;
155} Ipair;
156
157static int cmpIpair(void *pair1, void *pair2) {
158 const int *p1 = pair1;
159 const int *p2 = pair2;
160 if (*p1 < *p2) {
161 return -1;
162 }
163 if (*p1 > *p2) {
164 return 1;
165 }
166 return 0;
167}
168
169static void *newIpair(void *p, Dtdisc_t *disc) {
170 Ipair *objp = p;
171 Ipair *newp = gv_alloc(sizeof(Ipair));
172
173 (void)disc;
174 newp->i = objp->i;
175 newp->j = objp->j;
176
177 return newp;
178}
179
181 .key = offsetof(Ipair, i),
182 .size = sizeof(int),
183 .link = offsetof(Ipair, link),
184 .makef = newIpair,
185 .freef = free,
186 .comparf = cmpIpair,
187};
188
189static void vmapAdd(Dt_t * map, int i, int j)
190{
191 Ipair obj;
192 obj.i = i;
193 obj.j = j;
194 dtinsert(map, &obj);
195}
196
197static int vMap(Dt_t * map, int i)
198{
199 Ipair *ip;
200 ip = dtmatch(map, &i);
201 return ip->j;
202}
203
204/* mapTri:
205 * Map vertex indices from router_t to tripoly_t coordinates.
206 */
207static void mapTri(Dt_t * map, tri * tp)
208{
209 for (; tp; tp = tp->nxttri) {
210 tp->v.i = vMap(map, tp->v.i);
211 tp->v.j = vMap(map, tp->v.j);
212 }
213}
214
215/* addTri:
216 */
217static tri *
218addTri(int i, int j, tri * oldp)
219{
220 tri *tp = gv_alloc(sizeof(tri));
221 tp->v.i = i;
222 tp->v.j = j;
223 tp->nxttri = oldp;
224 return tp;
225}
226
227/* bisect:
228 * Return the angle bisecting the angle pp--cp--np
229 */
230static double bisect(pointf pp, pointf cp, pointf np)
231{
232 double theta, phi;
233 theta = atan2(np.y - cp.y, np.x - cp.x);
234 phi = atan2(pp.y - cp.y, pp.x - cp.x);
235 return (theta + phi) / 2.0;
236}
237
238/* raySeg:
239 * Check if ray v->w intersects segment a--b.
240 */
241static int raySeg(pointf v, pointf w, pointf a, pointf b)
242{
243 int wa = wind(v, w, a);
244 int wb = wind(v, w, b);
245 if (wa == wb)
246 return 0;
247 if (wa == 0) {
248 return wind(v, b, w) * wind(v, b, a) >= 0;
249 } else {
250 return wind(v, a, w) * wind(v, a, b) >= 0;
251 }
252}
253
254/* raySegIntersect:
255 * Find the point p where ray v->w intersects segment ai-bi, if any.
256 * Return 1 on success, 0 on failure
257 */
258static int
260{
261 if (raySeg(v, w, a, b))
262 return line_intersect(v, w, a, b, p);
263 else
264 return 0;
265}
266
267/* triPoint:
268 * Given the triangle vertex v, and point w so that v->w points
269 * into the polygon, return where the ray v->w intersects the
270 * polygon. The search uses all of the opposite sides of triangles
271 * with v as vertex.
272 * Return 0 on success; 1 on failure.
273 */
274static int
275triPoint(tripoly_t * trip, int vx, pointf v, pointf w, pointf * ip)
276{
277 tri *tp;
278
279 for (tp = trip->triMap[vx]; tp; tp = tp->nxttri) {
281 (v, w, trip->poly.ps[tp->v.i], trip->poly.ps[tp->v.j], ip))
282 return 0;
283 }
284 return 1;
285}
286
287/* ctrlPtIdx:
288 * Find the index of v in the points polys->ps.
289 * We start at 1 since the point corresponding to 0
290 * will never be used as v.
291 */
292static int ctrlPtIdx(pointf v, Ppoly_t * polys)
293{
294 pointf w;
295 for (size_t i = 1; i < polys->pn; i++) {
296 w = polys->ps[i];
297 if (w.x == v.x && w.y == v.y) {
298 assert(i <= INT_MAX);
299 return (int)i;
300 }
301 }
302 return -1;
303}
304
305#define SEP 15
306
307/* mkCtrlPts:
308 * Generate mult points associated with v.
309 * The points will lie on the ray bisecting the angle prev--v--nxt.
310 * The first point will aways be v.
311 * The rest are positioned equally spaced with maximum spacing SEP.
312 * In addition, they all lie within the polygon trip->poly.
313 * Parameter s gives the index after which a vertex lies on the
314 * opposite side. This is necessary to get the "curvature" of the
315 * path correct.
316 */
317static pointf *mkCtrlPts(int s, int mult, pointf prev, pointf v,
318 pointf nxt, tripoly_t * trip)
319{
320 int idx = ctrlPtIdx(v, &trip->poly);
321 int i;
322 double d, sep, theta, sinTheta, cosTheta;
323 pointf q, w;
324
325 if (idx < 0)
326 return NULL;
327
328 pointf *ps = gv_calloc(mult, sizeof(pointf));
329 theta = bisect(prev, v, nxt);
330 sinTheta = sin(theta);
331 cosTheta = cos(theta);
332 w.x = v.x + 100 * cosTheta;
333 w.y = v.y + 100 * sinTheta;
334 if (idx > s) {
335 if (wind(prev, v, w) != 1) {
336 sinTheta *= -1;
337 cosTheta *= -1;
338 w.x = v.x + 100 * cosTheta;
339 w.y = v.y + 100 * sinTheta;
340 }
341 } else if (wind(prev, v, w) != -1) {
342 sinTheta *= -1;
343 cosTheta *= -1;
344 w.x = v.x + 100 * cosTheta;
345 w.y = v.y + 100 * sinTheta;
346 }
347
348 if (triPoint(trip, idx, v, w, &q)) {
349 return 0;
350 }
351
352 d = DIST(q, v);
353 if (d >= mult * SEP)
354 sep = SEP;
355 else
356 sep = d / mult;
357 if (idx < s) {
358 for (i = 0; i < mult; i++) {
359 ps[i].x = v.x + i * sep * cosTheta;
360 ps[i].y = v.y + i * sep * sinTheta;
361 }
362 } else {
363 for (i = 0; i < mult; i++) {
364 ps[mult - i - 1].x = v.x + i * sep * cosTheta;
365 ps[mult - i - 1].y = v.y + i * sep * sinTheta;
366 }
367 }
368 return ps;
369}
370
371/*
372 * Simple graph structure for recording the triangle graph.
373 */
374
375typedef struct {
376 size_t ne; // no. of edges.
377 int *edges; /* indices of edges adjacent to node. */
378 pointf ctr; /* center of triangle. */
379} tnode;
380
381typedef struct {
382 int t, h; /* indices of head and tail nodes */
383 ipair seg; /* indices of points forming shared segment */
384 double dist; /* length of edge; usually distance between centers */
385} tedge;
386
387typedef struct {
389 size_t nnodes; // number of nodes
391 int nedges; // number of edges
392} tgraph;
393
394struct router_s {
395 int pn; /* no. of points */
396 pointf *ps; /* all points in configuration */
397 int *obs; /* indices in obstacle i are obs[i]...obs[i+1]-1 */
398 int *tris; /* indices of triangle i are tris[3*i]...tris[3*i+2] */
399 Dt_t *trimap; /* map from obstacle side (a,b) to index of adj. triangle */
400 int tn; /* no. of nodes in tg */
401 tgraph *tg; /* graph of triangles */
402};
403
404/* triCenter:
405 * Given an array of points and 3 integer indices,
406 * compute and return the center of the triangle.
407 */
408static pointf triCenter(pointf * pts, int *idxs)
409{
410 pointf a = pts[*idxs++];
411 pointf b = pts[*idxs++];
412 pointf c = pts[*idxs++];
413 pointf p;
414 p.x = (a.x + b.x + c.x) / 3.0;
415 p.y = (a.y + b.y + c.y) / 3.0;
416 return p;
417}
418
419#define MARGIN 32
420
421/* bbox:
422 * Compute bounding box of polygons, and return it
423 * with an added margin of MARGIN.
424 * Store total number of points in *np.
425 */
426static boxf bbox(Ppoly_t** obsp, int npoly, int *np)
427{
428 boxf bb;
429 int i, cnt = 0;
430 pointf p;
431 Ppoly_t* obs;
432
433 bb.LL.x = bb.LL.y = DBL_MAX;
434 bb.UR.x = bb.UR.y = -DBL_MAX;
435
436 for (i = 0; i < npoly; i++) {
437 obs = *obsp++;
438 for (size_t j = 0; j < obs->pn; j++) {
439 p = obs->ps[j];
440 bb.LL.x = fmin(bb.LL.x, p.x);
441 bb.UR.x = fmax(bb.UR.x, p.x);
442 bb.LL.y = fmin(bb.LL.y, p.y);
443 bb.UR.y = fmax(bb.UR.y, p.y);
444 cnt++;
445 }
446 }
447
448 *np = cnt;
449
450 bb.LL.x -= MARGIN;
451 bb.LL.y -= MARGIN;
452 bb.UR.x += MARGIN;
453 bb.UR.y += MARGIN;
454
455 return bb;
456}
457
458static int *mkTriIndices(surface_t * sf)
459{
460 int *tris = gv_calloc(3 * sf->nfaces, sizeof(int));
461 memcpy(tris, sf->faces, 3 * sf->nfaces * sizeof(int));
462 return tris;
463}
464
465/* sharedEdge:
466 * Returns a pair of integer (x,y), x < y, where x and y are the
467 * indices of the two vertices of the shared edge.
468 */
469static ipair sharedEdge(int *p, int *q)
470{
471 ipair pt;
472 int tmp, p1, p2;
473 p1 = *p;
474 p2 = *(p + 1);
475 if (p1 == *q) {
476 if (p2 != *(q + 1) && p2 != *(q + 2)) {
477 p2 = *(p + 2);
478 }
479 } else if (p1 == *(q + 1)) {
480 if (p2 != *q && p2 != *(q + 2)) {
481 p2 = *(p + 2);
482 }
483 } else if (p1 == *(q + 2)) {
484 if (p2 != *q && p2 != *(q + 1)) {
485 p2 = *(p + 2);
486 }
487 } else {
488 p1 = *(p + 2);
489 }
490
491 if (p1 > p2) {
492 tmp = p1;
493 p1 = p2;
494 p2 = tmp;
495 }
496 pt.i = p1;
497 pt.j = p2;
498 return pt;
499}
500
501/* addTriEdge:
502 * Add an edge to g, with tail t, head h, and shared
503 * segment seg.
504 */
505static void addTriEdge(tgraph *g, int t, int h, ipair seg) {
506 g->edges = gv_recalloc(g->edges, g->nedges, g->nedges + 1,
507 sizeof(g->edges[0]));
508 tedge *ep = g->edges + g->nedges;
509 tnode *tp = g->nodes + t;
510 tnode *hp = g->nodes + h;
511
512 ep->t = t;
513 ep->h = h;
514 ep->dist = DIST(tp->ctr, hp->ctr);
515 ep->seg = seg;
516
517 tp->edges = gv_recalloc(tp->edges, tp->ne, tp->ne + 1,
518 sizeof(tp->edges[0]));
519 tp->edges[tp->ne++] = g->nedges;
520 hp->edges = gv_recalloc(hp->edges, hp->ne, hp->ne + 1,
521 sizeof(hp->edges[0]));
522 hp->edges[hp->ne++] = g->nedges;
523
524 g->nedges++;
525}
526
527static void freeTriGraph(tgraph * tg)
528{
529 for (size_t i = 0; i < tg->nnodes; ++i) {
530 free(tg->nodes[i].edges);
531 }
532 free(tg->nodes);
533 free(tg->edges);
534 free(tg);
535}
536
537/* mkTriGraph:
538 * Generate graph with triangles as nodes and an edge iff two triangles
539 * share an edge.
540 */
541static tgraph *mkTriGraph(surface_t *sf, pointf *pts) {
542 tnode *np;
543 int j, i, ne = 0;
544 int *jp;
545
546 /* ne is twice no. of edges */
547 for (i = 0; i < 3 * sf->nfaces; i++)
548 if (sf->neigh[i] != -1)
549 ne++;
550
551 tgraph *g = gv_alloc(sizeof(tgraph));
552
553 /* plus 2 for nodes added as endpoints of an edge */
554 g->nnodes = sf->nfaces + 2;
555 g->nodes = gv_calloc(g->nnodes, sizeof(tnode));
556
557 for (i = 0; i < sf->nfaces; i++) {
558 np = g->nodes + i;
559 np->ctr = triCenter(pts, sf->faces + 3 * i);
560 }
561
562 for (i = 0; i < sf->nfaces; i++) {
563 np = g->nodes + i;
564 jp = sf->neigh + 3 * i;
565 ne = 0;
566 while (ne < 3 && (j = *jp++) != -1) {
567 if (i < j) {
568 ipair seg =
569 sharedEdge(sf->faces + 3 * i, sf->faces + 3 * j);
570 addTriEdge(g, i, j, seg);
571 }
572 ne++;
573 }
574 }
575
576 return g;
577}
578
580{
581 free(rtr->ps);
582 free(rtr->obs);
583 free(rtr->tris);
584 dtclose(rtr->trimap);
585 freeTriGraph(rtr->tg);
586 free(rtr);
587}
588
589router_t *mkRouter(Ppoly_t** obsp, int npoly)
590{
591 router_t *rtr = gv_alloc(sizeof(router_t));
592 Ppoly_t* obs;
593 boxf bb;
594 int npts;
595 surface_t *sf;
596 /* points in obstacle i have indices obsi[i] through obsi[i+1]-1 in pts
597 */
598 int *obsi = gv_calloc(npoly + 1, sizeof(int));
599 int i, ix = 4, six = 0;
600
601 bb = bbox(obsp, npoly, &npts);
602 npts += 4; /* 4 points of bounding box */
603 pointf *pts = gv_calloc(npts, sizeof(pointf)); // all points are stored in pts
604 int *segs = gv_calloc(2 * npts, sizeof(int)); // indices of points forming segments
605
606 /* store bounding box in CCW order */
607 pts[0] = bb.LL;
608 pts[1].x = bb.UR.x;
609 pts[1].y = bb.LL.y;
610 pts[2] = bb.UR;
611 pts[3].x = bb.LL.x;
612 pts[3].y = bb.UR.y;
613 for (i = 1; i <= 4; i++) {
614 segs[six++] = i - 1;
615 if (i < 4)
616 segs[six++] = i;
617 else
618 segs[six++] = 0;
619 }
620
621 /* store obstacles in CW order and generate constraint segments */
622 for (i = 0; i < npoly; i++) {
623 obsi[i] = ix;
624 obs = *obsp++;
625 for (size_t j = 1; j <= obs->pn; j++) {
626 segs[six++] = ix;
627 if (j < obs->pn)
628 segs[six++] = ix + 1;
629 else
630 segs[six++] = obsi[i];
631 pts[ix++] = obs->ps[j - 1];
632 }
633 }
634 obsi[i] = ix;
635
636 /* copy points into coordinate arrays */
637 double *x = gv_calloc(npts, sizeof(double));
638 double *y = gv_calloc(npts, sizeof(double));
639 for (i = 0; i < npts; i++) {
640 x[i] = pts[i].x;
641 y[i] = pts[i].y;
642 }
643 sf = mkSurface(x, y, npts, segs, npts);
644 free(x);
645 free(y);
646 free(segs);
647
648 rtr->ps = pts;
649 rtr->pn = npts;
650 rtr->obs = obsi;
651 rtr->tris = mkTriIndices(sf);
652 rtr->trimap = mapSegToTri(sf);
653 rtr->tn = sf->nfaces;
654 rtr->tg = mkTriGraph(sf, pts);
655
656 freeSurface(sf);
657 return rtr;
658}
659
660/* finishEdge:
661 * Finish edge generation, clipping to nodes and adding arrowhead
662 * if necessary, and adding edge labels
663 */
664static void finishEdge(edge_t* e, Ppoly_t spl, int flip) {
665 if (flip) {
666 for (size_t j = 0; j < spl.pn / 2; j++) {
667 pointf tmp = spl.ps[spl.pn - 1 - j];
668 spl.ps[spl.pn - 1 - j] = spl.ps[j];
669 spl.ps[j] = tmp;
670 }
671 }
672 if (Verbose > 1)
673 fprintf(stderr, "spline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e)));
674 clip_and_install(e, aghead(e), spl.ps, spl.pn, &sinfo);
675
676 addEdgeLabels(e);
677}
678
679#define EQPT(p,q) (((p).x==(q).x)&&((p).y==(q).y))
680
681/* tweakEnd:
682 * Hack because path routing doesn't know about the interiors
683 * of polygons. If the first or last segment of the shortest path
684 * lies along one of the polygon boundaries, the path may flip
685 * inside the polygon. To avoid this, we shift the point a bit.
686 *
687 * If the edge p(=poly.ps[s])-q of the shortest path is also an
688 * edge of the border polygon, move p slightly inside the polygon
689 * and return it. If prv and nxt are the two vertices adjacent to
690 * p in the polygon, let m be the midpoint of prv--nxt. We then
691 * move a tiny bit along the ray p->m.
692 *
693 * Otherwise, return p unchanged.
694 */
696 Ppoint_t prv, nxt, p;
697
698 p = poly.ps[s];
699 nxt = poly.ps[(s + 1) % poly.pn];
700 if (s == 0)
701 prv = poly.ps[poly.pn-1];
702 else
703 prv = poly.ps[s - 1];
704 if (EQPT(q, nxt) || EQPT(q, prv) ){
705 Ppoint_t m;
706 m.x = (nxt.x + prv.x)/2.0 - p.x;
707 m.y = (nxt.y + prv.y)/2.0 - p.y;
708 const double d = hypot(m.x, m.y);
709 p.x += 0.1*m.x/d;
710 p.y += 0.1*m.y/d;
711 }
712 return p;
713}
714
715static void tweakPath(Ppoly_t poly, size_t t, Ppolyline_t pl) {
716 pl.ps[0] = tweakEnd(poly, 0, pl.ps[1]);
717 pl.ps[pl.pn-1] = tweakEnd (poly, t, pl.ps[pl.pn-2]);
718}
719
720
721/* genroute:
722 * Generate splines for e and cohorts.
723 * Edges go from 0 to t.
724 * Return 0 on success.
725 */
726static int genroute(tripoly_t *trip, int t, edge_t *e, int doPolyline) {
727 pointf eps[2];
728 Pvector_t evs[2];
729 pointf **cpts = NULL; /* lists of control points */
731 Ppolyline_t pl, spl;
732 Ppolyline_t mmpl;
733 int mult = ED_count(e);
734 node_t* head = aghead(e);
735 int rv = 0;
736
737 poly.ps = NULL;
738 pl.pn = 0;
739 eps[0].x = trip->poly.ps[0].x, eps[0].y = trip->poly.ps[0].y;
740 eps[1].x = trip->poly.ps[t].x, eps[1].y = trip->poly.ps[t].y;
741 if (Pshortestpath(&(trip->poly), eps, &pl) < 0) {
742 agwarningf("Could not create control points for multiple spline for edge (%s,%s)\n", agnameof(agtail(e)), agnameof(aghead(e)));
743 rv = 1;
744 goto finish;
745 }
746
747 if (pl.pn == 2) {
748 makeStraightEdge(agraphof(head), e, doPolyline, &sinfo);
749 goto finish;
750 }
751
752 evs[0].x = evs[0].y = 0;
753 evs[1].x = evs[1].y = 0;
754
755 if (mult == 1 || Concentrate) {
756 poly = trip->poly;
757 Pedge_t *medges = gv_calloc(poly.pn, sizeof(Pedge_t));
758 for (size_t j = 0; j < poly.pn; j++) {
759 medges[j].a = poly.ps[j];
760 medges[j].b = poly.ps[(j + 1) % poly.pn];
761 }
762 assert(t >= 0);
763 tweakPath(poly, (size_t)t, pl);
764 if (Proutespline(medges, poly.pn, pl, evs, &spl) < 0) {
765 agwarningf("Could not create control points for multiple spline for edge (%s,%s)\n", agnameof(agtail(e)), agnameof(aghead(e)));
766 rv = 1;
767 goto finish;
768 }
769 finishEdge(e, spl, aghead(e) != head);
770 free(medges);
771
772 return 0;
773 }
774
775 const size_t pn = 2 * (pl.pn - 1);
776
777 cpts = gv_calloc(pl.pn - 2, sizeof(pointf *));
778 for (size_t i = 0; i + 2 < pl.pn; i++) {
779 cpts[i] =
780 mkCtrlPts(t, mult+1, pl.ps[i], pl.ps[i + 1], pl.ps[i + 2], trip);
781 if (!cpts[i]) {
782 agwarningf("Could not create control points for multiple spline for edge (%s,%s)\n", agnameof(agtail(e)), agnameof(aghead(e)));
783 rv = 1;
784 goto finish;
785 }
786 }
787
788 poly.ps = gv_calloc(pn, sizeof(pointf));
789 poly.pn = pn;
790
791 for (int i = 0; i < mult; i++) {
792 poly.ps[0] = eps[0];
793 for (size_t j = 1; j + 1 < pl.pn; j++) {
794 poly.ps[j] = cpts[j - 1][i];
795 }
796 poly.ps[pl.pn - 1] = eps[1];
797 for (size_t j = 1; j + 1 < pl.pn; j++) {
798 poly.ps[pn - j] = cpts[j - 1][i + 1];
799 }
800 if (Pshortestpath(&poly, eps, &mmpl) < 0) {
801 agwarningf("Could not create control points for multiple spline for edge (%s,%s)\n", agnameof(agtail(e)), agnameof(aghead(e)));
802 rv = 1;
803 goto finish;
804 }
805
806 if (doPolyline) {
807 make_polyline (mmpl, &spl);
808 }
809 else {
810 Pedge_t *medges = gv_calloc(poly.pn, sizeof(Pedge_t));
811 for (size_t j = 0; j < poly.pn; j++) {
812 medges[j].a = poly.ps[j];
813 medges[j].b = poly.ps[(j + 1) % poly.pn];
814 }
815 tweakPath(poly, pl.pn - 1, mmpl);
816 const bool failed_routing = Proutespline(medges, poly.pn, mmpl, evs, &spl) < 0;
817 free(medges);
818 if (failed_routing) {
819 agwarningf("Could not create control points for multiple spline for edge (%s,%s)\n",
820 agnameof(agtail(e)), agnameof(aghead(e)));
821 rv = 1;
822 goto finish;
823 }
824 }
825 finishEdge(e, spl, aghead(e) != head);
826
827 e = ED_to_virt(e);
828 }
829
830finish :
831 if (cpts) {
832 for (size_t i = 0; i + 2 < pl.pn; i++)
833 free(cpts[i]);
834 free(cpts);
835 }
836 free(poly.ps);
837 return rv;
838}
839
840#define NSMALL -0.0000000001
841
842/* inCone:
843 * Returns true iff q is in the convex cone a-b-c
844 */
845static int
847{
848 return area2(q,a,b) >= NSMALL && area2(q,b,c) >= NSMALL;
849}
850
851static pointf north = {0, 1};
852static pointf northeast = {1, 1};
853static pointf east = {1, 0};
854static pointf southeast = {1, -1};
855static pointf south = {0, -1};
856static pointf southwest = {-1, -1};
857static pointf west = {-1, 0};
858static pointf northwest = {-1, 1};
859
860/* addEndpoint:
861 * Add node to graph representing spline end point p inside obstruction obs_id.
862 * For each side of obstruction, add edge from p to corresponding triangle.
863 * The node id of the new node in the graph is v_id.
864 * If p lies on the side of its node (sides != 0), we limit the triangles
865 * to those within 45 degrees of each side of the natural direction of p.
866 */
867static void addEndpoint(router_t * rtr, pointf p, node_t* v, int v_id, int sides)
868{
869 int obs_id = ND_lim(v);
870 int starti = rtr->obs[obs_id];
871 int endi = rtr->obs[obs_id + 1];
872 pointf* pts = rtr->ps;
873 int i, t;
874 pointf vr, v0, v1;
875
876 switch (sides) {
877 case TOP :
878 vr = add_pointf (p, north);
879 v0 = add_pointf (p, northwest);
880 v1 = add_pointf (p, northeast);
881 break;
882 case TOP|RIGHT :
883 vr = add_pointf (p, northeast);
884 v0 = add_pointf (p, north);
885 v1 = add_pointf (p, east);
886 break;
887 case RIGHT :
888 vr = add_pointf (p, east);
889 v0 = add_pointf (p, northeast);
890 v1 = add_pointf (p, southeast);
891 break;
892 case BOTTOM|RIGHT :
893 vr = add_pointf (p, southeast);
894 v0 = add_pointf (p, east);
895 v1 = add_pointf (p, south);
896 break;
897 case BOTTOM :
898 vr = add_pointf (p, south);
899 v0 = add_pointf (p, southeast);
900 v1 = add_pointf (p, southwest);
901 break;
902 case BOTTOM|LEFT :
903 vr = add_pointf (p, southwest);
904 v0 = add_pointf (p, south);
905 v1 = add_pointf (p, west);
906 break;
907 case LEFT :
908 vr = add_pointf (p, west);
909 v0 = add_pointf (p, southwest);
910 v1 = add_pointf (p, northwest);
911 break;
912 case TOP|LEFT :
913 vr = add_pointf (p, northwest);
914 v0 = add_pointf (p, west);
915 v1 = add_pointf (p, north);
916 break;
917 case 0 :
918 break;
919 default :
920 assert (0);
921 break;
922 }
923
924 rtr->tg->nodes[v_id].ne = 0;
925 rtr->tg->nodes[v_id].ctr = p;
926 for (i = starti; i < endi; i++) {
927 ipair seg;
928 seg.i = i;
929 if (i < endi - 1)
930 seg.j = i + 1;
931 else
932 seg.j = starti;
933 t = findMap(rtr->trimap, seg.i, seg.j);
934 if (sides && !inCone (v0, p, v1, pts[seg.i]) && !inCone (v0, p, v1, pts[seg.j]) && !raySeg(p,vr,pts[seg.i],pts[seg.j]))
935 continue;
936 addTriEdge(rtr->tg, v_id, t, seg);
937 }
938 assert(rtr->tg->nodes[v_id].ne > 0 && "no edges were added");
939}
940
941/* edgeToSeg:
942 * Given edge from i to j, find segment associated
943 * with the edge.
944 *
945 * This lookup could be made faster by modifying the
946 * shortest path algorithm to store the edges rather than
947 * the nodes.
948 */
949static ipair edgeToSeg(tgraph * tg, int i, int j)
950{
951 ipair ip = {0, 0};
952 tnode *np = tg->nodes + i;
953 tedge *ep;
954
955 for (size_t k = 0; k < np->ne; k++) {
956 ep = tg->edges + np->edges[k];
957 if (ep->t == j || ep->h == j)
958 return ep->seg;
959 }
960
961 assert(0);
962 return ip;
963}
964
965static void
967{
968 tri* tp;
969 tri* nxt;
970
971 free (trip->poly.ps);
972 for (size_t i = 0; i < trip->poly.pn; i++) {
973 for (tp = trip->triMap[i]; tp; tp = nxt) {
974 nxt = tp->nxttri;
975 free (tp);
976 }
977 }
978 free (trip->triMap);
979 free (trip);
980}
981
982/* Auxiliary data structure used to translate a path of rectangles
983 * into a polygon. Each side_t represents a vertex on one side of
984 * the polygon. v is the index of the vertex in the global router_t,
985 * and ts is a linked list of the indices of segments of sides opposite
986 * to v in some triangle on the path. These lists will be translated
987 * to polygon indices by mapTri, and stored in tripoly_t.triMap.
988 */
989typedef struct {
990 int v;
992} side_t;
993
994/* mkPoly:
995 * Construct simple polygon from shortest path from t to s in g.
996 * dad gives the indices of the triangles on path.
997 * sx used to store index of s in points.
998 * index of t is always 0
999 */
1000static tripoly_t *mkPoly(router_t * rtr, int *dad, int s, int t,
1001 pointf p_s, pointf p_t, int *sx)
1002{
1003 tripoly_t *ps;
1004 int nxt;
1005 ipair p;
1006 size_t nt = 0;
1007 int idx;
1008 int cnt1 = 0;
1009 int cnt2 = 0;
1010 pointf *pts;
1011 /* maps vertex index used in router_t to vertex index used in tripoly */
1012 Dt_t *vmap;
1013
1014 /* count number of triangles in path */
1015 for (nxt = dad[t]; nxt != s; nxt = dad[nxt]) {
1016 nt++;
1017 assert (nxt != dad[nxt] && "infinite loop due to 'nxt' not changing");
1018 }
1019
1020 side_t *side1 = gv_calloc(nt + 4, sizeof(side_t));
1021 side_t *side2 = gv_calloc(nt + 4, sizeof(side_t));
1022
1023 nxt = dad[t];
1024 p = edgeToSeg(rtr->tg, nxt, t);
1025 side1[cnt1].ts = addTri(-1, p.j, NULL);
1026 side1[cnt1++].v = p.i;
1027 side2[cnt2].ts = addTri(-1, p.i, NULL);
1028 side2[cnt2++].v = p.j;
1029
1030 t = nxt;
1031 for (nxt = dad[t]; nxt >= 0; nxt = dad[nxt]) {
1032 p = edgeToSeg(rtr->tg, t, nxt);
1033 if (p.i == side1[cnt1 - 1].v) {
1034 side1[cnt1 - 1].ts =
1035 addTri(side2[cnt2 - 1].v, p.j, side1[cnt1 - 1].ts);
1036 side2[cnt2 - 1].ts =
1037 addTri(side1[cnt1 - 1].v, p.j, side2[cnt2 - 1].ts);
1038 side2[cnt2].ts =
1039 addTri(side2[cnt2 - 1].v, side1[cnt1 - 1].v, NULL);
1040 side2[cnt2++].v = p.j;
1041 } else if (p.i == side2[cnt2 - 1].v) {
1042 side1[cnt1 - 1].ts =
1043 addTri(side2[cnt2 - 1].v, p.j, side1[cnt1 - 1].ts);
1044 side2[cnt2 - 1].ts =
1045 addTri(side1[cnt1 - 1].v, p.j, side2[cnt2 - 1].ts);
1046 side1[cnt1].ts =
1047 addTri(side2[cnt2 - 1].v, side1[cnt1 - 1].v, NULL);
1048 side1[cnt1++].v = p.j;
1049 } else if (p.j == side1[cnt1 - 1].v) {
1050 side1[cnt1 - 1].ts =
1051 addTri(side2[cnt2 - 1].v, p.i, side1[cnt1 - 1].ts);
1052 side2[cnt2 - 1].ts =
1053 addTri(side1[cnt1 - 1].v, p.i, side2[cnt2 - 1].ts);
1054 side2[cnt2].ts =
1055 addTri(side2[cnt2 - 1].v, side1[cnt1 - 1].v, NULL);
1056 side2[cnt2++].v = p.i;
1057 } else {
1058 side1[cnt1 - 1].ts =
1059 addTri(side2[cnt2 - 1].v, p.i, side1[cnt1 - 1].ts);
1060 side2[cnt2 - 1].ts =
1061 addTri(side1[cnt1 - 1].v, p.i, side2[cnt2 - 1].ts);
1062 side1[cnt1].ts =
1063 addTri(side2[cnt2 - 1].v, side1[cnt1 - 1].v, NULL);
1064 side1[cnt1++].v = p.i;
1065 }
1066 t = nxt;
1067 }
1068 side1[cnt1 - 1].ts = addTri(-2, side2[cnt2 - 1].v, side1[cnt1 - 1].ts);
1069 side2[cnt2 - 1].ts = addTri(-2, side1[cnt1 - 1].v, side2[cnt2 - 1].ts);
1070
1071 /* store points in pts starting with t in 0,
1072 * then side1, then s, then side2
1073 */
1074 vmap = dtopen(&ipairdisc, Dtoset);
1075 vmapAdd(vmap, -1, 0);
1076 vmapAdd(vmap, -2, cnt1 + 1);
1077 pointf *pps = pts = gv_calloc(nt + 4, sizeof(pointf));
1078 tri **trim = gv_calloc(nt + 4, sizeof(tri*));
1079 *pps++ = p_t;
1080 idx = 1;
1081 for (int i = 0; i < cnt1; i++) {
1082 vmapAdd(vmap, side1[i].v, idx);
1083 *pps++ = rtr->ps[side1[i].v];
1084 trim[idx++] = side1[i].ts;
1085 }
1086 *pps++ = p_s;
1087 idx++;
1088 for (int i = cnt2 - 1; i >= 0; i--) {
1089 vmapAdd(vmap, side2[i].v, idx);
1090 *pps++ = rtr->ps[side2[i].v];
1091 trim[idx++] = side2[i].ts;
1092 }
1093
1094 for (size_t i = 0; i < nt + 4; i++) {
1095 mapTri(vmap, trim[i]);
1096 }
1097
1098 ps = gv_alloc(sizeof(tripoly_t));
1099 ps->poly.pn = nt + 4; /* nt triangles gives nt+2 points plus s and t */
1100 ps->poly.ps = pts;
1101 ps->triMap = trim;
1102
1103 free (side1);
1104 free (side2);
1105 dtclose(vmap);
1106 *sx = cnt1 + 1; /* index of s in ps */
1107 return ps;
1108}
1109
1110/* resetGraph:
1111 * Remove edges and nodes added for current edge routing
1112 */
1113static void resetGraph(tgraph *g, int ncnt, int ecnt,
1114 size_t *original_edge_count) {
1115 int i;
1116 tnode *np = g->nodes;
1117 g->nedges = ecnt;
1118 for (i = 0; i < ncnt; i++) {
1119 np->ne = original_edge_count[i];
1120 np++;
1121 }
1122}
1123
1124#define PQTYPE int
1125#define PQVTYPE float
1126
1127#define PQ_TYPES
1128#include <neatogen/fPQ.h>
1129#undef PQ_TYPES
1130
1131typedef struct {
1132 PQ pq;
1134 int *idxs;
1135} PPQ;
1136
1137#define N_VAL(pq,n) ((PPQ*)pq)->vals[n]
1138#define N_IDX(pq,n) ((PPQ*)pq)->idxs[n]
1139
1140#define PQ_CODE
1141#include <neatogen/fPQ.h>
1142#undef PQ_CODE
1143
1144#define N_DAD(n) dad[n]
1145#define E_WT(e) (e->dist)
1146#define UNSEEN (-FLT_MAX)
1147
1148/* triPath:
1149 * Find the shortest path with lengths in g from
1150 * v0 to v1. The returned vector (dad) encodes the
1151 * shorted path from v1 to v0. That path is given by
1152 * v1, dad[v1], dad[dad[v1]], ..., v0.
1153 */
1154static int *
1155triPath(tgraph * g, int n, int v0, int v1, PQ * pq)
1156{
1157 int i, adjn;
1158 double d;
1159 tnode *np;
1160 tedge *e;
1161 int *dad = gv_calloc(n, sizeof(int));
1162
1163 for (i = 0; i < pq->PQsize; i++)
1164 N_VAL(pq, i) = UNSEEN;
1165
1166 PQinit(pq);
1167 N_DAD(v0) = -1;
1168 N_VAL(pq, v0) = 0;
1169 if (PQinsert(pq, v0))
1170 return NULL;
1171
1172 while ((i = PQremove(pq)) != -1) {
1173 N_VAL(pq, i) *= -1;
1174 if (i == v1)
1175 break;
1176 np = g->nodes + i;
1177 for (size_t j = 0; j < np->ne; j++) {
1178 e = g->edges + np->edges[j];
1179 if (e->t == i)
1180 adjn = e->h;
1181 else
1182 adjn = e->t;
1183 if (N_VAL(pq, adjn) < 0) {
1184 d = -(N_VAL(pq, i) + E_WT(e));
1185 if (N_VAL(pq, adjn) == UNSEEN) {
1186 N_VAL(pq, adjn) = d;
1187 N_DAD(adjn) = i;
1188 if (PQinsert(pq, adjn)) {
1189 free(dad);
1190 return NULL;
1191 }
1192 } else if (N_VAL(pq, adjn) < d) {
1193 PQupdate(pq, adjn, d);
1194 N_DAD(adjn) = i;
1195 }
1196 }
1197 }
1198 }
1199 return dad;
1200}
1201
1202/* makeMultiSpline:
1203 * FIX: we don't really use the shortest path provided by ED_path,
1204 * so avoid in neato spline code.
1205 * Return 0 on success.
1206 */
1207int makeMultiSpline(edge_t* e, router_t * rtr, int doPolyline) {
1208 Ppolyline_t line = ED_path(e);
1209 node_t *t = agtail(e);
1210 node_t *h = aghead(e);
1211 pointf t_p = line.ps[0];
1212 pointf h_p = line.ps[line.pn - 1];
1213 tripoly_t *poly;
1214 int idx;
1215 int *sp;
1216 int t_id = rtr->tn;
1217 int h_id = rtr->tn + 1;
1218 int ecnt = rtr->tg->nedges;
1219 PPQ pq;
1220 int ret;
1221
1222 // record the number of edges in each node, so we can drop the added ones
1223 // later
1224 size_t *original_edge_count = gv_calloc(rtr->tg->nnodes,
1225 sizeof(original_edge_count[0]));
1226 for (size_t i = 0; i < rtr->tg->nnodes; ++i)
1227 original_edge_count[i] = rtr->tg->nodes[i].ne;
1228
1229 /* Add endpoints to triangle graph */
1230 addEndpoint(rtr, t_p, t, t_id, ED_tail_port(e).side);
1231 addEndpoint(rtr, h_p, h, h_id, ED_head_port(e).side);
1232
1233 /* Initialize priority queue */
1234 PQgen(&pq.pq, rtr->tn + 2, -1);
1235 PQTYPE *idxs = gv_calloc(pq.pq.PQsize + 1, sizeof(PQTYPE));
1236 PQVTYPE *vals = gv_calloc(pq.pq.PQsize + 1, sizeof(PQVTYPE));
1237 vals[0] = 0;
1238 pq.vals = vals + 1;
1239 pq.idxs = idxs + 1;
1240
1241 /* Find shortest path of triangles */
1242 sp = triPath(rtr->tg, rtr->tn+2, h_id, t_id, (PQ *) & pq);
1243
1244 free(vals);
1245 free(idxs);
1246 PQfree(&(pq.pq), 0);
1247
1248 /* Use path of triangles to generate guiding polygon */
1249 if (sp) {
1250 poly = mkPoly(rtr, sp, h_id, t_id, h_p, t_p, &idx);
1251 free(sp);
1252
1253 /* Generate multiple splines using polygon */
1254 ret = genroute(poly, idx, e, doPolyline);
1255 freeTripoly (poly);
1256 }
1257 else ret = -1;
1258
1259 resetGraph(rtr->tg, rtr->tn, ecnt, original_edge_count);
1260 free(original_edge_count);
1261 return ret;
1262}
Memory allocation wrappers that exit on failure.
static void * gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
Definition alloc.h:73
static void * gv_calloc(size_t nmemb, size_t size)
Definition alloc.h:26
static void * gv_alloc(size_t size)
Definition alloc.h:47
#define dtmatch(d, o)
Definition cdt.h:184
#define dtsearch(d, o)
Definition cdt.h:183
#define dtinsert(d, o)
Definition cdt.h:185
CDT_API int dtclose(Dt_t *)
Definition dtclose.c:8
CDT_API Dtmethod_t * Dtoset
ordered set (self-adjusting tree)
Definition dttree.c:304
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
Definition dtopen.c:9
#define LEFT
Definition const.h:120
#define RIGHT
Definition const.h:118
#define BOTTOM
Definition const.h:117
#define TOP
Definition const.h:119
surface_t * mkSurface(double *x, double *y, int n, int *segs, int nsegs)
Definition delaunay.c:724
void freeSurface(surface_t *s)
Definition delaunay.c:730
#define head
Definition dthdr.h:15
static Dtdisc_t disc
Definition exparse.y:209
void PQinit(void)
Definition fPQ.c:44
void PQgen(int sz)
Definition fPQ.c:25
void PQfree(void)
Definition fPQ.c:36
snode * PQremove(void)
Definition fPQ.c:121
void PQupdate(snode *n, int d)
Definition fPQ.c:137
int line_intersect(pointf a, pointf b, pointf c, pointf d, pointf *p)
Definition geom.c:235
#define DIST(p, q)
Definition geom.h:62
static pointf add_pointf(pointf p, pointf q)
Definition geomprocs.h:63
bool Concentrate
Definition globals.h:58
static bool Verbose
Definition gml2gv.c:23
void free(void *)
node NULL
Definition grammar.y:163
static int cnt(Dict_t *d, Dtlink_t **set)
Definition graph.c:210
#define ED_count(e)
Definition types.h:580
#define agtail(e)
Definition cgraph.h:880
#define ED_path(e)
Definition types.h:593
#define aghead(e)
Definition cgraph.h:881
#define ED_head_port(e)
Definition types.h:588
#define ED_tail_port(e)
Definition types.h:597
#define ED_to_virt(e)
Definition types.h:599
void agwarningf(const char *fmt,...)
Definition agerror.c:173
#define ND_lim(n)
Definition types.h:504
Agraph_t * agraphof(void *obj)
Definition obj.c:185
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:158
void PQinsert(pq_t *pq, Halfedge *he, Site *v, double offset)
Definition heap.c:54
$2 u p prev
Definition htmlparse.y:297
static int * ps
Definition lu.c:51
static tripoly_t * mkPoly(router_t *rtr, int *dad, int s, int t, pointf p_s, pointf p_t, int *sx)
static int findMap(Dt_t *map, int a, int b)
static void addMap(Dt_t *map, int a, int b, int t)
Definition multispline.c:95
static tgraph * mkTriGraph(surface_t *sf, pointf *pts)
static pointf southwest
static void mapTri(Dt_t *map, tri *tp)
#define PQVTYPE
router_t * mkRouter(Ppoly_t **obsp, int npoly)
static pointf northwest
static ipair sharedEdge(int *p, int *q)
struct _tri tri
static int raySegIntersect(pointf v, pointf w, pointf a, pointf b, pointf *p)
static int * mkTriIndices(surface_t *sf)
static bool swap_ends_p(edge_t *e)
Definition multispline.c:28
static bool spline_merge(node_t *n)
Definition multispline.c:22
void freeRouter(router_t *rtr)
static void addTriEdge(tgraph *g, int t, int h, ipair seg)
#define N_DAD(n)
static int vMap(Dt_t *map, int i)
static void finishEdge(edge_t *e, Ppoly_t spl, int flip)
static pointf east
static int inCone(pointf a, pointf b, pointf c, pointf q)
static void * newIpair(void *p, Dtdisc_t *disc)
static int cmpItem(void *item1, void *item2)
Definition multispline.c:62
static void resetGraph(tgraph *g, int ncnt, int ecnt, size_t *original_edge_count)
int makeMultiSpline(edge_t *e, router_t *rtr, int doPolyline)
static pointf * mkCtrlPts(int s, int mult, pointf prev, pointf v, pointf nxt, tripoly_t *trip)
static ipair edgeToSeg(tgraph *tg, int i, int j)
static void * newItem(void *p, Dtdisc_t *disc)
Definition multispline.c:74
static tri * addTri(int i, int j, tri *oldp)
static void tweakPath(Ppoly_t poly, size_t t, Ppolyline_t pl)
#define NSMALL
static int genroute(tripoly_t *trip, int t, edge_t *e, int doPolyline)
static pointf triCenter(pointf *pts, int *idxs)
static pointf northeast
static Ppoint_t tweakEnd(Ppoly_t poly, size_t s, Ppoint_t q)
#define SEP
static pointf west
static int * triPath(tgraph *g, int n, int v0, int v1, PQ *pq)
#define E_WT(e)
static Dtdisc_t itemdisc
Definition multispline.c:86
static int cmpIpair(void *pair1, void *pair2)
static int raySeg(pointf v, pointf w, pointf a, pointf b)
static pointf southeast
#define UNSEEN
#define MARGIN
static pointf north
static Dt_t * mapSegToTri(surface_t *sf)
static Dtdisc_t ipairdisc
#define N_VAL(pq, n)
static splineInfo sinfo
Definition multispline.c:34
static void freeTriGraph(tgraph *tg)
static int triPoint(tripoly_t *trip, int vx, pointf v, pointf w, pointf *ip)
static int ctrlPtIdx(pointf v, Ppoly_t *polys)
static boxf bbox(Ppoly_t **obsp, int npoly, int *np)
static pointf south
static void vmapAdd(Dt_t *map, int i, int j)
static void addEndpoint(router_t *rtr, pointf p, node_t *v, int v_id, int sides)
#define PQTYPE
static double bisect(pointf pp, pointf cp, pointf np)
#define EQPT(p, q)
static void freeTripoly(tripoly_t *trip)
void make_polyline(Ppolyline_t line, Ppolyline_t *sline)
Definition util.c:59
int Proutespline(Pedge_t *barriers, size_t n_barriers, Ppolyline_t input_route, Pvector_t endpoint_slopes[2], Ppolyline_t *output_route)
Definition route.c:69
int Pshortestpath(Ppoly_t *boundary, Ppoint_t endpoints[2], Ppolyline_t *output_route)
Definition shortest.c:83
PATHUTIL_API int wind(Ppoint_t a, Ppoint_t b, Ppoint_t c)
Definition visibility.c:53
PATHUTIL_API COORD area2(Ppoint_t, Ppoint_t, Ppoint_t)
Definition visibility.c:44
void clip_and_install(edge_t *fe, node_t *hn, pointf *ps, size_t pn, splineInfo *info)
Definition splines.c:238
void makeStraightEdge(graph_t *g, edge_t *e, int edgetype, splineInfo *info)
Definition routespl.c:934
void addEdgeLabels(edge_t *e)
Definition splines.c:1328
static triangles_t tris
Definition shortest.c:55
Dtlink_t link
PQVTYPE * vals
int * idxs
Ppoint_t b
Definition pathgeom.h:53
Ppoint_t a
Definition pathgeom.h:53
size_t pn
Definition pathgeom.h:47
Ppoint_t * ps
Definition pathgeom.h:46
double x
Definition pathgeom.h:38
double y
Definition pathgeom.h:38
struct _tri * nxttri
Definition multispline.c:43
ipair v
Definition multispline.c:42
Definition geom.h:41
pointf UR
Definition geom.h:41
pointf LL
Definition geom.h:41
Definition cdt.h:100
int key
Definition cdt.h:85
int i
Definition multispline.c:38
int j
Definition multispline.c:38
Definition utils.c:747
node_t * t
Definition utils.c:750
int a[2]
Definition multispline.c:58
int t
Definition multispline.c:59
double x
Definition geom.h:29
double y
Definition geom.h:29
Definition heap.c:19
tgraph * tg
pointf * ps
Dt_t * trimap
int * tris
int * obs
tri * ts
bool(* swapEnds)(edge_t *e)
Definition types.h:67
int * faces
Definition delaunay.h:19
int nfaces
Definition delaunay.h:18
int * neigh
Definition delaunay.h:20
ipair seg
double dist
tnode * nodes
int nedges
size_t nnodes
tedge * edges
size_t ne
int * edges
pointf ctr
tri ** triMap
Definition multispline.c:48
Ppoly_t poly
Definition multispline.c:47
struct poly_s poly
Definition grammar.c:93