diff --git a/cameo/README b/cameo/README index 3116f37..1291851 100644 --- a/cameo/README +++ b/cameo/README @@ -110,4 +110,15 @@ Vertical adjustment: Tool compensation: - tool [dog] + offset [dog] [inside] + +"offset" offsets the toolpaths by the tool radius. By default, it offsets +the outermost toolpath to the outside and all other toolpaths to the +inside. This can be overridden with the #%outside directive in a gnuplot +file or the "inside" option to "offset". "inside" has precedence over +"#%outside". + +Concave corners on an outside path are normally cut such that the corner +is round, leaving material at and near the corner point. The option "dog" +changes this to cutting a "dogbone" hole such that material is also +removed up to the corner point. diff --git a/cameo/cameo.c b/cameo/cameo.c index 6f4ed48..93250e5 100644 --- a/cameo/cameo.c +++ b/cameo/cameo.c @@ -100,7 +100,7 @@ int main(int argc, char **argv) paths = gerber_read(in, r); else paths = gnuplot_read(in, r); - tool_comp_paths(paths, dog_bone); + tool_comp_paths(paths, dog_bone, 0); gnuplot_write(out, paths); return 0; diff --git a/cameo/lang.l b/cameo/lang.l index 024bd2b..4672734 100644 --- a/cameo/lang.l +++ b/cameo/lang.l @@ -43,7 +43,7 @@ NUM -?[0-9]+\.?[0-9]* array return TOK_ARRAY; clear return TOK_CLEAR; reset return TOK_RESET; -tool return TOK_TOOL; +offset return TOK_OFFSET; translate return TOK_TRANSLATE; z return TOK_Z; @@ -55,6 +55,7 @@ NUM -?[0-9]+\.?[0-9]* return TOK_WRITE; } dog return TOK_DOG; +inside return TOK_INSIDE; mm metric = 1; mil metric = 0; diff --git a/cameo/lang.y b/cameo/lang.y index 468246e..566c32b 100644 --- a/cameo/lang.y +++ b/cameo/lang.y @@ -113,19 +113,24 @@ static void align(int ref, double x, double y) %union { double num; char *str; + enum { + OO_DOG = 1 << 0, + OO_INSIDE = 1 << 1, + } oopt; }; -%token TOK_ALIGN TOK_ARRAY TOK_CLEAR TOK_RESET TOK_TOOL +%token TOK_ALIGN TOK_ARRAY TOK_CLEAR TOK_RESET TOK_OFFSET %token TOK_TRANSLATE TOK_Z %token TOK_GERBER TOK_GNUPLOT TOK_WRITE -%token TOK_DOG +%token TOK_DOG TOK_INSIDE %token NUM_EXP_MIL NUM_EXP_MM NUM_IMP_MIL NUM_IMP_MM REF %token STRING %type opt_filename %type dimen number +%type offset_options offset_option %% @@ -172,13 +177,10 @@ command: { xo = yo = 0; } - | TOK_TOOL + | TOK_OFFSET offset_options { - tool_comp_paths(paths, 0); - } - | TOK_TOOL TOK_DOG - { - tool_comp_paths(paths, 1); + tool_comp_paths(paths, + !!($2 & OO_DOG), !!($2 & OO_INSIDE)); } | TOK_TRANSLATE dimen dimen { @@ -251,3 +253,25 @@ number: $$ = $1; } ; + +offset_options: + { + $$ = 0; + } + | offset_option offset_options + { + $$ = $1 | $2; + + } + ; + +offset_option: + TOK_DOG + { + $$ = OO_DOG; + } + | TOK_INSIDE + { + $$ = OO_INSIDE; + } + ; diff --git a/cameo/ops.c b/cameo/ops.c index 733b130..74c4cfa 100644 --- a/cameo/ops.c +++ b/cameo/ops.c @@ -29,7 +29,7 @@ static void tool_comp_1(struct path *path, int inside, int dog_bone) } -void tool_comp_paths(struct path *paths, int dog_bone) +void tool_comp_paths(struct path *paths, int dog_bone, int all_inside) { struct path *leftmost, *path; @@ -46,10 +46,11 @@ void tool_comp_paths(struct path *paths, int dog_bone) leftmost = path_find_leftmost(paths); for (path = paths; path; path = path->next) - if (path != leftmost && !path->outside) + if (path != leftmost && (all_inside || !path->outside)) tool_comp_1(path, 1, dog_bone); - for (path = paths; path; path = path->next) - if (path != leftmost && path->outside) - tool_comp_1(path, 0, dog_bone); - tool_comp_1(leftmost, 0, dog_bone); + if (!all_inside) + for (path = paths; path; path = path->next) + if (path != leftmost && path->outside) + tool_comp_1(path, 0, dog_bone); + tool_comp_1(leftmost, !all_inside, dog_bone); } diff --git a/cameo/ops.h b/cameo/ops.h index 50d6646..a40fcf9 100644 --- a/cameo/ops.h +++ b/cameo/ops.h @@ -18,6 +18,6 @@ #include "path.h" -void tool_comp_paths(struct path *paths, int dog_bone); +void tool_comp_paths(struct path *paths, int dog_bone, int all_inside); #endif /* !OPS_H */