]> git.draconx.ca Git - slotifier.git/blobdiff - src/slotifier.c
Fix radius/diameter confusion in overlap search.
[slotifier.git] / src / slotifier.c
index 6ca3213ff14ed91937605e5f38f0f07d02cf6ac1..b74a9ecf5112c0daa4b3bd41c1ec1b1296af5ef4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Utility to convert overlapping Excellon drill hits into drill slots.
- * Copyright © 2018 Nick Bowler
+ * Copyright © 2018, 2021 Nick Bowler
  *
  * 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
@@ -63,7 +63,7 @@ static void print_version(void)
                        copysign = convsign;
        }
 
-       printf("Copyright %s 2018 Nick Bowler.\n", copysign);
+       printf("Copyright %s 2021 Nick Bowler.\n", copysign);
        puts("License GPLv3+: GNU GPL version 3 or any later version.");
        puts("This is free software: you are free to change and redistribute it.");
        puts("There is NO WARRANTY, to the extent permitted by law.");
@@ -221,7 +221,7 @@ static int combine_holes(gerbv_image_t *drill, gerbv_net_t *hole,
        hole->aperture = -hole->aperture;
 
        for (i = 0; i < CVectorSize(group); i++) {
-               double xy[2], dia;
+               double xy[2], dia, r;
 
                CVectorGetElement(group, &hole, i);
                tool = drill->aperture[abs(hole->aperture)];
@@ -230,10 +230,13 @@ static int combine_holes(gerbv_image_t *drill, gerbv_net_t *hole,
                xy[0] = hole->start_x; xy[1] = hole->start_y;
                dia = tool->parameter[0];
 
+               /* Half a mil slop to decisively include points on boundary. */
+               r = dia/2 + 0.0005;
+
                if (drill->aperture[biggest_tool]->parameter[0] < dia)
                        biggest_tool = abs(hole->aperture);
 
-               if (CNearTreeFindInSphere(t, dia, 0, tmp, xy, 1) != 0) {
+               if (CNearTreeFindInSphere(t, r, 0, tmp, xy, 1) != 0) {
                        /* We should always should find at least one hole! */
                        fprintf(stderr, _("%s: fatal error searching holes\n"),
                                        progname);