Date:2011-01-31 23:36:59 (13 years 1 month ago)
Author:Werner Almesberger
Commit:6947b3a5d1e27d3238182cf822e474ca2ad504ec
Message:cameo: allow for rounding errors KiCad produces with a metric grid

- cameo/path.c (path_is_closed): use points_eq instead of open-coding the
comparison
- cameo//path.c (EPSILON_MM, points_eq): consider two points as equal if
their projections on the xy plane are less than EPSILON_MM apart and
their z positions don't differ by more than the same distance
Files: cameo/path.c (4 diffs)

Change Details

cameo/path.c
11/*
22 * path.c - Toolpath operations
33 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 Werner Almesberger
4 * Written 2010-2011 by Werner Almesberger
5 * Copyright 2010-2011 Werner Almesberger
66 *
77 * This program is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
...... 
2020#include "path.h"
2121
2222
23/*
24 * We allow for a bit of tolerance, to absorb the rounding errors KiCad
25 * produces with designs using a metric grid.
26 */
27
28#define EPSILON_MM 0.006 /* 6 um */
29
30
2331static void free_points(struct point *points)
2432{
2533    struct point *next;
...... 
7785}
7886
7987
88static int points_eq(const struct point *a, const struct point *b)
89{
90    if (hypot(a->x-b->x, a->y-b->y) > EPSILON_MM)
91        return 0;
92    if (fabs(a->z-b->z) > EPSILON_MM)
93        return 0;
94    return 1;
95}
96
97
8098static int path_is_closed(const struct path *path)
8199{
82100    if (path->first == path->last)
83101        return 1;
84    return path->first->x == path->last->x &&
85        path->first->y == path->last->y && path->first->z == path->last->z;
102    return points_eq(path->first, path->last);
86103}
87104
88105
...... 
347364}
348365
349366
350static int points_eq(const struct point *a, const struct point *b)
351{
352    return a->x == b->x && a->y == b->y && a->z == b->z;
353}
354
355
356367static int attr_eq(const struct path *a, const struct path *b)
357368{
358369    return a->r_tool == b->r_tool && a->outside == b->outside &&

Archive Download the corresponding diff file

Branches:
master



interactive