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:
22
cameo/path.c
22
cameo/path.c
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user