Index: trunk/src/obj_line.c =================================================================== --- trunk/src/obj_line.c (revision 11664) +++ trunk/src/obj_line.c (revision 11665) @@ -303,7 +303,41 @@ + (double)line->Thickness * (double)line->Thickness * M_PI; /* cap circles */ } +void pcb_sqline_to_rect(const pcb_line_t *line, pcb_coord_t *x, pcb_coord_t *y) +{ + double l, vx, vy, nx, ny, width, x1, y1, x2, y2, dx, dy; + x1 = line->Point1.X; + y1 = line->Point1.Y; + x2 = line->Point2.X; + y2 = line->Point2.Y; + + width = (double)((line->Thickness + 1) / 2); + dx = x2-x1; + dy = y2-y1; + + if ((dx == 0) && (dy == 0)) + dx = 1; + + l = sqrt((double)dx*(double)dx + (double)dy*(double)dy); + + vx = dx / l; + vy = dy / l; + nx = -vy; + ny = vx; + + x[0] = (pcb_coord_t)pcb_round(x1 - vx * width + nx * width); + y[0] = (pcb_coord_t)pcb_round(y1 - vy * width + ny * width); + x[1] = (pcb_coord_t)pcb_round(x1 - vx * width - nx * width); + y[1] = (pcb_coord_t)pcb_round(y1 - vy * width - ny * width); + x[2] = (pcb_coord_t)pcb_round(x2 + vx * width - nx * width); + y[2] = (pcb_coord_t)pcb_round(y2 + vy * width - ny * width); + x[3] = (pcb_coord_t)pcb_round(x2 + vx * width + nx * width); + y[3] = (pcb_coord_t)pcb_round(y2 + vy * width + ny * width); +} + + + /*** ops ***/ /* copies a line to buffer */ void *pcb_lineop_add_to_buffer(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line) Index: trunk/src/obj_line.h =================================================================== --- trunk/src/obj_line.h (revision 11664) +++ trunk/src/obj_line.h (revision 11665) @@ -68,6 +68,8 @@ pcb_coord_t pcb_line_length(const pcb_line_t *line); double pcb_line_area(const pcb_line_t *line); +/* Convert a square cap line (e.g. a gEDA/pcb pad) to 4 corner points of a rectangle */ +void pcb_sqline_to_rect(const pcb_line_t *line, pcb_coord_t *x, pcb_coord_t *y); /* hash */ int pcb_line_eq(const pcb_element_t *e1, const pcb_line_t *l1, const pcb_element_t *e2, const pcb_line_t *l2); Index: trunk/src_plugins/io_tedax/footprint.c =================================================================== --- trunk/src_plugins/io_tedax/footprint.c (revision 11664) +++ trunk/src_plugins/io_tedax/footprint.c (revision 11665) @@ -45,34 +45,15 @@ #include "obj_pad.h" #include "obj_pinvia.h" - static void print_sqpad_coords(FILE *f, pcb_pad_t *Pad, pcb_coord_t cx, pcb_coord_t cy) { - double l, vx, vy, nx, ny, width, x1, y1, x2, y2, dx, dy; + pcb_coord_t x[4], y[4]; - x1 = Pad->Point1.X; - y1 = Pad->Point1.Y; - x2 = Pad->Point2.X; - y2 = Pad->Point2.Y; - - width = (double)((Pad->Thickness + 1) / 2); - dx = x2-x1; - dy = y2-y1; - - if ((dx == 0) && (dy == 0)) - dx = 1; - - l = sqrt((double)dx*(double)dx + (double)dy*(double)dy); - - vx = dx / l; - vy = dy / l; - nx = -vy; - ny = vx; - - pcb_fprintf(f, " %.9mm %.9mm", (pcb_coord_t)(x1 - vx * width + nx * width) - cx, (pcb_coord_t)(y1 - vy * width + ny * width) - cy); - pcb_fprintf(f, " %.9mm %.9mm", (pcb_coord_t)(x1 - vx * width - nx * width) - cx, (pcb_coord_t)(y1 - vy * width - ny * width) - cy); - pcb_fprintf(f, " %.9mm %.9mm", (pcb_coord_t)(x2 + vx * width - nx * width) - cx, (pcb_coord_t)(y2 + vy * width - ny * width) - cy); - pcb_fprintf(f, " %.9mm %.9mm", (pcb_coord_t)(x2 + vx * width + nx * width) - cx, (pcb_coord_t)(y2 + vy * width + ny * width) - cy); + pcb_sqline_to_rect((pcb_line_t *)Pad, x, y); + pcb_fprintf(f, " %.9mm %.9mm", x[0] - cx, y[0] - cy); + pcb_fprintf(f, " %.9mm %.9mm", x[1] - cx, y[1] - cy); + pcb_fprintf(f, " %.9mm %.9mm", x[2] - cx, y[2] - cy); + pcb_fprintf(f, " %.9mm %.9mm", x[3] - cx, y[3] - cy); } #define elem_layer(elem, obj) \