22static const int BOX = 1;
50 double x_min, y_min, x_max, y_max;
52 x_min = x_max = verts->
x;
53 y_min = y_max = verts->
y;
54 for (
size_t i = 1; i <
cnt; i++) {
56 x_min = fmin(x_min, verts->
x);
57 y_min = fmin(y_min, verts->
y);
58 x_max = fmax(x_max, verts->
x);
59 y_max = fmax(y_max, verts->
y);
72 for (
size_t i = 0; i <
cnt; i++) {
83 if (verts[0].y == verts[1].y)
84 return ((verts[2].y == verts[3].y) &&
85 (verts[0].x == verts[3].x) && (verts[1].x == verts[2].x));
87 return ((verts[0].x == verts[1].x) &&
88 (verts[2].x == verts[3].x) &&
89 (verts[0].y == verts[3].y) && (verts[1].y == verts[2].y));
109 char *p =
agget(n,
"samplepoints");
116 for (
size_t i = 0; i < sides; i++) {
118 (
ND_width(n) / 2.0 + xm) * cos((
double)i / (double)sides *
M_PI * 2.0);
120 (
ND_height(n) / 2.0 + ym) * sin((
double)i / (double)sides *
M_PI * 2.0);
126#define PUTPT(P,X,Y) ((P).x=(X),(P).y=(Y))
155 else if ((
poly->sides < 3) &&
poly->regular)
177 for (
size_t i = 0; i < sides; i++) {
178 const double h = hypot(
poly->vertices[i].x,
poly->vertices[i].y);
179 verts[i].
x =
poly->vertices[i].x * (1.0 + xmargin/h);
180 verts[i].
y =
poly->vertices[i].y * (1.0 + ymargin/h);
186 verts =
genRound(n, &sides, xmargin, ymargin);
201 verts =
genRound(n, &sides, xmargin, ymargin);
204 agerrorf(
"makeAddPoly: unknown shape type %s\n",
241 for (
size_t i = 0; i < sides; i++) {
251 &&
isBox(verts, sides))
253 else if ((
poly->sides < 3) &&
poly->regular)
275 agerrorf(
"makePoly: unknown shape type %s\n",
280 if ((xmargin != 1.0) || (ymargin != 1.0))
295 return ((originp.
x <= cornerq.
x) && (originq.
x <= cornerp.
x) &&
296 (originp.
y <= cornerq.
y) && (originq.
y <= cornerp.
y));
303#define advance(A,B,N) (B++, A = (A+1)%N)
321 a1 = (a + n - 1) % n;
322 b1 = (b + m - 1) % m;
328 bHA =
leftOf(P[a1], P[a], Q[b]);
329 aHB =
leftOf(Q[b1], Q[b], P[a]);
336 if ((
cross == 0) && !bHA && !aHB) {
341 }
else if (
cross >= 0)
354 }
while (((aa < n) || (ba < m)) && (aa < 2 * n) && (ba < 2 * m));
368 double crossings = 0;
374 for (i = 0; i < n; i++) {
380 for (i = 0; i < n; i++) {
381 i1 = (i + n - 1) % n;
384 if (
tp3[i].y == 0 &&
tp3[i1].y == 0) {
385 if (
tp3[i].x *
tp3[i1].x < 0) {
393 if ((
tp3[i].y >= 0 &&
tp3[i1].y <= 0) ||
394 (
tp3[i1].
y >= 0 &&
tp3[i].
y <= 0)) {
405 if (
tp3[i].y == 0 ||
tp3[i1].y == 0) {
415 if ((
int)crossings % 2 == 1)
422 return p.
x <= corner.
x && p.
x >= origin_point.
x && p.
y <= corner.
y &&
423 p.
y >= origin_point.
y;
430 for (i = 0; i <
cnt; i++) {
431 outp->
x = inp->
x + off.
x;
432 outp->
y = inp->
y + off.
y;
458 double dx = p.
x - q.
x;
459 double dy = p.
y - q.
y;
460 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?