static LineType * MakeBypassLine(LayerType *layer, Vector a, Vector b, LineType *orig, POLYAREA **expandp) { LineType *line; line = CreateVectorLineOnLayer(layer, a, b, orig->Thickness, orig->Clearance, orig->Flags); if (line && expandp) { POLYAREA *p = LinePoly(line, line->Thickness + line->Clearance); poly_Boolean_free(*expandp, p, expandp, PBO_UNITE); } return line; }
static POLYAREA * square_therm (PinTypePtr pin, Cardinal style) { POLYAREA *p, *p2; PLINE *c; Vector v; Coord d, in, out; switch (style) { case 1: d = pcb->ThermScale * pin->Clearance * M_SQRT1_2; out = (pin->Thickness + pin->Clearance) / 2; in = pin->Thickness / 2; /* top (actually bottom since +y is down) */ v[0] = pin->X - in + d; v[1] = pin->Y + in; if ((c = poly_NewContour (v)) == NULL) return NULL; v[0] = pin->X + in - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X + out - d; v[1] = pin->Y + out; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X - out + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); p = ContourToPoly (c); /* right */ v[0] = pin->X + in; v[1] = pin->Y + in - d; if ((c = poly_NewContour (v)) == NULL) return NULL; v[1] = pin->Y - in + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X + out; v[1] = pin->Y - out + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[1] = pin->Y + out - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); p2 = ContourToPoly (c); p->f = p2; p2->b = p; /* left */ v[0] = pin->X - in; v[1] = pin->Y - in + d; if ((c = poly_NewContour (v)) == NULL) return NULL; v[1] = pin->Y + in - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X - out; v[1] = pin->Y + out - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[1] = pin->Y - out + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); p2 = ContourToPoly (c); p->f->f = p2; p2->b = p->f; /* bottom (actually top since +y is down) */ v[0] = pin->X + in - d; v[1] = pin->Y - in; if ((c = poly_NewContour (v)) == NULL) return NULL; v[0] = pin->X - in + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X - out + d; v[1] = pin->Y - out; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X + out - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); p2 = ContourToPoly (c); p->f->f->f = p2; p2->f = p; p2->b = p->f->f; p->b = p2; return p; case 4: { LineType l; l.Flags = NoFlags (); d = pin->Thickness / 2 - pcb->ThermScale * pin->Clearance; out = pin->Thickness / 2 + pin->Clearance / 4; in = pin->Clearance / 2; /* top */ l.Point1.X = pin->X - d; l.Point2.Y = l.Point1.Y = pin->Y + out; l.Point2.X = pin->X + d; p = LinePoly (&l, in); /* right */ l.Point1.X = l.Point2.X = pin->X + out; l.Point1.Y = pin->Y - d; l.Point2.Y = pin->Y + d; p2 = LinePoly (&l, in); p->f = p2; p2->b = p; /* bottom */ l.Point1.X = pin->X - d; l.Point2.Y = l.Point1.Y = pin->Y - out; l.Point2.X = pin->X + d; p2 = LinePoly (&l, in); p->f->f = p2; p2->b = p->f; /* left */ l.Point1.X = l.Point2.X = pin->X - out; l.Point1.Y = pin->Y - d; l.Point2.Y = pin->Y + d; p2 = LinePoly (&l, in); p->f->f->f = p2; p2->b = p->f->f; p->b = p2; p2->f = p; return p; } default: /* style 2 and 5 */ d = 0.5 * pcb->ThermScale * pin->Clearance; if (style == 5) d += d; out = (pin->Thickness + pin->Clearance) / 2; in = pin->Thickness / 2; /* topright */ v[0] = pin->X + in; v[1] = pin->Y + in; if ((c = poly_NewContour (v)) == NULL) return NULL; v[1] = pin->Y + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 2) { v[0] = pin->X + out; poly_InclVertex (c->head.prev, poly_CreateNode (v)); } else frac_circle (c, v[0] + pin->Clearance / 4, v[1], v, 2); v[1] = pin->Y + in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); /* pivot 1/4 circle to next point */ frac_circle (c, pin->X + in, pin->Y + in, v, 4); v[0] = pin->X + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 2) { poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[1] = pin->Y + in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); } else frac_circle (c, v[0], v[1] - pin->Clearance / 4, v, 2); p = ContourToPoly (c); /* bottom right */ v[0] = pin->X + in; v[1] = pin->Y - d; if ((c = poly_NewContour (v)) == NULL) return NULL; v[1] = pin->Y - in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 2) { v[1] = pin->Y - out; poly_InclVertex (c->head.prev, poly_CreateNode (v)); } else frac_circle (c, v[0], v[1] - pin->Clearance / 4, v, 2); v[0] = pin->X + in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); /* pivot 1/4 circle to next point */ frac_circle (c, pin->X + in, pin->Y - in, v, 4); v[1] = pin->Y - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 5) frac_circle (c, v[0] - pin->Clearance / 4, v[1], v, 2); p2 = ContourToPoly (c); p->f = p2; p2->b = p; /* bottom left */ v[0] = pin->X - d; v[1] = pin->Y - in; if ((c = poly_NewContour (v)) == NULL) return NULL; v[0] = pin->X - in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[1] = pin->Y - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 2) { v[0] = pin->X - out; poly_InclVertex (c->head.prev, poly_CreateNode (v)); } else frac_circle (c, v[0] - pin->Clearance / 4, v[1], v, 2); v[1] = pin->Y - in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); /* pivot 1/4 circle to next point */ frac_circle (c, pin->X - in, pin->Y - in, v, 4); v[0] = pin->X - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 5) frac_circle (c, v[0], v[1] + pin->Clearance / 4, v, 2); p2 = ContourToPoly (c); p->f->f = p2; p2->b = p->f; /* top left */ v[0] = pin->X - d; v[1] = pin->Y + out; if ((c = poly_NewContour (v)) == NULL) return NULL; v[0] = pin->X - in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); /* pivot 1/4 circle to next point (x-out, y+in) */ frac_circle (c, pin->X - in, pin->Y + in, v, 4); v[1] = pin->Y + d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 2) { v[0] = pin->X - in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); } else frac_circle (c, v[0] + pin->Clearance / 4, v[1], v, 2); v[1] = pin->Y + in; poly_InclVertex (c->head.prev, poly_CreateNode (v)); v[0] = pin->X - d; poly_InclVertex (c->head.prev, poly_CreateNode (v)); if (style == 5) frac_circle (c, v[0], v[1] + pin->Clearance / 4, v, 2); p2 = ContourToPoly (c); p->f->f->f = p2; p2->f = p; p2->b = p->f->f; p->b = p2; return p; } }