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