diff 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
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);