1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-04-21 12:27:27 +03:00

cameo: new command "stats" to print path statistics

- README: documented the "stats" command
- lang.l, lang.y: added "stats" command
- path.h (path_stats), path.c (path_stats): calculate and print path
  statistics
This commit is contained in:
Werner Almesberger
2011-02-13 02:25:32 -03:00
parent 6947b3a5d1
commit dfc53c781a
5 changed files with 42 additions and 7 deletions

View File

@@ -406,3 +406,25 @@ again:
}
return path;
}
void path_stats(const struct path *path)
{
int paths = 0, segs = 0;
double len = 0;
const struct point *p;
while (path) {
paths++;
for (p = path->first; p; p = p->next) {
if (!p->next)
continue;
segs++;
len += hypot(hypot(p->x-p->next->x, p->y-p->next->y),
p->z-p->next->z);
}
path = path->next;
}
fprintf(stderr, "%d path%s, %d segment%s, %f mm\n",
paths, paths == 1 ? "" : "s", segs, segs == 1 ? "" : "s", len);
}