mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 05:31:10 +02:00
cameo/: added option "any" to "mill", to accept paths irrespective of tool size
This commit is contained in:
parent
54101eaaf4
commit
75c3a7d1d2
@ -68,6 +68,8 @@ NUM -?[0-9]+\.?[0-9]*
|
||||
<INITIAL>dog return TOK_DOG;
|
||||
<INITIAL>inside return TOK_INSIDE;
|
||||
|
||||
<INITIAL>any return TOK_ANY;
|
||||
|
||||
<INITIAL>mm metric = 1;
|
||||
<INITIAL>mil metric = 0;
|
||||
|
||||
|
19
cameo/lang.y
19
cameo/lang.y
@ -178,6 +178,7 @@ static struct path **classify(struct path **anchor, struct path *path)
|
||||
%union {
|
||||
double num;
|
||||
char *str;
|
||||
int flag;
|
||||
enum {
|
||||
OO_DOG = 1 << 0,
|
||||
OO_INSIDE = 1 << 1,
|
||||
@ -189,13 +190,14 @@ static struct path **classify(struct path **anchor, struct path *path)
|
||||
%token TOK_MILL TOK_OFFSET TOK_OPTIMIZE TOK_REMAINDER TOK_RESET
|
||||
%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
|
||||
%token TOK_DOG TOK_INSIDE TOK_ANY
|
||||
|
||||
%token <num> NUM_EXP_MIL NUM_EXP_MM NUM_IMP_MIL NUM_IMP_MM REF
|
||||
%token <str> STRING
|
||||
|
||||
%type <str> opt_filename
|
||||
%type <num> dimen number x_size y_size
|
||||
%type <flag> opt_any
|
||||
%type <oopt> offset_options offset_option
|
||||
|
||||
%%
|
||||
@ -321,7 +323,7 @@ command:
|
||||
walk =
|
||||
classify(walk, try_drill(*walk, $2, $4));
|
||||
}
|
||||
| TOK_MILL dimen dimen
|
||||
| TOK_MILL opt_any dimen dimen
|
||||
{
|
||||
struct path **walk;
|
||||
|
||||
@ -329,7 +331,8 @@ command:
|
||||
paths = NULL;
|
||||
walk = &remain;
|
||||
while (*walk)
|
||||
walk = classify(walk, try_mill(*walk, $2, $3));
|
||||
walk = classify(walk,
|
||||
try_mill(*walk, $3, $4, $2));
|
||||
}
|
||||
| TOK_REMAINDER
|
||||
{
|
||||
@ -437,3 +440,13 @@ offset_option:
|
||||
opt_comma:
|
||||
| ','
|
||||
;
|
||||
|
||||
opt_any:
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| TOK_ANY
|
||||
{
|
||||
$$ = 1;
|
||||
}
|
||||
;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* ops.c - Higher-level 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
|
||||
@ -74,9 +74,9 @@ struct path *try_drill(struct path *path, double d_min, double d_max)
|
||||
}
|
||||
|
||||
|
||||
struct path *try_mill(struct path *path, double diam, double step)
|
||||
struct path *try_mill(struct path *path, double diam, double step, int any)
|
||||
{
|
||||
if (path->r_tool*2 < diam)
|
||||
if (!any && path->r_tool*2 < diam)
|
||||
return NULL;
|
||||
if (!path->first)
|
||||
return NULL;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* ops.h - Higher-level 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
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
void tool_comp_paths(struct path *paths, int dog_bone, int all_inside);
|
||||
struct path *try_drill(struct path *path, double d_min, double d_max);
|
||||
struct path *try_mill(struct path *path, double diam, double step);
|
||||
struct path *try_mill(struct path *path, double diam, double step, int any);
|
||||
struct path *optimize_paths(struct path *paths);
|
||||
|
||||
#endif /* !OPS_H */
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* shape.c - Toolpaths for basic shapes
|
||||
*
|
||||
* 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
|
||||
@ -57,14 +57,19 @@ struct path *slot(double xa, double ya, double xb, double yb, double z,
|
||||
double nx, ny;
|
||||
double f;
|
||||
|
||||
f = (sr-tr)/hypot(dx, dy);
|
||||
nx = -dy*f;
|
||||
ny = dx*f;
|
||||
|
||||
path = path_new(tr);
|
||||
half_circle(xa, ya, nx, ny, z, s);
|
||||
half_circle(xb, yb, -nx, -ny, z, s);
|
||||
path_add(path, xa+nx, ya+ny, z);
|
||||
if (sr <= tr) {
|
||||
path_add(path, xa, ya, z);
|
||||
path_add(path, xb, yb, z);
|
||||
} else {
|
||||
f = (sr-tr)/hypot(dx, dy);
|
||||
nx = -dy*f;
|
||||
ny = dx*f;
|
||||
|
||||
half_circle(xa, ya, nx, ny, z, s);
|
||||
half_circle(xb, yb, -nx, -ny, z, s);
|
||||
path_add(path, xa+nx, ya+ny, z);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -76,8 +81,13 @@ struct path *circle(double cx, double cy, double cz, double cr, double tr,
|
||||
double a;
|
||||
|
||||
path = path_new(tr);
|
||||
for (a = 0; a < 2*M_PI; a += s)
|
||||
path_add(path, cx+(cr-tr)*cos(a), cy+(cr-tr)*sin(a), cz);
|
||||
path_add(path, cx+(cr-tr), cy, cz);
|
||||
if (cr <= tr) {
|
||||
path_add(path, cx, cy, cz);
|
||||
} else {
|
||||
for (a = 0; a < 2*M_PI; a += s)
|
||||
path_add(path,
|
||||
cx+(cr-tr)*cos(a), cy+(cr-tr)*sin(a), cz);
|
||||
path_add(path, cx+(cr-tr), cy, cz);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user