xdot* xd = NULL;
if ((p = agget(g, "_draw_")) && p[0]) {
+#ifdef DEBUG
+ if (Verbose) {
+ start_timer();
+ }
+#endif
xd = parseXDotF (p, NULL, sizeof (exdot_op));
if (!xd) {
agerr(AGWARN, "Could not parse \"_draw_\" attribute in graph %s\n", agnameof(g));
agerr(AGPREV, " \"%s\"\n", p);
}
+#ifdef DEBUG
+ if (Verbose) {
+ xdot_stats stats;
+ double et = elapsed_sec();
+ statXDot (xd, &stats);
+ fprintf (stderr, "%d ops %.2f sec\n", stats.cnt, et);
+ fprintf (stderr, "%d polygons %d points\n", stats.n_polygon, stats.n_polygon_pts);
+ fprintf (stderr, "%d polylines %d points\n", stats.n_polyline, stats.n_polyline_pts);
+ fprintf (stderr, "%d beziers %d points\n", stats.n_bezier, stats.n_bezier_pts);
+ fprintf (stderr, "%d ellipses\n", stats.n_ellipse);
+ fprintf (stderr, "%d texts\n", stats.n_text);
+ }
+#endif
}
return xd;
}
static char *parseInt(char *s, int *ip)
{
- int r, sz;
+ char* endp;
+
+#ifdef UNUSED
r = sscanf(s, "%d%n", ip, &sz);
if (r != 1) return 0;
else return (s + sz);
+#endif
+
+ *ip = (int)strtol (s, &endp, 10);
+ if (s == endp)
+ return 0;
+ else
+ return endp;
}
+
#ifdef UNUSED
static char *parsePoint(char *s, xdot_point * pp)
{
static char *parseRect(char *s, xdot_rect * rp)
{
+ char* endp;
+#ifdef UNUSED
int r, sz;
r = sscanf(s, "%lf %lf %lf %lf%n", &(rp->x), &(rp->y), &(rp->w),
&(rp->h), &sz);
if (r != 4) return 0;
else return (s + sz);
+#endif
+
+ rp->x = strtod (s, &endp);
+ if (s == endp)
+ return 0;
+ else
+ s = endp;
+
+ rp->y = strtod (s, &endp);
+ if (s == endp)
+ return 0;
+ else
+ s = endp;
+
+ rp->w = strtod (s, &endp);
+ if (s == endp)
+ return 0;
+ else
+ s = endp;
+
+ rp->y = strtod (s, &endp);
+ if (s == endp)
+ return 0;
+ else
+ s = endp;
+
+ return s;
}
static char *parsePolyline(char *s, xdot_polyline * pp)
free(x);
}
+int statXDot (xdot* x, xdot_stats* sp)
+{
+ int i;
+ xdot_op *op;
+ char *base;
+
+ if (!x || !sp) return 1;
+ memset(sp, 0, sizeof(xdot_stats));
+ sp->cnt = x->cnt;
+ base = (char *) (x->ops);
+ for (i = 0; i < x->cnt; i++) {
+ op = (xdot_op *) (base + i * x->sz);
+ switch (op->kind) {
+ case xd_filled_ellipse:
+ case xd_unfilled_ellipse:
+ sp->n_ellipse++;
+ break;
+ case xd_filled_polygon:
+ case xd_unfilled_polygon:
+ sp->n_polygon++;
+ sp->n_polygon_pts += op->u.polygon.cnt;
+ break;
+ case xd_filled_bezier:
+ case xd_unfilled_bezier:
+ sp->n_bezier++;
+ sp->n_bezier_pts += op->u.bezier.cnt;
+ break;
+ case xd_polyline:
+ sp->n_polyline++;
+ sp->n_polyline_pts += op->u.polyline.cnt;
+ break;
+ case xd_text:
+ sp->n_text++;
+ break;
+ default :
+ break;
+ }
+ }
+
+ return 0;
+}
+
#if 0
static void execOp(xdot_op * op, int param)
{
int flags;
} xdot;
+typedef struct {
+ int cnt; /* no. of xdot ops */
+ int n_ellipse;
+ int n_polygon;
+ int n_polygon_pts;
+ int n_polyline;
+ int n_polyline_pts;
+ int n_bezier;
+ int n_bezier_pts;
+ int n_text;
+} xdot_stats;
+
/* ops are indexed by xop_kind */
extern xdot* parseXDotF (char*, drawfunc_t opfns[], int sz);
extern xdot* parseXDotFOn (char*, drawfunc_t opfns[], int sz, xdot*);
extern char* sprintXDot (xdot*);
extern void fprintXDot (FILE*, xdot*);
extern void freeXDot (xdot*);
+extern int statXDot (xdot*, xdot_stats*);
#endif