comparison pads2gpcb/decals.c @ 52:727d4e56d5c8

pads2gpcb/decals.c: silk line extraction implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 31 Jan 2016 01:26:11 +0000
parents b3b7013d9228
children 0e18818206e5
comparison
equal deleted inserted replaced
51:f2bcf69fce63 52:727d4e56d5c8
10 10
11 static struct part_decal *current_decal; 11 static struct part_decal *current_decal;
12 static struct footprint_body fpbody; 12 static struct footprint_body fpbody;
13 static struct footprint_pad *pins_array; 13 static struct footprint_pad *pins_array;
14 14
15 #define MAX_SILK_LINES 16
16 static struct element_line silk_lines[MAX_SILK_LINES];
17 static struct element_arc silk_arcs[MAX_SILK_LINES];
18 static int num_silk_lines;
19 static int num_silk_arcs;
20
15 #define SOLDERMASK_DELTA (600 * 254) 21 #define SOLDERMASK_DELTA (600 * 254)
16 #define CLEARANCE_SETTING (2000 * 254) 22 #define CLEARANCE_SETTING (2000 * 254)
17 23
18 static void 24 static void
19 enter_decal() 25 enter_decal()
49 "error: EOF in the middle of a part decal definition\n"); 55 "error: EOF in the middle of a part decal definition\n");
50 exit(1); 56 exit(1);
51 } 57 }
52 } 58 }
53 59
60 static
61 try_silk_open_closed()
62 {
63 int ncoord, i, bad;
64 long x[MAX_SILK_LINES+1], y[MAX_SILK_LINES+1];
65 long thickness;
66
67 if (strcmp(input_line_fields[0], "OPEN") &&
68 strcmp(input_line_fields[0], "CLOSED"))
69 return(0);
70 if (input_line_nfields != 5)
71 return(0);
72 if (strcmp(input_line_fields[4], "0"))
73 return(0);
74 ncoord = atoi(input_line_fields[1]);
75 if (ncoord < 2) {
76 printf("line %d: silk %s piece ncoord < 2\n", input_lineno,
77 input_line_fields[0]);
78 return(0);
79 }
80 if (ncoord > MAX_SILK_LINES + 1) {
81 printf("line %d: silk %s piece ncoord too big\n", input_lineno,
82 input_line_fields[0]);
83 return(0);
84 }
85 thickness = convert_input_dim(input_line_fields[2]);
86
87 bad = 0;
88 for (i = 0; i < ncoord; i++) {
89 get_line_internal();
90 if (input_line_nfields != 2) {
91 printf("line %d: silk line coord not 2 numbers\n",
92 input_lineno);
93 bad = 1;
94 continue;
95 }
96 x[i] = convert_input_dim(input_line_fields[0]);
97 y[i] = -convert_input_dim(input_line_fields[1]);
98 }
99 if (bad)
100 return(1);
101
102 for (i = 0; i < ncoord - 1; i++) {
103 if (num_silk_lines >= MAX_SILK_LINES) {
104 printf("Too many silk lines!\n");
105 return(1);
106 }
107 silk_lines[num_silk_lines].x1 = x[i];
108 silk_lines[num_silk_lines].y1 = y[i];
109 silk_lines[num_silk_lines].x2 = x[i+1];
110 silk_lines[num_silk_lines].y2 = y[i+1];
111 silk_lines[num_silk_lines].thickness = thickness;
112 num_silk_lines++;
113 }
114 return(1);
115 }
116
117 static
118 try_silk_circle()
119 {
120 return(0);
121 }
122
54 static void 123 static void
55 one_drawing_piece() 124 one_drawing_piece()
56 { 125 {
57 int ncoord, i; 126 int ncoord, i;
58 127
59 /* just skip it for now */ 128 /* extract silk lines and arcs if enabled, otherwise skip */
60 get_line_internal(); 129 get_line_internal();
61 parse_input_line_fields(); 130 parse_input_line_fields();
62 if (input_line_nfields < 2) { 131 if (input_line_nfields < 2) {
63 fprintf(stderr, 132 fprintf(stderr,
64 "%s line %d: expected piece header line giving # of coords\n", 133 "%s line %d: expected piece header line giving # of coords\n",
65 input_filename, input_lineno); 134 input_filename, input_lineno);
66 exit(1); 135 exit(1);
136 }
137 if (do_footprint_silk) {
138 if (try_silk_open_closed())
139 return;
140 if (try_silk_circle())
141 return;
67 } 142 }
68 ncoord = atoi(input_line_fields[1]); 143 ncoord = atoi(input_line_fields[1]);
69 for (i = 0; i < ncoord; i++) 144 for (i = 0; i < ncoord; i++)
70 get_line_internal(); 145 get_line_internal();
71 } 146 }
342 exit(1); 417 exit(1);
343 } 418 }
344 419
345 /* done parsing the header line, initialize some misc */ 420 /* done parsing the header line, initialize some misc */
346 fpbody.refdes_scale = 100; 421 fpbody.refdes_scale = 100;
422 num_silk_lines = 0;
423 num_silk_arcs = 0;
347 424
348 /* read and process the miscellany */ 425 /* read and process the miscellany */
349 for (i = 0; i < num_drawing_pieces; i++) 426 for (i = 0; i < num_drawing_pieces; i++)
350 one_drawing_piece(); 427 one_drawing_piece();
351 for (i = 0; i < num_text_items; i++) 428 for (i = 0; i < num_text_items; i++)