diff --git a/cameo/README b/cameo/README index 0af9613..4d8ce38 100644 --- a/cameo/README +++ b/cameo/README @@ -137,7 +137,7 @@ better to use it only with "clean".) Vertical adjustment: z [] - + Tool compensation: @@ -174,6 +174,13 @@ If the current paths have different Z coordinates, each level is processed separately. +Path reversal: + + reverse + +Reverses all paths. This can be used to reverse tool direction. + + Drill/mill conversion: drill diff --git a/cameo/lang.l b/cameo/lang.l index 361588c..9c64ff8 100644 --- a/cameo/lang.l +++ b/cameo/lang.l @@ -50,6 +50,7 @@ NUM -?[0-9]+\.?[0-9]* optimize return TOK_OPTIMIZE; remainder return TOK_REMAINDER; reset return TOK_RESET; +reverse return TOK_REVERSE; rotate return TOK_ROTATE; stats return TOK_STATS; translate return TOK_TRANSLATE; diff --git a/cameo/lang.y b/cameo/lang.y index 677bcf8..d7c7536 100644 --- a/cameo/lang.y +++ b/cameo/lang.y @@ -189,7 +189,7 @@ static struct path **classify(struct path **anchor, struct path *path) %token TOK_ALIGN TOK_ARRAY TOK_CLEAR TOK_DRILL TOK_EMPTY TOK_AREA %token TOK_MILL TOK_OFFSET TOK_OPTIMIZE TOK_REMAINDER TOK_RESET -%token TOK_ROTATE TOK_STATS TOK_TRANSLATE TOK_Z +%token TOK_REVERSE TOK_ROTATE TOK_STATS TOK_TRANSLATE TOK_Z %token TOK_APPEND TOK_GERBER TOK_GNUPLOT TOK_EXCELLON TOK_WRITE %token TOK_DOG TOK_INSIDE TOK_ANY @@ -255,6 +255,14 @@ command: { paths = optimize_paths(paths); } + | TOK_REVERSE + { + struct path *tmp; + + tmp = reverse_paths(paths); + clear_paths(); + paths = tmp; + } | TOK_ROTATE number { rotate(paths, $2); diff --git a/cameo/ops.c b/cameo/ops.c index a90599f..545647a 100644 --- a/cameo/ops.c +++ b/cameo/ops.c @@ -1,8 +1,8 @@ /* * ops.c - Higher-level toolpath operations * - * Written 2010-2011 by Werner Almesberger - * Copyright 2010-2011 Werner Almesberger + * Written 2010-2012 by Werner Almesberger + * Copyright 2010-2012 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 @@ -140,3 +140,16 @@ struct path *optimize_paths(struct path *paths) } return res; } + + +struct path *reverse_paths(const struct path *paths) +{ + const struct path *path; + struct path *res = NULL, **last = &res; + + for (path = paths; path; path = path->next) { + *last = path_reverse(path); + last = &(*last)->next; + } + return res; +} diff --git a/cameo/ops.h b/cameo/ops.h index 4e8d9fb..f1e381b 100644 --- a/cameo/ops.h +++ b/cameo/ops.h @@ -1,8 +1,8 @@ /* * ops.h - Higher-level toolpath operations * - * Written 2010-2011 by Werner Almesberger - * Copyright 2010-2011 Werner Almesberger + * Written 2010-2012 by Werner Almesberger + * Copyright 2010-2012 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 @@ -22,5 +22,6 @@ struct path *tool_comp_paths(const struct path *paths, int dog_bone, struct path *try_drill(struct path *path, double d_min, double d_max); struct path *try_mill(struct path *path, double diam, double step, int any); struct path *optimize_paths(struct path *paths); +struct path *reverse_paths(const struct path *paths); #endif /* !OPS_H */