Now that Graphviz is compiled with C99, there does not seem to be much advantage
in retaining this helper function. We have initialization syntax that is the
same number of characters and can be understood locally without having to lookup
the definition of `pointfof`.
return;
sz = lp->dimen;
- AF[0] = pointfof(lp->pos.x + sz.x / 2., lp->pos.y - sz.y / 2.);
- AF[1] = pointfof(AF[0].x - sz.x, AF[0].y);
+ AF[0] = (pointf){lp->pos.x + sz.x / 2., lp->pos.y - sz.y / 2.};
+ AF[1] = (pointf){AF[0].x - sz.x, AF[0].y};
AF[2] = dotneato_closest(spl, lp->pos);
/* Don't use edge style to draw attachment */
gvrender_set_style(job, job->gvc->defaultlinestyle);
GEOMPROCS_API int line_intersect (pointf a, pointf b, pointf c, pointf d, pointf* p);
-static inline pointf pointfof(double x, double y)
-{
- pointf r;
-
- r.x = x;
- r.y = y;
- return r;
-}
-
static inline box boxof(int llx, int lly, int urx, int ury)
{
box b;
bb = GD_bb(g);
if (rankdir == RANKDIR_LR || rankdir == RANKDIR_BT) {
- new_bb.LL = map_point(pointfof(bb.LL.x, bb.UR.y));
- new_bb.UR = map_point(pointfof(bb.UR.x, bb.LL.y));
+ new_bb.LL = map_point((pointf){bb.LL.x, bb.UR.y});
+ new_bb.UR = map_point((pointf){bb.UR.x, bb.LL.y});
} else {
- new_bb.LL = map_point(pointfof(bb.LL.x, bb.LL.y));
- new_bb.UR = map_point(pointfof(bb.UR.x, bb.UR.y));
+ new_bb.LL = map_point((pointf){bb.LL.x, bb.LL.y});
+ new_bb.UR = map_point((pointf){bb.UR.x, bb.UR.y});
}
GD_bb(g) = new_bb;
if (GD_label(g)) {
n_objs = agnnodes(gp) + n_set_lbls + n_clbls + n_elbls;
objp = objs = N_NEW(n_objs, object_t);
xlp = lbls = N_NEW(n_lbls, xlabel_t);
- bb.LL = pointfof(INT_MAX, INT_MAX);
- bb.UR = pointfof(-INT_MAX, -INT_MAX);
+ bb.LL = (pointf){INT_MAX, INT_MAX};
+ bb.UR = (pointf){-INT_MAX, -INT_MAX};
for (np = agfstnode(gp); np; np = agnxtnode(gp, np)) {
Offset = GD_bb(g).LL;
break;
case RANKDIR_LR:
- Offset = pointfof(-GD_bb(g).UR.y, GD_bb(g).LL.x);
+ Offset = (pointf){-GD_bb(g).UR.y, GD_bb(g).LL.x};
break;
case RANKDIR_BT:
- Offset = pointfof(GD_bb(g).LL.x, -GD_bb(g).UR.y);
+ Offset = (pointf){GD_bb(g).LL.x, -GD_bb(g).UR.y};
break;
case RANKDIR_RL:
- Offset = pointfof(GD_bb(g).LL.y, GD_bb(g).LL.x);
+ Offset = (pointf){GD_bb(g).LL.y, GD_bb(g).LL.x};
break;
default:
UNREACHABLE();
if (bp) {
b = *bp;
- p = pointfof((b.LL.x + b.UR.x) / 2, (b.LL.y + b.UR.y) / 2);
+ p = (pointf){(b.LL.x + b.UR.x) / 2, (b.LL.y + b.UR.y) / 2};
defined = true;
} else {
p.x = p.y = 0.;
sf = f->fld[i];
amt = (int)((i + 1) * inc) - (int)(i * inc);
if (f->LR)
- newsz = pointfof(sf->size.x + amt, sz.y);
+ newsz = (pointf){sf->size.x + amt, sz.y};
else
- newsz = pointfof(sz.x, sf->size.y + amt);
+ newsz = (pointf){sz.x, sf->size.y + amt};
resize_reclbl(sf, newsz, nojustify_p);
}
}
unsigned char mask;
f->sides = sides;
- f->b.LL = pointfof(ul.x, ul.y - f->size.y);
- f->b.UR = pointfof(ul.x + f->size.x, ul.y);
+ f->b.LL = (pointf){ul.x, ul.y - f->size.y};
+ f->b.UR = (pointf){ul.x + f->size.x, ul.y};
last = f->n_flds - 1;
for (i = 0; i <= last; i++) {
if (sides) {
static void record_init(node_t * n)
{
field_t *info;
- pointf ul, sz;
+ pointf sz;
int flip;
size_t len;
char *textbuf; /* temp buffer for storing labels */
}
resize_reclbl(info, sz,
mapbool(late_string(n, N_nojustify, "false")) ? TRUE : FALSE);
- ul = pointfof(-sz.x / 2., sz.y / 2.); /* FIXME - is this still true: suspected to introduce ronding error - see Kluge below */
+ pointf ul = {-sz.x / 2., sz.y / 2.}; /* FIXME - is this still true: suspected to introduce ronding error - see Kluge below */
pos_reclbl(info, ul, sides);
ND_width(n) = PS2INCH(info->size.x);
ND_height(n) = PS2INCH(info->size.y + 1); /* Kluge!! +1 to fix rounding diff between layout and rendering
dx += sgn * stepx;
pointn = 0;
points[pointn++] = tp;
- points[pointn++] = pointfof(tp.x + dx, tp.y - ty / 3);
- points[pointn++] = pointfof(tp.x + dx, np.y - dy);
- points[pointn++] = pointfof((tp.x+hp.x)/2, np.y - dy);
- points[pointn++] = pointfof(hp.x - dx, np.y - dy);
- points[pointn++] = pointfof(hp.x - dx, hp.y - hy / 3);
+ points[pointn++] = (pointf){tp.x + dx, tp.y - ty / 3};
+ points[pointn++] = (pointf){tp.x + dx, np.y - dy};
+ points[pointn++] = (pointf){(tp.x + hp.x) / 2, np.y - dy};
+ points[pointn++] = (pointf){hp.x - dx, np.y - dy};
+ points[pointn++] = (pointf){hp.x - dx, hp.y - hy / 3};
points[pointn++] = hp;
if (ED_label(e)) {
if (GD_flip(agraphof(agtail(e)))) {
dx += sgn * stepx;
pointn = 0;
points[pointn++] = tp;
- points[pointn++] = pointfof(tp.x + dx, tp.y + ty / 3);
- points[pointn++] = pointfof(tp.x + dx, np.y + dy);
- points[pointn++] = pointfof((tp.x+hp.x)/2, np.y + dy);
- points[pointn++] = pointfof(hp.x - dx, np.y + dy);
- points[pointn++] = pointfof(hp.x - dx, hp.y + hy / 3);
+ points[pointn++] = (pointf){tp.x + dx, tp.y + ty / 3};
+ points[pointn++] = (pointf){tp.x + dx, np.y + dy};
+ points[pointn++] = (pointf){(tp.x + hp.x) / 2, np.y + dy};
+ points[pointn++] = (pointf){hp.x - dx, np.y + dy};
+ points[pointn++] = (pointf){hp.x - dx, hp.y + hy / 3};
points[pointn++] = hp;
if (ED_label(e)) {
if (GD_flip(agraphof(agtail(e)))) {
dy += sgn * stepy;
pointn = 0;
points[pointn++] = tp;
- points[pointn++] = pointfof(tp.x + tx / 3, tp.y + dy);
- points[pointn++] = pointfof(np.x + dx, tp.y + dy);
- points[pointn++] = pointfof(np.x + dx, (tp.y+hp.y)/2);
- points[pointn++] = pointfof(np.x + dx, hp.y - dy);
- points[pointn++] = pointfof(hp.x + hx / 3, hp.y - dy);
+ points[pointn++] = (pointf){tp.x + tx / 3, tp.y + dy};
+ points[pointn++] = (pointf){np.x + dx, tp.y + dy};
+ points[pointn++] = (pointf){np.x + dx, (tp.y + hp.y) / 2};
+ points[pointn++] = (pointf){np.x + dx, hp.y - dy};
+ points[pointn++] = (pointf){hp.x + hx / 3, hp.y - dy};
points[pointn++] = hp;
if (ED_label(e)) {
if (GD_flip(agraphof(agtail(e)))) {
dy += sgn * stepy;
pointn = 0;
points[pointn++] = tp;
- points[pointn++] = pointfof(tp.x - tx / 3, tp.y + dy);
- points[pointn++] = pointfof(np.x - dx, tp.y + dy);
- points[pointn++] = pointfof(np.x - dx, (tp.y+hp.y)/2);
- points[pointn++] = pointfof(np.x - dx, hp.y - dy);
- points[pointn++] = pointfof(hp.x - hx / 3, hp.y - dy);
+ points[pointn++] = (pointf){tp.x - tx / 3, tp.y + dy};
+ points[pointn++] = (pointf){np.x - dx, tp.y + dy};
+ points[pointn++] = (pointf){np.x - dx, (tp.y + hp.y) / 2};
+ points[pointn++] = (pointf){np.x - dx, hp.y - dy};
+ points[pointn++] = (pointf){hp.x - hx / 3, hp.y - dy};
points[pointn++] = hp;
if (ED_label(e)) {
int i, j;
if ((agnnodes(g) == 0) && (GD_n_cluster(g) ==0)) {
- bb.LL = pointfof(0, 0);
- bb.UR = pointfof(0, 0);
+ bb.LL = (pointf){0};
+ bb.UR = (pointf){0};
return;
}
- bb.LL = pointfof(INT_MAX, INT_MAX);
- bb.UR = pointfof(-INT_MAX, -INT_MAX);
+ bb.LL = (pointf){INT_MAX, INT_MAX};
+ bb.UR = (pointf){-INT_MAX, -INT_MAX};
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
ptf = coord(n);
s2.x = ND_xsize(n) / 2.0;
pointn = 0;
if (et == EDGETYPE_SPLINE || et == EDGETYPE_LINE) {
points[pointn++] = tp;
- points[pointn++] = pointfof((2 * tp.x + hp.x) / 3, dy);
- points[pointn++] = pointfof((2 * hp.x + tp.x) / 3, dy);
+ points[pointn++] = (pointf){(2 * tp.x + hp.x) / 3, dy};
+ points[pointn++] = (pointf){(2 * hp.x + tp.x) / 3, dy};
points[pointn++] = hp;
}
else { /* EDGETYPE_PLINE */
points[pointn++] = tp;
points[pointn++] = tp;
- points[pointn++] = pointfof((2 * tp.x + hp.x) / 3, dy);
- points[pointn++] = pointfof((2 * tp.x + hp.x) / 3, dy);
- points[pointn++] = pointfof((2 * tp.x + hp.x) / 3, dy);
- points[pointn++] = pointfof((2 * hp.x + tp.x) / 3, dy);
- points[pointn++] = pointfof((2 * hp.x + tp.x) / 3, dy);
- points[pointn++] = pointfof((2 * hp.x + tp.x) / 3, dy);
+ points[pointn++] = (pointf){(2 * tp.x + hp.x) / 3, dy};
+ points[pointn++] = (pointf){(2 * tp.x + hp.x) / 3, dy};
+ points[pointn++] = (pointf){(2 * tp.x + hp.x) / 3, dy};
+ points[pointn++] = (pointf){(2 * hp.x + tp.x) / 3, dy};
+ points[pointn++] = (pointf){(2 * hp.x + tp.x) / 3, dy};
+ points[pointn++] = (pointf){(2 * hp.x + tp.x) / 3, dy};
points[pointn++] = hp;
points[pointn++] = hp;
}
static int Verbose;
extern pointf edgeMidpoint(graph_t * g, edge_t * e);
-static inline pointf pointfof(double x, double y)
-{
- pointf r;
-
- r.x = x;
- r.y = y;
- return r;
-}
-
typedef struct {
GVC_t *gvc;
char *infname;
n_lbls = n_nlbls + n_elbls;
objp = objs = gv_calloc(n_objs, sizeof(object_t));
xlp = lbls = gv_calloc(n_lbls, sizeof(xlabel_t));
- bb.LL = pointfof(INT_MAX, INT_MAX);
- bb.UR = pointfof(-INT_MAX, -INT_MAX);
+ bb.LL = (pointf){INT_MAX, INT_MAX};
+ bb.UR = (pointf){-INT_MAX, -INT_MAX};
for (np = agfstnode(gp); np; np = agnxtnode(gp, np)) {
/* Add an obstacle per node */
char *lp;
lp = agget(obj, name);
if (lp && sscanf(lp, "%lf,%lf", &x, &y) == 2) {
- l->pos = pointfof(x, y);
+ l->pos = (pointf){x, y};
l->set = true;
}
}
if (GD_label(g) && G_lp) {
s = agxget(g, G_lp);
if (sscanf(s, "%lf,%lf", &x, &y) == 2) {
- GD_label(g)->pos = pointfof(x, y);
+ GD_label(g)->pos = (pointf){x, y};
GD_label(g)->set = true;
}
}
pts = putRects (total, gs, &pinfo);
free (pinfo.vals);
- rootbb.LL = pointfof(INT_MAX, INT_MAX);
- rootbb.UR = pointfof(-INT_MAX, -INT_MAX);
+ rootbb.LL = (pointf){INT_MAX, INT_MAX};
+ rootbb.UR = (pointf){-INT_MAX, -INT_MAX};
/* reposition children relative to GD_bb(g) */
for (j = 0; j < total; j++) {