46 Pedge_t **barriers,
size_t *n_barriers) {
50 for (i = 0; i < npoly; i++) {
59 for (i = 0; i < npoly; i++) {
64 for (j = 0; j < (int)
poly[i]->pn; j++) {
66 if (k >= (
int)
poly[i]->pn)
68 bar[b].
a =
poly[i]->ps[j];
69 bar[b].
b =
poly[i]->ps[k];
124 if (key1->
n1 > key2->
n1)
126 if (key1->
n1 < key2->
n1)
128 if (key1->
n2 > key2->
n2)
130 if (key1->
n2 < key2->
n2)
133 if (key1->
p1.
x > key2->
p1.
x)
135 if (key1->
p1.
x < key2->
p1.
x)
137 if (key1->
p1.
y > key2->
p1.
y)
139 if (key1->
p1.
y < key2->
p1.
y)
141 if (key1->
p2.
x > key2->
p2.
x)
143 if (key1->
p2.
x < key2->
p2.
x)
145 if (key1->
p2.
y > key2->
p2.
y)
147 if (key1->
p2.
y < key2->
p2.
y)
190 }
else if (tp.
x > hp.
x) {
193 }
else if (tp.
y < hp.
y) {
196 }
else if (tp.
y > hp.
y) {
200 test.
p1 = test.
p2 = tp;
229 }
else if (
cnt > 1) {
231 for (
size_t i = 0; i <
cnt; i++) {
236 for (
size_t i = 0; i <
cnt; i++) {
272 "cannot handle ellipse tangent slope in horizontal extreme point");
273 const double sign_y = p.
y >= 0 ? 1 : -1;
274 const double m = -sign_y * (b * p.
x) / (a * sqrt(a * a - p.
x * p.
x));
275 assert(isfinite(m) &&
"ellipse tangent slope is infinite");
287 (l0.
m * l0.
p.
x - l0.
p.
y - l1.
m * l1.
p.
x + l1.
p.
y) / (l0.
m - l1.
m);
288 const double y = l0.
p.
y + l0.
m * (x - l0.
p.
x);
303 const double angle0 = 2.0 *
M_PI * ((double)i - 0.5) / (double)nsides;
304 const double angle1 = 2.0 *
M_PI * ((double)i + 0.5) / (double)nsides;
305 const pointf p0 = {a * cos(angle0), b * sin(angle0)};
306 const pointf p1 = {a * cos(angle1), b * sin(angle1)};
309 const linef line0 = {{p0.
x, p0.
y}, m0};
310 const linef line1 = {{p1.
x, p1.
y}, m1};
353 if (
poly->option.fixedshape) {
365 const double outline_lw =
ND_lw(n) * outline_width / width;
368 p.
y = -outline_ht / 2.0;
372 p.
y = outline_ht / 2.0;
378 else if (
poly->sides >= 3) {
384 const size_t extra_peripheries =
poly->peripheries >= 1 &&
penwidth > 0.0 ? 1 : 0;
385 const size_t outline_periphery =
poly->peripheries + extra_peripheries;
386 const size_t vertices_offset = outline_periphery >= 1 ? (outline_periphery - 1) * sides : 0;
387 verts =
poly->vertices + vertices_offset;
388 margin.
x = pmargin->
x;
389 margin.
y = pmargin->
y;
397 for (
size_t j = 0; j < sides; j++) {
398 double xmargin = 0.0, ymargin = 0.0;
400 if (pmargin->
doAdd) {
422 polyp.
x = verts[j].
x + xmargin;
423 polyp.
y = verts[j].
y + ymargin;
426 const double h = hypot(verts[j].x, verts[j].y);
427 polyp.
x = verts[j].
x * (1.0 + margin.
x/h);
428 polyp.
y = verts[j].
y * (1.0 + margin.
y/h);
432 polyp.
x = verts[j].
x * margin.
x;
433 polyp.
y = verts[j].
y * margin.
y;
439 const double ellipse_a = (width + margin.
x) / 2.0;
440 const double ellipse_b = (height + margin.
y) / 2.0;
455 if (pmargin->
doAdd) {
474 if (pmargin->
doAdd) {
516 Pobspath(vconfig, p, pp, q, qp, &line);
550 q = line.
ps[line.
pn - 1];
554 for (i = 0; i < npoly; i++) {
563 slopes[0].
x = slopes[0].
y = 0.0;
564 slopes[1].
x = slopes[1].
y = 0.0;
565 if (
Proutespline(barriers, n_barriers, line, slopes, &spline) < 0) {
579#define BOUNDARY_PORT(e) ((ED_tail_port(e).side)||(ED_head_port(e).side))
596 int cnt, i = 0, npoly;
598 int useEdges =
Nop > 1;
627 agwarningf(
"the bounding boxes of some nodes touch - falling back to straight line edges\n");
629 agwarningf(
"some nodes with margin (%.02f,%.02f) touch - falling back to straight line edges\n", pmargin->
x, pmargin->
y);
635 fprintf(stderr,
"Creating edges using %s\n",
659 if (useEdges &&
ED_spl(e)) {
664 else if (
ED_count(e) == 0)
continue;
665 else if (n ==
head) {
667 }
else if (vconfig) {
675 if (!rtr) rtr =
mkRouter (obs, npoly);
688 for (i = 0; i <
cnt; i++) {
709 for (i=0; i < npoly; i++) {
769 if (
edgefn(g, &margin, edgetype))
805 agwarningf(
"Orthogonal edges not yet supported\n");
866 for (
size_t i = 0; i <
ED_spl(e)->size; i++) {
868 for (
size_t j = 0; j < bez->
size; j++) {
869 if (i == 0 && j == 0) {
873 else if (i ==
ED_spl(e)->size-1 && j == bez->
size-1) {
939 for (
size_t i = 0; i <
ED_spl(e)->size; i++) {
941 for (
size_t j = 0; j < bez->
size; j++) {
1027 double xf, yf, actual, desired;
1029 bool translated =
false;
1050 if (xf < 1.0 || yf < 1.0) {
1064 if (xf > 1.0 && yf > 1.0) {
1065 double scale = fmin(xf, yf);
1072 if (actual < desired) {
1073 yf = desired / actual;
1076 xf = actual / desired;
expand_t esepFactor(graph_t *g)
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static void * gv_alloc(size_t size)
CDT_API int dtclose(Dt_t *)
CDT_API Dtmethod_t * Dtoset
ordered set (self-adjusting tree)
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
boxf polyBB(polygon_t *poly)
double late_double(void *obj, attrsym_t *attr, double defaultValue, double minimum)
void updateBB(graph_t *g, textlabel_t *lp)
void compute_bb(graph_t *g)
vconfig_t * Pobsopen(Ppoly_t **obs, int n_obs)
void Pobsclose(vconfig_t *config)
void Pobspath(vconfig_t *config, Ppoint_t p0, int poly0, Ppoint_t p1, int poly1, Ppolyline_t *output_route)
#define PS2INCH(a_points)
#define INCH2PS(a_inches)
static pointf add_pointf(pointf p, pointf q)
static pointf scale(double c, pointf p)
static pointf exch_xyf(pointf p)
static int cnt(Dict_t *d, Dtlink_t **set)
int agnnodes(Agraph_t *g)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
void agwarningf(const char *fmt,...)
void agerrorf(const char *fmt,...)
#define ND_outline_width(n)
#define ND_outline_height(n)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
swig_ptr_object_handlers offset
bool in_poly(const Ppoly_t poly, Ppoint_t q)
int Plegal_arrangement(Ppoly_t **polys, int n_polys)
router_t * mkRouter(Ppoly_t **obsp, int npoly)
void freeRouter(router_t *rtr)
int makeMultiSpline(edge_t *e, router_t *rtr, int doPolyline)
static bool _neato_set_aspect(graph_t *g)
static int cmpitems(void *k1, void *k2)
static pointf line_intersection(linef l0, linef l1)
static void * newitem(void *p, Dtdisc_t *disc)
static void make_barriers(Ppoly_t **poly, int npoly, int pp, int qp, Pedge_t **barriers, size_t *n_barriers)
static int spline_edges_(graph_t *g, expand_t *pmargin, int edgetype)
static void translateE(edge_t *e, pointf offset)
static Ppoint_t recPt(double x, double y, pointf c, expand_t *m)
static bool swap_ends_p(edge_t *e)
int spline_edges1(graph_t *g, int edgetype)
static bool spline_merge(node_t *n)
Ppoly_t * makeObstacle(node_t *n, expand_t *pmargin, bool isOrtho)
Ppolyline_t getPath(edge_t *e, vconfig_t *vconfig, bool chkPts)
void makeSpline(edge_t *e, Ppoly_t **obs, int npoly, bool chkPts)
void spline_edges0(graph_t *g, bool set_aspect)
static pointf circumscribed_polygon_corner_about_ellipse(double a, double b, size_t i, size_t nsides)
static double ellipse_tangent_slope(double a, double b, pointf p)
static void shiftClusters(graph_t *g, pointf offset)
static void scaleEdge(edge_t *e, double xf, double yf)
static void translateG(Agraph_t *g, pointf offset)
static void makePolyline(edge_t *e)
static void scaleBB(graph_t *g, double xf, double yf)
int splineEdges(graph_t *g, int(*edgefn)(graph_t *, expand_t *, int), int edgetype)
void makeSelfArcs(edge_t *e, int stepx)
void neato_translate(Agraph_t *g)
static edge_t * equivEdge(Dt_t *map, edge_t *e)
static Ppoint_t genPt(double x, double y, pointf c)
void spline_edges(graph_t *g)
bool neato_set_aspect(graph_t *g)
void orthoEdges(Agraph_t *g, bool useLbls)
finds and smooths shortest paths
void make_polyline(Ppolyline_t line, Ppolyline_t *sline)
int Proutespline(Pedge_t *barriers, size_t n_barriers, Ppolyline_t input_route, Pvector_t endpoint_slopes[2], Ppolyline_t *output_route)
static void set_aspect(graph_t *g)
void makePortLabels(edge_t *e)
void clip_and_install(edge_t *fe, node_t *hn, pointf *ps, size_t pn, splineInfo *info)
void resolvePorts(edge_t *e)
shape_kind shapeOf(node_t *)
void makeStraightEdge(graph_t *g, edge_t *e, int edgetype, splineInfo *info)
void addEdgeLabels(edge_t *e)
void makeSelfEdge(edge_t *edges[], size_t ind, size_t cnt, double sizex, double sizey, splineInfo *sinfo)
Agraph_t * root
subgraphs - ancestors
bool(* swapEnds)(edge_t *e)
void(* edgefn)(Agraph_t *, Agedge_t *, glCompColor)