-I$(top_srcdir)/lib/graph \
-I$(top_srcdir)/lib/cdt @GD_INCLUDES@ @EXPAT_INCLUDES@ @Z_INCLUDES@
-pkginclude_HEADERS = const.h globals.h htmllex.h htmltable.h macros.h \
- pointset.h render.h renderprocs.h types.h utils.h colortbl.h geom.h
+pkginclude_HEADERS = logic.h geom.h const.h macros.h types.h globals.h \
+ htmllex.h htmltable.h pointset.h render.h renderprocs.h \
+ utils.h colortbl.h
noinst_LTLIBRARIES = libcommon.la
if !DISABLE_CODEGENS
AWKDIR = $(ROOT)/awk
HDRS = colortbl.h const.h globals.h macros.h render.h \
- renderprocs.h types.h utils.h geom.h
+ renderprocs.h types.h utils.h geom.h logic.h
OBJS = args.o arrows.o gdusershape.o mapgen.o psgen.o svgusershape.o \
colxlate.o globals.o mifgen.o psusershape.o timing.o \
/* geometric functions (e.g. on points and boxes) with application to, but
* no specific dependance on graphs */
-#include <assert.h>
-#include <math.h>
#include <stdio.h>
-
-#include "types.h"
-#include "macros.h"
-#include "const.h"
+#include "logic.h"
+#include "pathplan.h"
#include "geom.h"
point pointof(int x, int y)
return -1;
}
-/* flip_ptf:
- * Transform point =>
- * LR - rotate ccw by 90
- * BT - reflect across x axis
- * RL - TB o LR
- */
-point flip_pt(point p, int rankdir)
+point ccwrotatep(point p, int ccwrot)
{
int x = p.x, y = p.y;
- switch (rankdir) {
- case RANKDIR_TB:
+ switch (ccwrot) {
+ case 0:
break;
- case RANKDIR_LR:
+ case 90:
p.x = -y;
p.y = x;
break;
- case RANKDIR_BT:
+ case 180:
p.x = x;
p.y = -y;
break;
- case RANKDIR_RL:
+ case 270:
p.x = y;
p.y = x;
break;
+ default:
+ fprintf(stderr,"unsupported ccw rotation: %d degrees\n", ccwrot);
}
return p;
}
-/* flip_ptf:
- * flip_pt for pointf type.
- */
-pointf flip_ptf(pointf p, int rankdir)
+pointf ccwrotatepf(pointf p, int ccwrot)
{
double x = p.x, y = p.y;
- switch (rankdir) {
- case RANKDIR_TB:
+ switch (ccwrot) {
+ case 0:
break;
- case RANKDIR_LR:
+ case 90:
p.x = -y;
p.y = x;
break;
- case RANKDIR_BT:
+ case 180:
p.x = x;
p.y = -y;
break;
- case RANKDIR_RL:
+ case 270:
p.x = y;
p.y = x;
break;
+ default:
+ fprintf(stderr,"unsupported ccw rotation: %d degrees\n", ccwrot);
}
return p;
}
-/* invflip_pt:
- * Transform point =>
- * LR - rotate cw by 90
- * BT - reflect across x axis
- * RL - TB o LR
- * Note that flip and invflip only differ on LR
- */
-point invflip_pt(point p, int rankdir)
+point cwrotatep(point p, int cwrot)
{
int x = p.x, y = p.y;
- switch (rankdir) {
- case RANKDIR_TB:
+ switch (cwrot) {
+ case 0:
+ break;
+ case 90:
+ p.x = y;
+ p.y = -x;
+ break;
+ case 180:
+ p.x = x;
+ p.y = -y;
+ break;
+ case 270:
+ p.x = y;
+ p.y = x;
+ break;
+ default:
+ fprintf(stderr,"unsupported cw rotation: %d degrees\n", cwrot);
+ }
+ return p;
+}
+
+pointf cwrotatepf(pointf p, int cwrot)
+{
+ double x = p.x, y = p.y;
+ switch (cwrot) {
+ case 0:
break;
- case RANKDIR_LR:
+ case 90:
p.x = y;
p.y = -x;
break;
- case RANKDIR_BT:
+ case 180:
p.x = x;
p.y = -y;
break;
- case RANKDIR_RL:
+ case 270:
p.x = y;
p.y = x;
break;
+ default:
+ fprintf(stderr,"unsupported cw rotation: %d degrees\n", cwrot);
}
return p;
}
/* geometric functions (e.g. on points and boxes) with application to, but
* no specific dependance on graphs */
+#ifndef GV_GEOM_H
+#define GV_GEOM_H
+
+#include "pathplan.h"
+
#ifdef __cplusplus
extern "C" {
#endif
+
+typedef struct point { int x, y; } point;
+
+typedef Ppoint_t pointf;
+
+typedef struct box { point LL, UR; } box;
+
+typedef struct boxf { pointf LL, UR; } boxf;
+
+#ifdef MIN
+#undef MIN
+#endif
+#define MIN(a,b) ((a)<(b)?(a):(b))
- extern point pointof(int, int);
- extern pointf cvt2ptf(point);
- extern point cvt2pt(pointf);
- extern point add_points(point, point);
- extern pointf add_pointfs(pointf, pointf);
- extern point sub_points(point, point);
- extern pointf sub_pointfs(pointf, pointf);
- extern point exch_xy(point p);
- extern pointf exch_xyf(pointf p);
-
- extern box boxof(int llx, int lly, int urx, int ury);
- extern boxf boxfof(double llx, double lly, double urx, double ury);
- extern box mkbox(point, point);
- extern boxf mkboxf(pointf, pointf);
- extern box box_bb(box, box);
- extern boxf boxf_bb(boxf, boxf);
- extern box box_intersect(box, box);
- extern boxf boxf_intersect(boxf, boxf);
- extern boolean box_overlap(box, box);
- extern boolean boxf_overlap(boxf, boxf);
- extern boolean box_contains(box, box);
- extern boolean boxf_contains(boxf, boxf);
- extern box flip_rec_box(box b, point p);
-
- extern int lineToBox(pointf p1, pointf p2, boxf b);
- extern double dist2(pointf p, pointf q);
-
- extern point flip_pt(point p, int rankdir);
- extern pointf flip_ptf(pointf p, int rankdir);
- extern point invflip_pt(point p, int rankdir);
+#ifdef MAX
+#undef MAX
+#endif
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+#ifdef ABS
+#undef ABS
+#endif
+#define ABS(a) ((a) >= 0 ? (a) : -(a))
+
+#ifndef MAXINT
+#define MAXINT ((int)(~(unsigned)0 >> 1))
+#endif
+#ifndef MAXSHORT
+#define MAXSHORT (0x7fff)
+#endif
+#ifndef MAXDOUBLE
+#define MAXDOUBLE 1.7976931348623157e+308
+#endif
+#ifndef MAXFLOAT
+#define MAXFLOAT ((float)3.40282347e+38)
+#endif
+
+#ifdef BETWEEN
+#undef BETWEEN
+#endif
+#define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c)))
+
+/* true if point p is inside box b */
+#define INSIDE(p,b) (BETWEEN((b).LL.x,(p).x,(b).UR.x) && BETWEEN((b).LL.y,(p).y,(b).UR.y))
+/* true if boxes b0 and b1 overlap */
+#define OVERLAP(b0,b1) (((b0).UR.x >= (b1).LL.x) && ((b1).UR.x >= (b0).LL.x) && ((b0).UR.y >= (b1).LL.y) && ((b1).UR.y >= (b0).LL.y))
+/* true if box b0 completely contains b1*/
+#define CONTAINS(b0,b1) (((b0).UR.x >= (b1).UR.x) && ((b0).UR.y >= (b1).UR.y) && ((b0).LL.x <= (b1).LL.x) && ((b0).LL.y <= (b1).LL.y))
+
+/* expand box b as needed to enclose point p */
+#define EXPANDBP(b, p) (b.LL.x = MIN(b.LL.x, p.x), b.LL.y = MIN(b.LL.y, p.y), b.UR.x = MAX(b.UR.x, p.x), b.UR.y = MAX(b.UR.y, p.y))
+/* expand box b0 as needed to enclose box b1 */
+#define EXPANDBB(b0, b1) (b0.LL.x = MIN(b0.LL.x, b1.LL.x), b0.LL.y = MIN(b0.LL.y, b1.LL.y), b0.UR.x = MAX(b0.UR.x, b1.UR.x), b0.UR.y = MAX(b0.UR.y, b1.UR.y))
+
+#define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5))
+#define RADIANS(deg) ((deg)/180.0 * PI)
+#define DEGREES(rad) ((rad)/PI * 180.0)
+
+#define SQR(v) ((v) * (v))
+#define DIST2(p1,p2) (SQR((p1.x) - (p2.x))) + (SQR((p1.y) - (p2.y)))
+#define DIST(p1,p2) (sqrt(DIST2((p1),(p2))))
+
+#define POINTS_PER_INCH 72
+#define POINTS(f_inch) (ROUND((f_inch)*POINTS_PER_INCH))
+#define PS2INCH(ps) ((ps)/(double)POINTS_PER_INCH)
+
+#define P2PF(p, pf) (pf.x = p.x, pf.y = p.y)
+#define PF2P(pf, p) (p.x = ROUND (pf.x), p.y = ROUND (pf.y))
+#define B2BF(b, bf) (bf.LL.x = b.LL.x, bf.LL.y = b.LL.y, bf.UR.x = b.UR.x, bf.UR.y = b.UR.y)
+#define BF2B(bf, b) (b.LL.x = ROUND (bf.LL.x), b.LL.y = ROUND (bf.LL.y), b.UR.x = ROUND (bf.UR.x), b.UR.y = ROUND (bf.UR.y))
+
+extern point pointof(int, int);
+extern pointf cvt2ptf(point);
+extern point cvt2pt(pointf);
+extern point add_points(point, point);
+extern pointf add_pointfs(pointf, pointf);
+extern point sub_points(point, point);
+extern pointf sub_pointfs(pointf, pointf);
+extern point exch_xy(point p);
+extern pointf exch_xyf(pointf p);
+
+extern box boxof(int llx, int lly, int urx, int ury);
+extern boxf boxfof(double llx, double lly, double urx, double ury);
+extern box mkbox(point, point);
+extern boxf mkboxf(pointf, pointf);
+extern box box_bb(box, box);
+extern boxf boxf_bb(boxf, boxf);
+extern box box_intersect(box, box);
+extern boxf boxf_intersect(boxf, boxf);
+extern boolean box_overlap(box, box);
+extern boolean boxf_overlap(boxf, boxf);
+extern boolean box_contains(box, box);
+extern boolean boxf_contains(boxf, boxf);
+extern box flip_rec_box(box b, point p);
+
+extern int lineToBox(pointf p1, pointf p2, boxf b);
+extern double dist2(pointf p, pointf q);
+
+extern point ccwrotatep(point p, int ccwrot);
+extern pointf ccwrotatepf(pointf p, int ccwrot);
+extern point cwrotatep(point p, int cwrot);
+extern pointf cwrotatepf(pointf p, int cwrot);
#ifdef __cplusplus
}
#endif
+
+#endif
#ifndef GV_MACROS_H
#define GV_MACROS_H
-#define NOT(v) (!(v))
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE NOT(FALSE)
-#endif
-
-#ifndef NOTUSED
-#define NOTUSED(var) (void) var
-#endif
-
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
-#ifndef NIL
-#define NIL(type) ((type)0)
-#endif
-
#ifdef DMALLOC
#define NEW(t) (t*)calloc(1,sizeof(t))
#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
#define ZALLOC(size,ptr,type,osize) (ptr? (type*)zrealloc(ptr,size,sizeof(type),osize):(type*)zmalloc((size)*sizeof(type)))
#endif
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(a,b) ((a)<(b)?(a):(b))
-
-#ifdef MAX
-#undef MAX
-#endif
-#define MAX(a,b) ((a)>(b)?(a):(b))
-
-#ifdef ABS
-#undef ABS
-#endif
-#define ABS(a) ((a) >= 0 ? (a) : -(a))
-
-#ifndef MAXINT
-#define MAXINT ((int)(~(unsigned)0 >> 1))
-#endif
-#ifndef MAXSHORT
-#define MAXSHORT (0x7fff)
-#endif
-#ifndef MAXDOUBLE
-#define MAXDOUBLE 1.7976931348623157e+308
-#endif
-#ifndef MAXFLOAT
-#define MAXFLOAT ((float)3.40282347e+38)
-#endif
-
-#ifdef BETWEEN
-#undef BETWEEN
-#endif
-#define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c)))
-
-/* true if point p is inside box b */
-#define INSIDE(p,b) (BETWEEN((b).LL.x,(p).x,(b).UR.x) && BETWEEN((b).LL.y,(p).y,(b).UR.y))
-/* true if boxes b0 and b1 overlap */
-#define OVERLAP(b0,b1) (((b0).UR.x >= (b1).LL.x) && ((b1).UR.x >= (b0).LL.x) && ((b0).UR.y >= (b1).LL.y) && ((b1).UR.y >= (b0).LL.y))
-/* true if box b0 completely contains b1*/
-#define CONTAINS(b0,b1) (((b0).UR.x >= (b1).UR.x) && ((b0).UR.y >= (b1).UR.y) && ((b0).LL.x <= (b1).LL.x) && ((b0).LL.y <= (b1).LL.y))
-
-/* expand box b as needed to enclose point p */
-#define EXPANDBP(b, p) (b.LL.x = MIN(b.LL.x, p.x), b.LL.y = MIN(b.LL.y, p.y), b.UR.x = MAX(b.UR.x, p.x), b.UR.y = MAX(b.UR.y, p.y))
-/* expand box b0 as needed to enclose box b1 */
-#define EXPANDBB(b0, b1) (b0.LL.x = MIN(b0.LL.x, b1.LL.x), b0.LL.y = MIN(b0.LL.y, b1.LL.y), b0.UR.x = MAX(b0.UR.x, b1.UR.x), b0.UR.y = MAX(b0.UR.y, b1.UR.y))
-
-#define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5))
-#define RADIANS(deg) ((deg)/180.0 * PI)
-#define DEGREES(rad) ((rad)/PI * 180.0)
-
-#define SQR(v) ((v) * (v))
-#define DIST2(p1,p2) (SQR((p1.x) - (p2.x))) + (SQR((p1.y) - (p2.y)))
-#define DIST(p1,p2) (sqrt(DIST2((p1),(p2))))
-
-#define POINTS_PER_INCH 72
-#define POINTS(f_inch) (ROUND((f_inch)*POINTS_PER_INCH))
-#define PS2INCH(ps) ((ps)/(double)POINTS_PER_INCH)
-
#define isPinned(n) (ND_pinned(n) == P_PIN)
#define hasPos(n) (ND_pinned(n) > 0)
#define isFixed(n) (ND_pinned(n) > P_SET)
#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b))
#endif
-#define P2PF(p, pf) (pf.x = p.x, pf.y = p.y)
-#define PF2P(pf, p) (p.x = ROUND (pf.x), p.y = ROUND (pf.y))
-#define B2BF(b, bf) (bf.LL.x = b.LL.x, bf.LL.y = b.LL.y, bf.UR.x = b.UR.x, bf.UR.y = b.UR.y)
-#define BF2B(bf, b) (b.LL.x = ROUND (bf.LL.x), b.LL.y = ROUND (bf.LL.y), b.UR.x = ROUND (bf.UR.x), b.UR.y = ROUND (bf.UR.y))
-
#define XPAD(d) ((d).x += 4*GAP)
#define YPAD(d) ((d).y += 2*GAP)
#define PAD(d) {XPAD(d); YPAD(d);}
point map_point(point p)
{
- p = flip_pt(p, Rankdir);
+ p = ccwrotatep(p, Rankdir*90);
p.x -= Offset.x;
p.y -= Offset.y;
return p;
#include <string.h>
#endif
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "macros.h"
#include "const.h"
#include "types.h"
extern splines *getsplinepoints(edge_t * e);
extern void global_def(char *,
Agsym_t * (*fun) (Agraph_t *, char *, char *));
+ extern int gvRenderJobs (GVC_t * gvc, graph_t * g);
extern point image_size(graph_t * g, char *shapefile);
extern boolean isPolygon(node_t *);
extern char *strdup_and_subst_graph(char *str, Agraph_t * g);
box *bp = inside_context->s.bp;
node_t *n = inside_context->s.n;
- P = flip_ptf(p, GD_rankdir(n->graph));
+ P = ccwrotatepf(p, 90*GD_rankdir(n->graph));
/* Quick test if port rectangle is target */
if (bp) {
break;
}
}
- p = invflip_pt(p, GD_rankdir(n->graph));
+ p = cwrotatep(p, 90*GD_rankdir(n->graph));
pp->side = invflip_side(side, GD_rankdir(n->graph));
pp->bp = bp;
pp->p = p;
box bbox;
/* convert point to node coordinate system */
- p = flip_ptf(p, GD_rankdir(n->graph));
+ p = ccwrotatepf(p, 90*GD_rankdir(n->graph));
if (bp == NULL) {
fld0 = (field_t *) ND_shape_info(n);
double x2;
node_t *n = inside_context->s.n;
- P = flip_ptf(p, GD_rankdir(n->graph));
+ P = ccwrotatepf(p, 90*GD_rankdir(n->graph));
x2 = ND_ht_i(n) / 2;
return ((P.y >= -x2) && (P.y <= x2) && (P.x >= -ND_lw_i(n))
&& (P.x <= ND_rw_i(n)));
#ifndef GV_TYPES_H
#define GV_TYPES_H
-#include "pathplan.h"
-
#ifdef __cplusplus
extern "C" {
#endif
- typedef unsigned char boolean;
-
typedef int (*qsort_cmpf) (const void *, const void *);
typedef int (*bsearch_cmpf) (const void *, const void *);
typedef struct htmllabel_t htmllabel_t;
- typedef struct point {
- int x, y;
- } point;
-
- typedef Ppoint_t pointf;
-
- typedef struct box {
- point LL, UR;
- } box;
-
- typedef struct boxf {
- pointf LL, UR;
- } boxf;
-
typedef union inside_t {
struct {
pointf* p;
extern "C" {
#endif
-#ifndef FALSE
-#define FALSE 0
-#define TRUE (! FALSE)
-#endif
-
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
typedef enum { PEN_NONE, PEN_DASHED, PEN_DOTTED, PEN_SOLID } pen_type;
#include <glob.h>
#endif
-#include "types.h"
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "macros.h"
#include "const.h"
+#include "types.h"
#include "graph.h"
#include "gvplugin.h"
#include "gvcint.h"
#include <stdio.h>
#include <stdlib.h>
-#include "types.h"
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "macros.h"
+#include "types.h"
#include "graph.h"
#include "gvplugin.h"
#include "gvcint.h"
/* layout */
extern int gvlayout_select(GVC_t * gvc, char *str);
+ extern int gvFreeLayout(GVC_t * gvc, graph_t * g);
+ extern int gvLayoutJobs(GVC_t * gvc, graph_t * g);
#ifdef __cplusplus
}
#include <stdio.h>
#include <string.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "const.h"
#include "types.h"
#include "macros.h"
#include <stdio.h>
#include <stdlib.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "types.h"
#include "gvplugin.h"
#include "gvcint.h"
#include <stdio.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "const.h"
#include "types.h"
#include "macros.h"
#include <ltdl.h>
#endif
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "types.h"
#include "macros.h"
#include "graph.h"
#include <stdlib.h>
#include <string.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "const.h"
#include "types.h"
#include "macros.h"
+#include "geom.h"
#include "globals.h"
#include "graph.h"
#include "cdt.h"
#include <stdio.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "const.h"
#include "types.h"
#include "macros.h"
#include <stdio.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "const.h"
#include "types.h"
#include "macros.h"
#include <stdio.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "macros.h"
#include "const.h"
#include "types.h"
#include <stdio.h>
+#include "logic.h"
+#include "pathplan.h"
+#include "geom.h"
#include "macros.h"
#include "const.h"
#include "types.h"