changeset 67:e14cd5433e83

pads2gpcb/partinst.c: checkpoint before adding mirroring and rotation
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 31 Jan 2016 22:59:36 +0000
parents 68900e8dcda1
children b7f49f029bc3
files pads2gpcb/partinst.c
diffstat 1 files changed, 72 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pads2gpcb/partinst.c	Sun Jan 31 22:03:08 2016 +0000
+++ b/pads2gpcb/partinst.c	Sun Jan 31 22:59:36 2016 +0000
@@ -137,9 +137,81 @@
 }
 
 static void
+copy_footprint_body()
+{
+	struct footprint_body *origfp = our_part->decal->body;
+	struct footprint_body *newbody;
+
+	newbody = malloc(sizeof(struct footprint_body));
+	if (!newbody) {
+		perror("malloc to copy footprint body");
+		exit(1);
+	}
+	bcopy(origfp, newbody, sizeof(struct footprint_body));
+	newbody->pins = malloc(sizeof(struct footprint_pad) * origfp->npins);
+	if (!newbody->pins) {
+		perror("malloc to copy footprint pads");
+		exit(1);
+	}
+	bcopy(origfp->pins, newbody->pins,
+		sizeof(struct footprint_pad) * origfp->npins);
+	if (origfp->silk_lines) {
+		newbody->silk_lines =
+			malloc(sizeof(struct element_line) *
+				origfp->num_silk_lines);
+		if (!newbody->silk_lines) {
+			perror("malloc to copy footprint silk lines");
+			exit(1);
+		}
+		bcopy(origfp->silk_lines, newbody->silk_lines,
+			sizeof(struct element_line) * origfp->num_silk_lines);
+	}
+	if (origfp->silk_arcs) {
+		newbody->silk_arcs =
+			malloc(sizeof(struct element_arc) *
+				origfp->num_silk_arcs);
+		if (!newbody->silk_arcs) {
+			perror("malloc to copy footprint silk arcs");
+			exit(1);
+		}
+		bcopy(origfp->silk_arcs, newbody->silk_arcs,
+			sizeof(struct element_arc) * origfp->num_silk_arcs);
+	}
+	our_part->body = newbody;
+}
+
+static void
+part_inst_fail(reason)
+	char *reason;
+{
+	printf("Omitting component %s: %s\n", our_part->name, reason);
+}
+
+static void
 process_one_part()
 {
 	read_one_part();
+	/* analyze it */
+	if (!our_part->decal->body) {
+		part_inst_fail("bad decal");
+		return;
+	}
+	if (our_part->type->num_alpha_pins &&
+	    our_part->type->num_alpha_pins != our_part->decal->body->npins) {
+		part_inst_fail("alpha pins count mismatch");
+		return;
+	}
+	if (our_part->ori < 0) {
+		part_inst_fail("non-rectangular orientation");
+		return;
+	}
+
+	/* subsetting and renaming logic will go here */
+	our_part->newname = our_part->name;
+	copy_footprint_body();
+	our_part->body->mark_x = our_part->mark_x;
+	our_part->body->mark_y = our_part->mark_y;
+	/* rotation and mirroring to be implemented */
 }
 
 process_part_section()