cameo/gerber.c |
1 | 1 | /* |
2 | 2 | * gerber.c - Gerber file input |
3 | 3 | * |
4 | | * Written 2010, 2013, 2015 by Werner Almesberger |
5 | | * Copyright 2010, 2013, 2015 Werner Almesberger |
| 4 | * Written 2010, 2013, 2015, 2017 by Werner Almesberger |
| 5 | * Copyright 2010, 2013, 2015, 2017 Werner Almesberger |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU General Public License as published by |
... | ... | |
27 | 27 | #include "gerber.h" |
28 | 28 | |
29 | 29 | |
30 | | /* KiCad Gerber uses 0.1 mil units */ |
| 30 | static double scale; /* KiCad Gerber units */ |
31 | 31 | |
32 | | #define KU2MM(in) ((in)/10000.0*25.4) |
| 32 | #define KU2MM(in) ((in)/scale) |
33 | 33 | |
34 | 34 | |
35 | 35 | /* |
... | ... | |
90 | 90 | while (fgets(buf, sizeof(buf), file)) { |
91 | 91 | lineno++; |
92 | 92 | if (!strncmp(buf, "%FS", 3)) { |
93 | | if (strcmp(buf, "%FSLAX34Y34*%\n")) { |
| 93 | if (!strcmp(buf, "%FSLAX34Y34*%\n")) { |
| 94 | scale = 10 * 1000; |
| 95 | } else if (!strcmp(buf, "%FSLAX46Y46*%\n")) { |
| 96 | scale = 1000 * 1000; |
| 97 | } else { |
94 | 98 | fprintf(stderr, |
95 | 99 | "unrecognized format %s\n", buf); |
96 | 100 | exit(1); |
97 | 101 | } |
98 | 102 | continue; |
99 | 103 | } |
| 104 | /* @@@ we assume that %MO follows %FS */ |
100 | 105 | if (!strncmp(buf, "%MO", 3)) { |
101 | | if (strcmp(buf, "%MOIN*%\n")) { |
| 106 | if (!strcmp(buf, "%MOIN*%\n")) { |
| 107 | scale /= 25.4; |
| 108 | } else if (strcmp(buf, "%MOMM*%\n")) { |
102 | 109 | fprintf(stderr, |
103 | 110 | "unrecognized mode %s\n", buf); |
104 | 111 | exit(1); |