static void poly_init(node_t * n)
{
pointf dimen, min_bb, bb;
+ pointf outline_bb;
point imagesize;
pointf *vertices;
char *p, *sfile, *fxd;
ND_label(n)->space.y = dimen.y + temp;
}
+ const double penwidth = late_int(n, N_penwidth, DEFAULT_NODEPENWIDTH, MIN_NODEPENWIDTH);
+
outp = peripheries;
if (peripheries < 1)
outp = 1;
bb.x = 2. * P.x;
bb.y = 2. * P.y;
}
+ outline_bb = bb;
} else {
/*
* the current segments, and outside by GAP distance, intersect.
*/
+ if (peripheries >= 1 && penwidth > 0) {
+ // allocate extra vertices representing the outline, i.e., the outermost
+ // periphery with penwidth taken into account
+ ++outp;
+ }
+
vertices = N_NEW(outp * sides, pointf);
if (ND_shape(n)->polygon->vertices) {
poly_desc_t* pd = (poly_desc_t*)ND_shape(n)->polygon->vertices;
ymax *= 2.;
bb.x = MAX(width, xmax);
bb.y = MAX(height, ymax);
+ outline_bb = bb;
+
scalex = bb.x / xmax;
scaley = bb.y / ymax;
vertices[i] = P;
}
- if (peripheries > 1) {
+ if (outp > 1) {
pointf Q = vertices[(sides - 1)];
pointf R = vertices[0];
beta = atan2(R.y - Q.y, R.x - Q.x);
Q.y += sinx;
vertices[i + j * sides] = Q;
}
+ if (outp > peripheries) {
+ // add an outline at half the penwidth outside the outermost periphery
+ Q.x += cosx * penwidth / 2 / GAP;
+ Q.y += sinx * penwidth / 2 / GAP;
+ vertices[i + peripheries * sides] = Q;
+ }
}
for (i = 0; i < sides; i++) {
pointf P = vertices[i + (peripheries - 1) * sides];
bb.x = MAX(2. * fabs(P.x), bb.x);
bb.y = MAX(2. * fabs(P.y), bb.y);
+ pointf Q = vertices[i + (outp - 1) * sides];
+ outline_bb.x = MAX(2. * fabs(Q.x), outline_bb.x);
+ outline_bb.y = MAX(2. * fabs(Q.y), outline_bb.y);
}
}
}
/* set width and height to reflect label and shape */
ND_width(n) = PS2INCH(MAX(dimen.x,bb.x));
ND_height(n) = PS2INCH(MAX(dimen.y,bb.y));
+ ND_outline_width(n) = PS2INCH(MAX(dimen.x, outline_bb.x));
+ ND_outline_height(n) = PS2INCH(MAX(dimen.y, outline_bb.y));
} else {
ND_width(n) = PS2INCH(bb.x);
ND_height(n) = PS2INCH(bb.y);
+ ND_outline_width(n) = PS2INCH(outline_bb.x);
+ ND_outline_height(n) = PS2INCH(outline_bb.y);
}
ND_shape_info(n) = poly;
}
if (n != lastn) {
double n_width, n_height;
+ double n_outline_width;
+ double n_outline_height;
poly = ND_shape_info(n);
vertex = poly->vertices;
sides = poly->sides;
boxf bb = polyBB(poly);
n_width = bb.UR.x - bb.LL.x;
n_height = bb.UR.y - bb.LL.y;
+ n_outline_width = n_width;
+ n_outline_height = n_height;
/* get point and node size adjusted for rankdir=LR */
if (GD_flip(agraphof(n))) {
ysize = n_width;
}
n_width = POINTS(ND_width(n));
n_height = POINTS(ND_height(n));
+ n_outline_width = INCH2PS(ND_outline_width(n));
+ n_outline_height = INCH2PS(ND_outline_height(n));
}
/* scale */
ysize = 1.0;
scalex = n_width / xsize;
scaley = n_height / ysize;
- box_URx = n_width / 2.0;
- box_URy = n_height / 2.0;
+ box_URx = n_outline_width / 2.0;
+ box_URy = n_outline_height / 2.0;
- /* index to outer-periphery */
- outp = (poly->peripheries - 1) * sides;
- if (outp < 0)
- outp = 0;
+ const double penwidth = late_int(n, N_penwidth, DEFAULT_NODEPENWIDTH, MIN_NODEPENWIDTH);
+ if (poly->peripheries >= 1 && penwidth > 0) {
+ /* index to outline, i.e., the outer-periphery with penwidth taken into account */
+ outp = (poly->peripheries + 1 - 1) * sides;
+ } else {
+ /* index to outer-periphery */
+ outp = (poly->peripheries - 1) * sides;
+ if (outp < 0)
+ outp = 0;
+ }
lastn = n;
}