diff 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
line wrap: on
line diff
--- a/pads2gpcb/decals.c	Sat Jan 30 21:32:18 2016 +0000
+++ b/pads2gpcb/decals.c	Sun Jan 31 01:26:11 2016 +0000
@@ -12,6 +12,12 @@
 static struct footprint_body fpbody;
 static struct footprint_pad *pins_array;
 
+#define	MAX_SILK_LINES	16
+static struct element_line silk_lines[MAX_SILK_LINES];
+static struct element_arc silk_arcs[MAX_SILK_LINES];
+static int num_silk_lines;
+static int num_silk_arcs;
+
 #define	SOLDERMASK_DELTA	(600 * 254)
 #define	CLEARANCE_SETTING	(2000 * 254)
 
@@ -51,12 +57,75 @@
 	}
 }
 
+static
+try_silk_open_closed()
+{
+	int ncoord, i, bad;
+	long x[MAX_SILK_LINES+1], y[MAX_SILK_LINES+1];
+	long thickness;
+
+	if (strcmp(input_line_fields[0], "OPEN") &&
+	    strcmp(input_line_fields[0], "CLOSED"))
+		return(0);
+	if (input_line_nfields != 5)
+		return(0);
+	if (strcmp(input_line_fields[4], "0"))
+		return(0);
+	ncoord = atoi(input_line_fields[1]);
+	if (ncoord < 2) {
+		printf("line %d: silk %s piece ncoord < 2\n", input_lineno,
+			input_line_fields[0]);
+		return(0);
+	}
+	if (ncoord > MAX_SILK_LINES + 1) {
+		printf("line %d: silk %s piece ncoord too big\n", input_lineno,
+			input_line_fields[0]);
+		return(0);
+	}
+	thickness = convert_input_dim(input_line_fields[2]);
+
+	bad = 0;
+	for (i = 0; i < ncoord; i++) {
+		get_line_internal();
+		if (input_line_nfields != 2) {
+			printf("line %d: silk line 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);
+
+	for (i = 0; i < ncoord - 1; i++) {
+		if (num_silk_lines >= MAX_SILK_LINES) {
+			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].thickness = thickness;
+		num_silk_lines++;
+	}
+	return(1);
+}
+
+static
+try_silk_circle()
+{
+	return(0);
+}
+
 static void
 one_drawing_piece()
 {
 	int ncoord, i;
 
-	/* just skip it for now */
+	/* extract silk lines and arcs if enabled, otherwise skip */
 	get_line_internal();
 	parse_input_line_fields();
 	if (input_line_nfields < 2) {
@@ -65,6 +134,12 @@
 			input_filename, input_lineno);
 		exit(1);
 	}
+	if (do_footprint_silk) {
+		if (try_silk_open_closed())
+			return;
+		if (try_silk_circle())
+			return;
+	}
 	ncoord = atoi(input_line_fields[1]);
 	for (i = 0; i < ncoord; i++)
 		get_line_internal();
@@ -344,6 +419,8 @@
 
 	/* done parsing the header line, initialize some misc */
 	fpbody.refdes_scale = 100;
+	num_silk_lines = 0;
+	num_silk_arcs = 0;
 
 	/* read and process the miscellany */
 	for (i = 0; i < num_drawing_pieces; i++)