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

cameo: adding support for dril/mill substitutions (in progress)

- Makefile (OBJS): added shape.o
- README: added section for drill/mill substitutions
- lang.l, lang.y: added commands "drill", "empty", "mill", "remainder", and
  "reset"
- lang.y (clear_paths): moved freeing of all paths from "clean" to shared
  function clear_paths
- ops.h, ops.c (try_drill, try_mill): helper functions for "drill" and
  "mill" commands
- shape.h. shape.c (slot, circle): functions to generate toolpaths for
  basic shapes
This commit is contained in:
Werner Almesberger
2010-12-15 04:56:58 -03:00
parent 848eb2a209
commit b1652fc50a
8 changed files with 222 additions and 11 deletions

View File

@@ -25,6 +25,7 @@
static double xo = 0, yo = 0, zo = 0;
static struct path *paths = NULL;
static struct path *remain = NULL;
#define MIL2MM(mil) ((mil)/1000*25.4)
@@ -108,6 +109,33 @@ static void align(int ref, double x, double y)
}
static void clear_paths(void)
{
struct path *next;
while (paths) {
next = paths->next;
path_free(paths);
paths = next;
}
}
static struct path **classify(struct path **anchor, struct path *path)
{
struct path **walk, *next;
if (!path)
return &(*anchor)->next;
for (walk = &paths; *walk; walk = &(*walk)->next);
*walk = path;
next = (*anchor)->next;
path_free(*anchor);
*anchor = next;
return anchor;
}
%}
@@ -121,7 +149,8 @@ static void align(int ref, double x, double y)
};
%token TOK_ALIGN TOK_ARRAY TOK_CLEAR TOK_RESET TOK_OFFSET
%token TOK_ALIGN TOK_ARRAY TOK_CLEAR TOK_DRILL TOK_EMPTY
%token TOK_MILL TOK_OFFSET TOK_REMAINDER TOK_RESET
%token TOK_TRANSLATE TOK_Z
%token TOK_GERBER TOK_GNUPLOT TOK_EXCELLON TOK_WRITE
%token TOK_DOG TOK_INSIDE
@@ -166,13 +195,7 @@ command:
}
| TOK_CLEAR
{
struct path *next;
while (paths) {
next = paths->next;
path_free(paths);
paths = next;
}
clear_paths();
}
| TOK_RESET
{
@@ -218,6 +241,38 @@ command:
gnuplot_write($2, paths);
translate(0, 0, -zo);
}
| TOK_DRILL dimen dimen
{
struct path **walk;
remain = paths;
paths = NULL;
walk = &paths;
while (*walk)
walk =
classify(walk, try_drill(*walk, $2, $3));
}
| TOK_MILL dimen dimen
{
struct path **walk;
remain = paths;
paths = NULL;
walk = &paths;
while (*walk)
walk = classify(walk, try_mill(*walk, $2, $3));
}
| TOK_REMAINDER
{
clear_paths();
paths = remain;
remain = NULL;
}
| TOK_EMPTY
{
if (paths)
yyerror("path list is not empty");
}
;
opt_filename: