34 static boolean spline_merge(
node_t * n)
39 static boolean swap_ends_p(
edge_t * e)
44 static splineInfo sinfo = { swap_ends_p, spline_merge };
47 make_barriers(
Ppoly_t ** poly,
int npoly,
int pp,
int qp,
48 Pedge_t ** barriers,
int *n_barriers)
54 for (i = 0; i < npoly; i++) {
63 for (i = 0; i < npoly; i++) {
68 for (j = 0; j < poly[i]->
pn; j++) {
72 bar[b].
a = poly[i]->
ps[j];
73 bar[b].
b = poly[i]->
ps[k];
100 p.
x = (x * m->
x) + c.
x;
101 p.
y = (y * m->
y) + c.
y;
140 if (key1->
n1 > key2->
n1)
142 if (key1->
n1 < key2->
n1)
144 if (key1->
n2 > key2->
n2)
146 if (key1->
n2 < key2->
n2)
149 if ((x = key1->
p1.
x - key2->
p1.
x))
151 if ((x = key1->
p1.
y - key2->
p1.
y))
153 if ((x = key1->
p2.
x - key2->
p2.
x))
155 return (key1->
p2.
y - key2->
p2.
y);
199 }
else if (tp.
x > hp.
x) {
202 }
else if (tp.
y < hp.
y) {
205 }
else if (tp.
y > hp.
y) {
209 test.
p1 = test.
p2 = tp;
240 for (i = 0; i < cnt; i++) {
245 for (i = 0; i < cnt; i++) {
293 margin.
x = margin.
y = 0;
317 else if (poly->
sides >= 3) {
321 margin.
x = pmargin->
x;
322 margin.
y = pmargin->
y;
331 for (j = 0; j < sides; j++) {
332 double xmargin = 0.0, ymargin = 0.0;
334 if (pmargin->
doAdd) {
354 polyp.
x = verts[j].
x + xmargin;
355 polyp.
y = verts[j].
y + ymargin;
358 double h =
LEN(verts[j].x,verts[j].y);
359 polyp.
x = verts[j].
x * (1.0 + margin.
x/h);
360 polyp.
y = verts[j].
y * (1.0 + margin.
y/h);
364 polyp.
x = verts[j].
x * margin.
x;
365 polyp.
y = verts[j].
y * margin.
y;
369 c = cos(2.0 *
M_PI * j / sides + adj);
370 s = sin(2.0 *
M_PI * j / sides + adj);
371 if (pmargin->
doAdd) {
373 polyp.
y = s*(
ND_ht(n)+pmargin->
y) / 2.0;
377 polyp.
y = pmargin->
y * s *
ND_ht(n) / 2.0;
392 if (pmargin->
doAdd) {
393 obs->
ps[0] = genPt(b.
LL.
x-pmargin->
x, b.
LL.
y-pmargin->
y, pt);
394 obs->
ps[1] = genPt(b.
LL.
x-pmargin->
x, b.
UR.
y+pmargin->
y, pt);
395 obs->
ps[2] = genPt(b.
UR.
x+pmargin->
x, b.
UR.
y+pmargin->
y, pt);
396 obs->
ps[3] = genPt(b.
UR.
x+pmargin->
x, b.
LL.
y-pmargin->
y, pt);
399 obs->
ps[0] = recPt(b.
LL.
x, b.
LL.
y, pt, pmargin);
400 obs->
ps[1] = recPt(b.
LL.
x, b.
UR.
y, pt, pmargin);
401 obs->
ps[2] = recPt(b.
UR.
x, b.
UR.
y, pt, pmargin);
402 obs->
ps[3] = recPt(b.
UR.
x, b.
LL.
y, pt, pmargin);
412 if (pmargin->
doAdd) {
413 obs->
ps[0] = genPt(-
ND_lw(n)-pmargin->
x, -
ND_ht(n)-pmargin->
y,pt);
466 Pobspath(vconfig, p, pp, q, qp, &line);
479 q0 = line.
ps[line.
pn - 1];
508 q = line.
ps[line.
pn - 1];
512 for (i = 0; i < npoly; i++) {
519 make_barriers(obs, npoly, pp, qp, &barriers, &n_barriers);
520 slopes[0].
x = slopes[0].
y = 0.0;
521 slopes[1].
x = slopes[1].
y = 0.0;
522 if (
Proutespline(barriers, n_barriers, line, slopes, &spline) < 0) {
536 #define BOUNDARY_PORT(e) ((ED_tail_port(e).side)||(ED_head_port(e).side))
555 int cnt, i = 0, npoly;
558 int useEdges = (
Nop > 1);
587 agerr(
AGWARN,
"the bounding boxes of some nodes touch - falling back to straight line edges\n");
589 agerr(
AGWARN,
"some nodes with margin (%.02f,%.02f) touch - falling back to straight line edges\n", pmargin->
x, pmargin->
y);
595 fprintf(stderr,
"Creating edges using %s\n",
596 (legal && (edgetype ==
ET_ORTHO)) ?
"orthogonal lines" :
597 (vconfig ? (edgetype ==
ET_SPLINE ?
"splines" :
"polylines") :
608 else if (legal && (edgetype ==
ET_ORTHO)) {
619 if (useEdges &&
ED_spl(e)) {
624 else if (
ED_count(e) == 0)
continue;
625 else if (n == head) {
631 }
else if (vconfig) {
639 if (!rtr) rtr =
mkRouter (obs, npoly);
652 for (i = 0; i < cnt; i++) {
677 for (i=0; i < npoly; i++) {
726 edge_t *leader = equivEdge(map, e);
737 if (edgefn(g, &margin, edgetype))
774 agerr (
AGWARN,
"Orthogonal edges not yet supported\n");
791 shiftClusters (
GD_clust(g)[i], offset);
794 GD_bb(g).UR.x -= offset.
x;
795 GD_bb(g).UR.y -= offset.
y;
796 GD_bb(g).LL.x -= offset.
x;
797 GD_bb(g).LL.y -= offset.
y;
817 shiftClusters (g,
GD_bb(g).LL);
825 static void scaleEdge(
edge_t * e,
double xf,
double yf)
838 for (i = 0; i <
ED_spl(e)->size; i++) {
840 for (j = 0; j < bez->size; j++) {
841 if ((i == 0) && (j == 0)) {
845 else if ((i ==
ED_spl(e)->size-1) && (j == bez->size-1)) {
883 static void scaleBB(
graph_t * g,
double xf,
double yf)
912 for (i = 0; i <
ED_spl(e)->size; i++) {
914 for (j = 0; j < bez->
size; j++) {
920 bez->
sp.
x -= offset.
x;
921 bez->
sp.
y -= offset.
y;
924 bez->
ep.
x -= offset.
x;
925 bez->
ep.
y -= offset.
y;
954 GD_bb(g).UR.x -= offset.
x;
955 GD_bb(g).UR.y -= offset.
y;
956 GD_bb(g).LL.x -= offset.
x;
957 GD_bb(g).LL.y -= offset.
y;
1002 static boolean _neato_set_aspect(
graph_t * g)
1004 double xf, yf, actual, desired;
1006 boolean translated =
FALSE;
1019 double t =
GD_bb(g).UR.x;
1026 return (translated ||
FALSE);
1030 if ((xf < 1.0) || (yf < 1.0)) {
1041 return (translated ||
FALSE);
1044 if ((xf > 1.0) && (yf > 1.0)) {
1045 double scale =
MIN(xf, yf);
1048 return (translated ||
FALSE);
1052 if (actual < desired) {
1053 yf = desired / actual;
1056 xf = actual / desired;
1060 return (translated ||
FALSE);
1072 scaleEdge(e, xf, yf);
1099 boolean moved =
FALSE;
1102 moved = _neato_set_aspect(g);
int(* Dtcompar_f)(Dt_t *, void *, void *, Dtdisc_t *)
CDT_API int dtclose(Dt_t *)
void makeSpline(graph_t *, edge_t *, Ppoly_t **, int, boolean)
void *(* Dtmake_f)(Dt_t *, void *, Dtdisc_t *)
shape_kind shapeOf(node_t *)
CDT_API Dtmethod_t * Dtoset
int Proutespline(Pedge_t *barriers, int n_barriers, Ppolyline_t input_route, Pvector_t endpoint_slopes[2], Ppolyline_t *output_route)
void make_polyline(Ppolyline_t line, Ppolyline_t *sline)
void clip_and_install(edge_t *fe, node_t *hn, pointf *ps, int pn, splineInfo *info)
int agerr(agerrlevel_t level, const char *fmt,...)
router_t * mkRouter(Ppoly_t **obsp, int npoly)
int splineEdges(graph_t *, int(*edgefn)(graph_t *, expand_t *, int), int)
CGRAPH_API Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
int makeMultiSpline(graph_t *g, edge_t *e, router_t *rtr, int doPolyline)
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
#define PS2INCH(a_points)
CGRAPH_API Agraph_t * agraphof(void *obj)
int Plegal_arrangement(Ppoly_t **polys, int n_polys)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
void addEdgeLabels(graph_t *g, edge_t *e, pointf rp, pointf rq)
void spline_edges0(Agraph_t *, boolean)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Ppolyline_t getPath(edge_t *, vconfig_t *, int, Ppoly_t **, int)
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
int in_poly(Ppoly_t argpoly, Ppoint_t q)
CGRAPH_API char * agnameof(void *)
vconfig_t * Pobsopen(Ppoly_t **obs, int n_obs)
void spline_edges(Agraph_t *)
void Pobsclose(vconfig_t *config)
void makePortLabels(edge_t *e)
void compute_bb(graph_t *g)
expand_t esepFactor(graph_t *g)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
EXTERN unsigned char Concentrate
EXTERN unsigned char Verbose
Ppoly_t * makeObstacle(node_t *n, expand_t *, boolean)
void makeSelfEdge(path *P, edge_t *edges[], int ind, int cnt, double sizex, double sizey, splineInfo *sinfo)
CGRAPH_API int agnnodes(Agraph_t *g)
void makeStraightEdge(graph_t *g, edge_t *e, int edgetype, splineInfo *info)
void updateBB(graph_t *g, textlabel_t *lp)
void neato_translate(Agraph_t *g)
int Pobspath(vconfig_t *config, Ppoint_t p0, int poly0, Ppoint_t p1, int poly1, Ppolyline_t *output_route)
void(* Dtfree_f)(Dt_t *, void *, Dtdisc_t *)
boxf polyBB(polygon_t *poly)
void resolvePorts(edge_t *e)
void makeSelfArcs(path *P, edge_t *e, int stepx)
int spline_edges1(graph_t *g, int)
CGRAPH_API Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
void freeRouter(router_t *rtr)
void printvis(vconfig_t *cp)
boolean neato_set_aspect(graph_t *g)