FreeCalypso > hg > ueda-linux
comparison pads2gpcb/decals.c @ 69:a7f0e9bb3fb7
pads2gpcb: struct coord_pair introduced
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 31 Jan 2016 23:41:00 +0000 |
parents | b7f49f029bc3 |
children | fab9fc646044 |
comparison
equal
deleted
inserted
replaced
68:b7f49f029bc3 | 69:a7f0e9bb3fb7 |
---|---|
70 | 70 |
71 static | 71 static |
72 try_silk_open_closed() | 72 try_silk_open_closed() |
73 { | 73 { |
74 int ncoord, i, bad; | 74 int ncoord, i, bad; |
75 long x[MAX_SILK_LINES+1], y[MAX_SILK_LINES+1]; | 75 struct coord_pair coord[MAX_SILK_LINES+1]; |
76 long thickness; | 76 long thickness; |
77 | 77 |
78 if (strcmp(input_line_fields[0], "OPEN") && | 78 if (strcmp(input_line_fields[0], "OPEN") && |
79 strcmp(input_line_fields[0], "CLOSED")) | 79 strcmp(input_line_fields[0], "CLOSED")) |
80 return(0); | 80 return(0); |
99 printf("line %d: silk line coord not 2 numbers\n", | 99 printf("line %d: silk line coord not 2 numbers\n", |
100 input_lineno); | 100 input_lineno); |
101 bad = 1; | 101 bad = 1; |
102 continue; | 102 continue; |
103 } | 103 } |
104 x[i] = convert_input_dim(input_line_fields[0]); | 104 coord[i].x = convert_input_dim(input_line_fields[0]); |
105 y[i] = convert_input_dim(input_line_fields[1]); | 105 coord[i].y = convert_input_dim(input_line_fields[1]); |
106 } | 106 } |
107 if (bad) | 107 if (bad) |
108 return(1); | 108 return(1); |
109 | 109 |
110 for (i = 0; i < ncoord - 1; i++) { | 110 for (i = 0; i < ncoord - 1; i++) { |
111 if (num_silk_lines >= MAX_SILK_LINES) { | 111 if (num_silk_lines >= MAX_SILK_LINES) { |
112 printf("Too many silk lines!\n"); | 112 printf("Too many silk lines!\n"); |
113 return(1); | 113 return(1); |
114 } | 114 } |
115 silk_lines[num_silk_lines].x1 = x[i]; | 115 silk_lines[num_silk_lines].end1 = coord[i]; |
116 silk_lines[num_silk_lines].y1 = y[i]; | 116 silk_lines[num_silk_lines].end2 = coord[i+1]; |
117 silk_lines[num_silk_lines].x2 = x[i+1]; | |
118 silk_lines[num_silk_lines].y2 = y[i+1]; | |
119 silk_lines[num_silk_lines].thickness = thickness; | 117 silk_lines[num_silk_lines].thickness = thickness; |
120 num_silk_lines++; | 118 num_silk_lines++; |
121 } | 119 } |
122 return(1); | 120 return(1); |
123 } | 121 } |
124 | 122 |
125 static | 123 static |
126 try_silk_circle() | 124 try_silk_circle() |
127 { | 125 { |
128 int i, bad; | 126 int i, bad; |
129 long x[2], y[2]; | 127 struct coord_pair coord[2], centre; |
130 long centre_x, centre_y, diameter, thickness; | 128 long diameter, thickness; |
131 | 129 |
132 if (strcmp(input_line_fields[0], "CIRCLE")) | 130 if (strcmp(input_line_fields[0], "CIRCLE")) |
133 return(0); | 131 return(0); |
134 if (strcmp(input_line_fields[1], "2")) { | 132 if (strcmp(input_line_fields[1], "2")) { |
135 printf("line %d: silk CIRCLE piece ncoord != 2\n", | 133 printf("line %d: silk CIRCLE piece ncoord != 2\n", |
146 printf("line %d: silk CIRCLE coord not 2 numbers\n", | 144 printf("line %d: silk CIRCLE coord not 2 numbers\n", |
147 input_lineno); | 145 input_lineno); |
148 bad = 1; | 146 bad = 1; |
149 continue; | 147 continue; |
150 } | 148 } |
151 x[i] = convert_input_dim(input_line_fields[0]); | 149 coord[i].x = convert_input_dim(input_line_fields[0]); |
152 y[i] = convert_input_dim(input_line_fields[1]); | 150 coord[i].y = convert_input_dim(input_line_fields[1]); |
153 } | 151 } |
154 if (bad) | 152 if (bad) |
155 return(1); | 153 return(1); |
156 | 154 |
157 /* find the centre and diameter */ | 155 /* find the centre and diameter */ |
158 if (x[0] == x[1]) { | 156 if (coord[0].x == coord[1].x) { |
159 centre_x = x[0]; | 157 centre.x = coord[0].x; |
160 if (y[0] < y[1]) { | 158 if (coord[0].y < coord[1].y) { |
161 diameter = y[1] - y[0]; | 159 diameter = coord[1].y - coord[0].y; |
162 centre_y = y[0] + diameter / 2; | 160 centre.y = coord[0].y + diameter / 2; |
163 } else if (y[1] < y[0]) { | 161 } else if (coord[1].y < coord[0].y) { |
164 diameter = y[0] - y[1]; | 162 diameter = coord[0].y - coord[1].y; |
165 centre_y = y[1] + diameter / 2; | 163 centre.y = coord[1].y + diameter / 2; |
166 } else | 164 } else |
167 goto centre_diam_fail; | 165 goto centre_diam_fail; |
168 } else if (y[0] == y[1]) { | 166 } else if (coord[0].y == coord[1].y) { |
169 centre_y = y[0]; | 167 centre.y = coord[0].y; |
170 if (x[0] < x[1]) { | 168 if (coord[0].x < coord[1].x) { |
171 diameter = x[1] - x[0]; | 169 diameter = coord[1].x - coord[0].x; |
172 centre_x = x[0] + diameter / 2; | 170 centre.x = coord[0].x + diameter / 2; |
173 } else if (x[1] < x[0]) { | 171 } else if (coord[1].x < coord[0].x) { |
174 diameter = x[0] - x[1]; | 172 diameter = coord[0].x - coord[1].x; |
175 centre_x = x[1] + diameter / 2; | 173 centre.x = coord[1].x + diameter / 2; |
176 } else | 174 } else |
177 goto centre_diam_fail; | 175 goto centre_diam_fail; |
178 } else { | 176 } else { |
179 centre_diam_fail: | 177 centre_diam_fail: |
180 printf("line %d: unable to find circle centre and diameter\n", | 178 printf("line %d: unable to find circle centre and diameter\n", |
187 | 185 |
188 if (num_silk_arcs >= MAX_SILK_LINES) { | 186 if (num_silk_arcs >= MAX_SILK_LINES) { |
189 printf("Too many silk arcs!\n"); | 187 printf("Too many silk arcs!\n"); |
190 return(1); | 188 return(1); |
191 } | 189 } |
192 silk_arcs[num_silk_arcs].centre_x = centre_x; | 190 silk_arcs[num_silk_arcs].centre = centre; |
193 silk_arcs[num_silk_arcs].centre_y = centre_y; | |
194 silk_arcs[num_silk_arcs].width = diameter / 2; | 191 silk_arcs[num_silk_arcs].width = diameter / 2; |
195 silk_arcs[num_silk_arcs].height = diameter / 2; | 192 silk_arcs[num_silk_arcs].height = diameter / 2; |
196 silk_arcs[num_silk_arcs].start_angle = 0; | 193 silk_arcs[num_silk_arcs].start_angle = 0; |
197 silk_arcs[num_silk_arcs].delta_angle = 360; | 194 silk_arcs[num_silk_arcs].delta_angle = 360; |
198 silk_arcs[num_silk_arcs].thickness = thickness; | 195 silk_arcs[num_silk_arcs].thickness = thickness; |
264 fprintf(stderr, | 261 fprintf(stderr, |
265 "%s line %d: expected %d in the pin number field\n", | 262 "%s line %d: expected %d in the pin number field\n", |
266 input_filename, input_lineno); | 263 input_filename, input_lineno); |
267 exit(1); | 264 exit(1); |
268 } | 265 } |
269 pins_array[idx].x1 = convert_input_dim(input_line_fields[0]); | 266 pins_array[idx].end1.x = convert_input_dim(input_line_fields[0]); |
270 pins_array[idx].y1 = convert_input_dim(input_line_fields[1]); | 267 pins_array[idx].end1.y = convert_input_dim(input_line_fields[1]); |
271 } | 268 } |
272 | 269 |
273 static void | 270 static void |
274 process_pad_shape(padptr) | 271 process_pad_shape(padptr) |
275 struct pad_shape_info *padptr; | 272 struct pad_shape_info *padptr; |
388 return(-1); | 385 return(-1); |
389 } | 386 } |
390 pin->thickness = pin->shape.short_dim; | 387 pin->thickness = pin->shape.short_dim; |
391 pin->clearance = CLEARANCE_SETTING; | 388 pin->clearance = CLEARANCE_SETTING; |
392 pin->mask = pin->thickness + SOLDERMASK_DELTA; | 389 pin->mask = pin->thickness + SOLDERMASK_DELTA; |
393 pin->x2 = pin->x1; | 390 pin->end2 = pin->end1; |
394 pin->y2 = pin->y1; | |
395 if (!pin->shape.elongated) | 391 if (!pin->shape.elongated) |
396 return(0); | 392 return(0); |
397 long_minus_short = pin->shape.long_dim - pin->shape.short_dim; | 393 long_minus_short = pin->shape.long_dim - pin->shape.short_dim; |
398 delta = long_minus_short / 2; | 394 delta = long_minus_short / 2; |
399 switch (pin->shape.angle) { | 395 switch (pin->shape.angle) { |
400 case 0: | 396 case 0: |
401 pin->x1 -= delta; | 397 pin->end1.x -= delta; |
402 pin->x2 += delta; | 398 pin->end2.x += delta; |
403 return(0); | 399 return(0); |
404 case 90: | 400 case 90: |
405 pin->y1 -= delta; | 401 pin->end1.y -= delta; |
406 pin->y2 += delta; | 402 pin->end2.y += delta; |
407 return(0); | 403 return(0); |
408 } | 404 } |
409 return(-1); | 405 return(-1); |
410 } | 406 } |
411 | 407 |