mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-01-09 02:00:14 +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>dog return TOK_DOG;
|
||||||
<INITIAL>inside return TOK_INSIDE;
|
<INITIAL>inside return TOK_INSIDE;
|
||||||
|
|
||||||
|
<INITIAL>any return TOK_ANY;
|
||||||
|
|
||||||
<INITIAL>mm metric = 1;
|
<INITIAL>mm metric = 1;
|
||||||
<INITIAL>mil metric = 0;
|
<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 {
|
%union {
|
||||||
double num;
|
double num;
|
||||||
char *str;
|
char *str;
|
||||||
|
int flag;
|
||||||
enum {
|
enum {
|
||||||
OO_DOG = 1 << 0,
|
OO_DOG = 1 << 0,
|
||||||
OO_INSIDE = 1 << 1,
|
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_MILL TOK_OFFSET TOK_OPTIMIZE TOK_REMAINDER TOK_RESET
|
||||||
%token TOK_ROTATE TOK_STATS 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_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 <num> NUM_EXP_MIL NUM_EXP_MM NUM_IMP_MIL NUM_IMP_MM REF
|
||||||
%token <str> STRING
|
%token <str> STRING
|
||||||
|
|
||||||
%type <str> opt_filename
|
%type <str> opt_filename
|
||||||
%type <num> dimen number x_size y_size
|
%type <num> dimen number x_size y_size
|
||||||
|
%type <flag> opt_any
|
||||||
%type <oopt> offset_options offset_option
|
%type <oopt> offset_options offset_option
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@ -321,7 +323,7 @@ command:
|
|||||||
walk =
|
walk =
|
||||||
classify(walk, try_drill(*walk, $2, $4));
|
classify(walk, try_drill(*walk, $2, $4));
|
||||||
}
|
}
|
||||||
| TOK_MILL dimen dimen
|
| TOK_MILL opt_any dimen dimen
|
||||||
{
|
{
|
||||||
struct path **walk;
|
struct path **walk;
|
||||||
|
|
||||||
@ -329,7 +331,8 @@ command:
|
|||||||
paths = NULL;
|
paths = NULL;
|
||||||
walk = &remain;
|
walk = &remain;
|
||||||
while (*walk)
|
while (*walk)
|
||||||
walk = classify(walk, try_mill(*walk, $2, $3));
|
walk = classify(walk,
|
||||||
|
try_mill(*walk, $3, $4, $2));
|
||||||
}
|
}
|
||||||
| TOK_REMAINDER
|
| TOK_REMAINDER
|
||||||
{
|
{
|
||||||
@ -437,3 +440,13 @@ offset_option:
|
|||||||
opt_comma:
|
opt_comma:
|
||||||
| ','
|
| ','
|
||||||
;
|
;
|
||||||
|
|
||||||
|
opt_any:
|
||||||
|
{
|
||||||
|
$$ = 0;
|
||||||
|
}
|
||||||
|
| TOK_ANY
|
||||||
|
{
|
||||||
|
$$ = 1;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* ops.c - Higher-level toolpath operations
|
* ops.c - Higher-level toolpath operations
|
||||||
*
|
*
|
||||||
* Written 2010 by Werner Almesberger
|
* Written 2010-2011 by Werner Almesberger
|
||||||
* Copyright 2010 Werner Almesberger
|
* Copyright 2010-2011 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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;
|
return NULL;
|
||||||
if (!path->first)
|
if (!path->first)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* ops.h - Higher-level toolpath operations
|
* ops.h - Higher-level toolpath operations
|
||||||
*
|
*
|
||||||
* Written 2010 by Werner Almesberger
|
* Written 2010-2011 by Werner Almesberger
|
||||||
* Copyright 2010 Werner Almesberger
|
* Copyright 2010-2011 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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);
|
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_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);
|
struct path *optimize_paths(struct path *paths);
|
||||||
|
|
||||||
#endif /* !OPS_H */
|
#endif /* !OPS_H */
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* shape.c - Toolpaths for basic shapes
|
* shape.c - Toolpaths for basic shapes
|
||||||
*
|
*
|
||||||
* Written 2010 by Werner Almesberger
|
* Written 2010-2011 by Werner Almesberger
|
||||||
* Copyright 2010 Werner Almesberger
|
* Copyright 2010-2011 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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 nx, ny;
|
||||||
double f;
|
double f;
|
||||||
|
|
||||||
f = (sr-tr)/hypot(dx, dy);
|
|
||||||
nx = -dy*f;
|
|
||||||
ny = dx*f;
|
|
||||||
|
|
||||||
path = path_new(tr);
|
path = path_new(tr);
|
||||||
half_circle(xa, ya, nx, ny, z, s);
|
if (sr <= tr) {
|
||||||
half_circle(xb, yb, -nx, -ny, z, s);
|
path_add(path, xa, ya, z);
|
||||||
path_add(path, xa+nx, ya+ny, 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;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +81,13 @@ struct path *circle(double cx, double cy, double cz, double cr, double tr,
|
|||||||
double a;
|
double a;
|
||||||
|
|
||||||
path = path_new(tr);
|
path = path_new(tr);
|
||||||
for (a = 0; a < 2*M_PI; a += s)
|
if (cr <= tr) {
|
||||||
path_add(path, cx+(cr-tr)*cos(a), cy+(cr-tr)*sin(a), cz);
|
path_add(path, cx, cy, cz);
|
||||||
path_add(path, cx+(cr-tr), 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;
|
return path;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user