/* * path.h - Toolpath operations * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #ifndef PATH_H #define PATH_H #include struct point { double x, y, z; /* mm */ struct point *next; }; struct path { struct point *first, *last; double r_tool; /* mm */ int outside; /* non-zero to mark path as an outside edge */ int notch; /* non-zero to enable dog-boning for path */ const char *id; /* identifier assigned by generator */ struct path *next; }; /* * We allow for a bit of tolerance, to absorb the rounding errors KiCad * produces with designs using a metric grid. */ #define EPSILON_MM 0.006 /* 6 um */ static inline int points_eq(const struct point *a, const struct point *b) { if (hypot(a->x-b->x, a->y-b->y) > EPSILON_MM) return 0; if (fabs(a->z-b->z) > EPSILON_MM) return 0; return 1; } struct path *path_new(double r_tool, const char *id); void path_add(struct path *path, double x, double y, double z); struct path *path_reverse(const struct path *path); struct path *path_clone(const struct path *path); int path_is_closed(const struct path *path); int path_tool_is_left(const struct path *path); struct path *path_offset(const struct path *path, int left, int notch); const struct path *path_find_leftmost(const struct path *path); int path_is_inside(const struct path *a, const struct path *b); void path_free(struct path *path); struct path *path_connect(struct path *path); void path_stats(const struct path *path); #endif /* !PATH_H */