FreeCalypso > hg > ueda-linux
changeset 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 | a9a20c85140e |
files | pads2gpcb/decals.c pads2gpcb/struct.h pads2gpcb/writeelem.c |
diffstat | 3 files changed, 53 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/pads2gpcb/decals.c Sun Jan 31 23:19:37 2016 +0000 +++ b/pads2gpcb/decals.c Sun Jan 31 23:41:00 2016 +0000 @@ -72,7 +72,7 @@ try_silk_open_closed() { int ncoord, i, bad; - long x[MAX_SILK_LINES+1], y[MAX_SILK_LINES+1]; + struct coord_pair coord[MAX_SILK_LINES+1]; long thickness; if (strcmp(input_line_fields[0], "OPEN") && @@ -101,8 +101,8 @@ bad = 1; continue; } - x[i] = convert_input_dim(input_line_fields[0]); - y[i] = convert_input_dim(input_line_fields[1]); + coord[i].x = convert_input_dim(input_line_fields[0]); + coord[i].y = convert_input_dim(input_line_fields[1]); } if (bad) return(1); @@ -112,10 +112,8 @@ printf("Too many silk lines!\n"); return(1); } - silk_lines[num_silk_lines].x1 = x[i]; - silk_lines[num_silk_lines].y1 = y[i]; - silk_lines[num_silk_lines].x2 = x[i+1]; - silk_lines[num_silk_lines].y2 = y[i+1]; + silk_lines[num_silk_lines].end1 = coord[i]; + silk_lines[num_silk_lines].end2 = coord[i+1]; silk_lines[num_silk_lines].thickness = thickness; num_silk_lines++; } @@ -126,8 +124,8 @@ try_silk_circle() { int i, bad; - long x[2], y[2]; - long centre_x, centre_y, diameter, thickness; + struct coord_pair coord[2], centre; + long diameter, thickness; if (strcmp(input_line_fields[0], "CIRCLE")) return(0); @@ -148,31 +146,31 @@ bad = 1; continue; } - x[i] = convert_input_dim(input_line_fields[0]); - y[i] = convert_input_dim(input_line_fields[1]); + coord[i].x = convert_input_dim(input_line_fields[0]); + coord[i].y = convert_input_dim(input_line_fields[1]); } if (bad) return(1); /* find the centre and diameter */ - if (x[0] == x[1]) { - centre_x = x[0]; - if (y[0] < y[1]) { - diameter = y[1] - y[0]; - centre_y = y[0] + diameter / 2; - } else if (y[1] < y[0]) { - diameter = y[0] - y[1]; - centre_y = y[1] + diameter / 2; + if (coord[0].x == coord[1].x) { + centre.x = coord[0].x; + if (coord[0].y < coord[1].y) { + diameter = coord[1].y - coord[0].y; + centre.y = coord[0].y + diameter / 2; + } else if (coord[1].y < coord[0].y) { + diameter = coord[0].y - coord[1].y; + centre.y = coord[1].y + diameter / 2; } else goto centre_diam_fail; - } else if (y[0] == y[1]) { - centre_y = y[0]; - if (x[0] < x[1]) { - diameter = x[1] - x[0]; - centre_x = x[0] + diameter / 2; - } else if (x[1] < x[0]) { - diameter = x[0] - x[1]; - centre_x = x[1] + diameter / 2; + } else if (coord[0].y == coord[1].y) { + centre.y = coord[0].y; + if (coord[0].x < coord[1].x) { + diameter = coord[1].x - coord[0].x; + centre.x = coord[0].x + diameter / 2; + } else if (coord[1].x < coord[0].x) { + diameter = coord[0].x - coord[1].x; + centre.x = coord[1].x + diameter / 2; } else goto centre_diam_fail; } else { @@ -189,8 +187,7 @@ printf("Too many silk arcs!\n"); return(1); } - silk_arcs[num_silk_arcs].centre_x = centre_x; - silk_arcs[num_silk_arcs].centre_y = centre_y; + silk_arcs[num_silk_arcs].centre = centre; silk_arcs[num_silk_arcs].width = diameter / 2; silk_arcs[num_silk_arcs].height = diameter / 2; silk_arcs[num_silk_arcs].start_angle = 0; @@ -266,8 +263,8 @@ input_filename, input_lineno); exit(1); } - pins_array[idx].x1 = convert_input_dim(input_line_fields[0]); - pins_array[idx].y1 = convert_input_dim(input_line_fields[1]); + pins_array[idx].end1.x = convert_input_dim(input_line_fields[0]); + pins_array[idx].end1.y = convert_input_dim(input_line_fields[1]); } static void @@ -390,20 +387,19 @@ pin->thickness = pin->shape.short_dim; pin->clearance = CLEARANCE_SETTING; pin->mask = pin->thickness + SOLDERMASK_DELTA; - pin->x2 = pin->x1; - pin->y2 = pin->y1; + pin->end2 = pin->end1; if (!pin->shape.elongated) return(0); long_minus_short = pin->shape.long_dim - pin->shape.short_dim; delta = long_minus_short / 2; switch (pin->shape.angle) { case 0: - pin->x1 -= delta; - pin->x2 += delta; + pin->end1.x -= delta; + pin->end2.x += delta; return(0); case 90: - pin->y1 -= delta; - pin->y2 += delta; + pin->end1.y -= delta; + pin->end2.y += delta; return(0); } return(-1);
--- a/pads2gpcb/struct.h Sun Jan 31 23:19:37 2016 +0000 +++ b/pads2gpcb/struct.h Sun Jan 31 23:41:00 2016 +0000 @@ -8,11 +8,14 @@ int angle; }; +struct coord_pair { + long x; + long y; +}; + struct footprint_pad { - long x1; - long y1; - long x2; - long y2; + struct coord_pair end1; + struct coord_pair end2; long thickness; long clearance; long mask; @@ -20,16 +23,13 @@ }; struct element_line { - long x1; - long y1; - long x2; - long y2; + struct coord_pair end1; + struct coord_pair end2; long thickness; }; struct element_arc { - long centre_x; - long centre_y; + struct coord_pair centre; long width; long height; int start_angle;
--- a/pads2gpcb/writeelem.c Sun Jan 31 23:19:37 2016 +0000 +++ b/pads2gpcb/writeelem.c Sun Jan 31 23:41:00 2016 +0000 @@ -44,10 +44,10 @@ char mask_buf[DIM_OUT_BUFSIZE], *mask_str; char *flagstr; - x1_str = output_gpcb_dimension(pad->x1, x1_buf); - y1_str = output_gpcb_dimension(-pad->y1, y1_buf); - x2_str = output_gpcb_dimension(pad->x2, x2_buf); - y2_str = output_gpcb_dimension(-pad->y2, y2_buf); + x1_str = output_gpcb_dimension(pad->end1.x, x1_buf); + y1_str = output_gpcb_dimension(-pad->end1.y, y1_buf); + x2_str = output_gpcb_dimension(pad->end2.x, x2_buf); + y2_str = output_gpcb_dimension(-pad->end2.y, y2_buf); thickness_str = output_gpcb_dimension(pad->thickness, thickness_buf); clearance_str = output_gpcb_dimension(pad->clearance, clearance_buf); mask_str = output_gpcb_dimension(pad->mask, mask_buf); @@ -78,10 +78,10 @@ char y2_buf[DIM_OUT_BUFSIZE], *y2_str; char thickness_buf[DIM_OUT_BUFSIZE], *thickness_str; - x1_str = output_gpcb_dimension(obj->x1, x1_buf); - y1_str = output_gpcb_dimension(-obj->y1, y1_buf); - x2_str = output_gpcb_dimension(obj->x2, x2_buf); - y2_str = output_gpcb_dimension(-obj->y2, y2_buf); + x1_str = output_gpcb_dimension(obj->end1.x, x1_buf); + y1_str = output_gpcb_dimension(-obj->end1.y, y1_buf); + x2_str = output_gpcb_dimension(obj->end2.x, x2_buf); + y2_str = output_gpcb_dimension(-obj->end2.y, y2_buf); thickness_str = output_gpcb_dimension(obj->thickness, thickness_buf); fprintf(outf, "\tElementLine[%s %s %s %s %s]\n", @@ -99,8 +99,8 @@ char height_buf[DIM_OUT_BUFSIZE], *height_str; char thickness_buf[DIM_OUT_BUFSIZE], *thickness_str; - centrex_str = output_gpcb_dimension(obj->centre_x, centrex_buf); - centrey_str = output_gpcb_dimension(-obj->centre_y, centrey_buf); + centrex_str = output_gpcb_dimension(obj->centre.x, centrex_buf); + centrey_str = output_gpcb_dimension(-obj->centre.y, centrey_buf); width_str = output_gpcb_dimension(obj->width, width_buf); height_str = output_gpcb_dimension(obj->height, height_buf); thickness_str = output_gpcb_dimension(obj->thickness, thickness_buf);