FreeCalypso > hg > ueda-linux
changeset 54:a930e05cf908
pads2gpcb/decals.c: silk circle extraction implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 31 Jan 2016 01:57:38 +0000 |
parents | 0e18818206e5 |
children | e93375570f91 |
files | pads2gpcb/decals.c |
diffstat | 1 files changed, 76 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pads2gpcb/decals.c Sun Jan 31 01:39:31 2016 +0000 +++ b/pads2gpcb/decals.c Sun Jan 31 01:57:38 2016 +0000 @@ -118,7 +118,82 @@ static try_silk_circle() { - return(0); + int i, bad; + long x[2], y[2]; + long centre_x, centre_y, diameter, thickness; + + if (strcmp(input_line_fields[0], "CIRCLE")) + return(0); + if (input_line_nfields != 5) + return(0); + if (strcmp(input_line_fields[4], "0")) + return(0); + if (strcmp(input_line_fields[1], "2")) { + printf("line %d: silk CIRCLE piece ncoord != 2\n", + input_lineno); + return(0); + } + thickness = convert_input_dim(input_line_fields[2]); + + bad = 0; + for (i = 0; i < 2; i++) { + get_line_internal(); + parse_input_line_fields(); + if (input_line_nfields != 2) { + printf("line %d: silk CIRCLE coord not 2 numbers\n", + input_lineno); + bad = 1; + continue; + } + x[i] = convert_input_dim(input_line_fields[0]); + y[i] = -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; + } 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 + goto centre_diam_fail; + } else { +centre_diam_fail: + printf("line %d: unable to find circle centre and diameter\n", + input_lineno); + return(1); + } + if (diameter % 2) + printf("warning: line %d: circle diameter in nm is odd!\n", + input_lineno); + + if (num_silk_arcs >= MAX_SILK_LINES) { + 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].width = diameter; + silk_arcs[num_silk_arcs].height = diameter; + silk_arcs[num_silk_arcs].start_angle = 0; + silk_arcs[num_silk_arcs].delta_angle = 360; + silk_arcs[num_silk_arcs].thickness = thickness; + return(1); } static void