21static const int BOX = 1;
49 double x_min, y_min, x_max, y_max;
51 x_min = x_max = verts->
x;
52 y_min = y_max = verts->
y;
53 for (
size_t i = 1; i <
cnt; i++) {
55 x_min = fmin(x_min, verts->
x);
56 y_min = fmin(y_min, verts->
y);
57 x_max = fmax(x_max, verts->
x);
58 y_max = fmax(y_max, verts->
y);
71 for (
size_t i = 0; i <
cnt; i++) {
82 if (verts[0].y == verts[1].y)
83 return ((verts[2].y == verts[3].y) &&
84 (verts[0].x == verts[3].x) && (verts[1].x == verts[2].x));
86 return ((verts[0].x == verts[1].x) &&
87 (verts[2].x == verts[3].x) &&
88 (verts[0].y == verts[3].y) && (verts[1].y == verts[2].y));
108 char *p =
agget(n,
"samplepoints");
115 for (
size_t i = 0; i < sides; i++) {
117 (
ND_width(n) / 2.0 + xm) * cos((
double)i / (double)sides *
M_PI * 2.0);
119 (
ND_height(n) / 2.0 + ym) * sin((
double)i / (double)sides *
M_PI * 2.0);
125#define PUTPT(P,X,Y) ((P).x=(X),(P).y=(Y))
154 else if ((
poly->sides < 3) &&
poly->regular)
176 for (
size_t i = 0; i < sides; i++) {
177 const double h = hypot(
poly->vertices[i].x,
poly->vertices[i].y);
178 verts[i].
x =
poly->vertices[i].x * (1.0 + xmargin/h);
179 verts[i].
y =
poly->vertices[i].y * (1.0 + ymargin/h);
185 verts =
genRound(n, &sides, xmargin, ymargin);
200 verts =
genRound(n, &sides, xmargin, ymargin);
203 agerrorf(
"makeAddPoly: unknown shape type %s\n",
240 for (
size_t i = 0; i < sides; i++) {
250 &&
isBox(verts, sides))
252 else if ((
poly->sides < 3) &&
poly->regular)
274 agerrorf(
"makePoly: unknown shape type %s\n",
279 if ((xmargin != 1.0) || (ymargin != 1.0))
294 return ((originp.
x <= cornerq.
x) && (originq.
x <= cornerp.
x) &&
295 (originp.
y <= cornerq.
y) && (originq.
y <= cornerp.
y));
302#define advance(A,B,N) (B++, A = (A+1)%N)
320 a1 = (a + n - 1) % n;
321 b1 = (b + m - 1) % m;
327 bHA =
leftOf(P[a1], P[a], Q[b]);
328 aHB =
leftOf(Q[b1], Q[b], P[a]);
335 if ((
cross == 0) && !bHA && !aHB) {
340 }
else if (
cross >= 0)
353 }
while (((aa < n) || (ba < m)) && (aa < 2 * n) && (ba < 2 * m));
367 double crossings = 0;
373 for (i = 0; i < n; i++) {
379 for (i = 0; i < n; i++) {
380 i1 = (i + n - 1) % n;
383 if (
tp3[i].y == 0 &&
tp3[i1].y == 0) {
384 if (
tp3[i].x *
tp3[i1].x < 0) {
392 if ((
tp3[i].y >= 0 &&
tp3[i1].y <= 0) ||
393 (
tp3[i1].
y >= 0 &&
tp3[i].
y <= 0)) {
404 if (
tp3[i].y == 0 ||
tp3[i1].y == 0) {
414 if ((
int)crossings % 2 == 1)
421 return p.
x <= corner.
x && p.
x >= origin_point.
x && p.
y <= corner.
y &&
422 p.
y >= origin_point.
y;
429 for (i = 0; i <
cnt; i++) {
430 outp->
x = inp->
x + off.
x;
431 outp->
y = inp->
y + off.
y;
457 double dx = p.
x - q.
x;
458 double dy = p.
y - q.
y;
459 if ((
dx *
dx +
dy *
dy) > (d * d) / 4.0)
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static bool leftOf(pointf p1, pointf p2, pointf p3)
Return true if p3 is to left of ray p1->p2.
geometric types and macros (e.g. points and boxes)
#define PS2INCH(a_points)
void addpt(Point *c, Point a, Point b)
void subpt(Point *a, Point b, Point c)
double area_2(Point a, Point b, Point c)
static int cnt(Dict_t *d, Dtlink_t **set)
char * agget(void *obj, char *name)
void agerrorf(const char *fmt,...)
static double cross(double *u, double *v)
int polyOverlap(Point p, Poly *pp, Point q, Poly *qp)
static int inPoly(Point vertex[], int n, Point q)
static Point makeScaledTransPoint(double x, double y, double dx, double dy)
static void inflatePts(Point *verts, size_t cnt, double xmargin, double ymargin)
static bool ISCIRCLE(const Poly *p)
static int isBox(Point *verts, size_t cnt)
int makePoly(Poly *pp, Agnode_t *n, double xmargin, double ymargin)
static void bbox(Point *verts, size_t cnt, Point *o, Point *c)
int makeAddPoly(Poly *pp, Agnode_t *n, double xmargin, double ymargin)
static void transCopy(Point *inp, int cnt, Point off, Point *outp)
static bool ISBOX(const Poly *p)
static bool inBox(Point p, Point origin_point, Point corner)
static int edgesIntersect(Point *P, Point *Q, int n, int m)
static int pintersect(Point originp, Point cornerp, Point originq, Point cornerq)
static Point * genRound(Agnode_t *n, size_t *sidep, double xm, double ym)
static Point makeScaledPoint(double x, double y)
shape_kind shapeOf(node_t *)
static bool streq(const char *a, const char *b)
are a and b equal?