mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 05:56:48 +02: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:
parent
6947b3a5d1
commit
dfc53c781a
@ -202,3 +202,10 @@ Tool path optimization:
|
||||
Try to reduce the movements made between paths by reordering the paths.
|
||||
Note that this disturbs the order generated by "offset" and should thus
|
||||
not be used on paths that to be executed in a specific sequence.
|
||||
|
||||
|
||||
Statistics:
|
||||
|
||||
stats
|
||||
|
||||
Prints the number of paths and segments, plus their total length.
|
||||
|
@ -2,8 +2,8 @@
|
||||
/*
|
||||
* lang.l - Toolpath adaptation language
|
||||
*
|
||||
* Written 2010 by Werner Almesberger
|
||||
* Copyright 2010 by Werner Almesberger
|
||||
* Written 2010-2011 by Werner Almesberger
|
||||
* Copyright 2010-2011 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -50,6 +50,7 @@ NUM -?[0-9]+\.?[0-9]*
|
||||
<INITIAL>remainder return TOK_REMAINDER;
|
||||
<INITIAL>reset return TOK_RESET;
|
||||
<INITIAL>rotate return TOK_ROTATE;
|
||||
<INITIAL>stats return TOK_STATS;
|
||||
<INITIAL>translate return TOK_TRANSLATE;
|
||||
<INITIAL>z return TOK_Z;
|
||||
|
||||
|
10
cameo/lang.y
10
cameo/lang.y
@ -2,8 +2,8 @@
|
||||
/*
|
||||
* lang.y - Toolpath adaptation language
|
||||
*
|
||||
* Written 2010 by Werner Almesberger
|
||||
* Copyright 2010 by Werner Almesberger
|
||||
* Written 2010-2011 by Werner Almesberger
|
||||
* Copyright 2010-2011 by Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -187,7 +187,7 @@ static struct path **classify(struct path **anchor, struct path *path)
|
||||
|
||||
%token TOK_ALIGN TOK_ARRAY TOK_CLEAR TOK_DRILL TOK_EMPTY
|
||||
%token TOK_MILL TOK_OFFSET TOK_OPTIMIZE TOK_REMAINDER TOK_RESET
|
||||
%token TOK_ROTATE TOK_TRANSLATE TOK_Z
|
||||
%token TOK_ROTATE TOK_STATS TOK_TRANSLATE TOK_Z
|
||||
%token TOK_APPEND TOK_GERBER TOK_GNUPLOT TOK_EXCELLON TOK_WRITE
|
||||
%token TOK_DOG TOK_INSIDE
|
||||
|
||||
@ -253,6 +253,10 @@ command:
|
||||
rotate(paths, $2);
|
||||
rot += $2;
|
||||
}
|
||||
| TOK_STATS
|
||||
{
|
||||
path_stats(paths);
|
||||
}
|
||||
| TOK_TRANSLATE dimen dimen
|
||||
{
|
||||
translate(paths, $2, $3, 0);
|
||||
|
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);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* path.h - Toolpath operations
|
||||
*
|
||||
* Written 2010 by Werner Almesberger
|
||||
* Copyright 2010 Werner Almesberger
|
||||
* Written 2010-2011 by Werner Almesberger
|
||||
* Copyright 2010-2011 Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -38,5 +38,6 @@ struct path *path_offset(const struct path *path, int left, int notch);
|
||||
struct path *path_find_leftmost(struct path *path);
|
||||
void path_free(struct path *path);
|
||||
struct path *path_connect(struct path *path);
|
||||
void path_stats(const struct path *path);
|
||||
|
||||
#endif /* !PATH_H */
|
||||
|
Loading…
Reference in New Issue
Block a user