{
ScfEcomponent* c0;
ScfEcomponent* c1;
- ScfEpin* p0;
- ScfEpin* p1;
- ScfEpin* p2;
- ScfEpin* p3;
+ ScfEpin* p;
size_t i;
size_t j;
+ size_t k;
for (i = 0; i < f->n_components - 1; i++) {
c0 = f->components[i];
- p0 = c0->pins[0];
- p1 = c0->pins[1];
+ int y0 = INT_MAX;
+ int y1 = INT_MIN;
- if (p0->y - p1->y <= d && p0->y - p1->y >= -d)
- continue;
+ for (k = 0; k < c0->n_pins; k++) {
+ p = c0->pins[k];
+
+ if (y0 > p->y)
+ y0 = p->y;
- int y0 = p0->y < p1->y ? p0->y : p1->y;
- int y1 = p0->y < p1->y ? p1->y : p0->y;
+ if (y1 < p->y)
+ y1 = p->y;
+ }
+
+ if (y1 - y0 <= d)
+ continue;
for (j = i + 1; j < f->n_components; j++) {
c1 = f->components[j];
if ((c0->x < 0 && c1->x > 0) || (c0->x > 0 && c1->x < 0))
continue;
- p2 = c1->pins[0];
- p3 = c1->pins[1];
+ int y2 = INT_MAX;
+ int y3 = INT_MIN;
+
+ for (k = 0; k < c1->n_pins; k++) {
+ p = c1->pins[k];
- if (p2->y - p3->y <= d && p2->y - p3->y >= -d)
+ if (y2 > p->y)
+ y2 = p->y;
+
+ if (y3 < p->y)
+ y3 = p->y;
+ }
+
+ if (y3 - y2 <= d)
continue;
- int y2 = p2->y < p3->y ? p2->y : p3->y;
- int y3 = p2->y < p3->y ? p3->y : p2->y;
+ if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) {
- if (y0 < y2 && y3 < y1) {
if ((c0->x < 0 && c0->x > c1->x) || (c0->x > 0 && c0->x < c1->x))
__ses_xchg_cx2(c0, c1);
- } else if (y2 < y0 && y1 < y3) {
+ } else if ((y2 <= y0 && y1 < y3) || (y2 < y0 && y1 <= y3)) {
+
if ((c0->x < 0 && c0->x < c1->x) || (c0->x > 0 && c0->x > c1->x))
__ses_xchg_cx2(c0, c1);
}