Index: find_geo.c =================================================================== --- find_geo.c (revision 35700) +++ find_geo.c (revision 35701) @@ -720,6 +720,42 @@ return rnd_false; } +/* Bloated pline-pline intersection test: trace c1 using thick lines to see if + it ever touches c2 */ +rnd_bool pcb_isc_poly_poly_bloated(const pcb_find_t *ctx, rnd_pline_t *c1, rnd_pline_t *c2, pcb_poly_t *P2) +{ + rnd_pline_t *c; + + if (!((c1->xmin - Bloat <= c2->xmax) && (c2->xmin <= c1->xmax + Bloat) && + (c1->ymin - Bloat <= c2->ymax) && (c2->ymin <= c1->ymax + Bloat))) return rnd_false; + + for (c = c1; c; c = c->next) { + pcb_line_t line; + rnd_vnode_t *v = c->head; + if (c->xmin - Bloat <= c2->xmax && c->xmax + Bloat >= c2->xmin && + c->ymin - Bloat <= c2->ymax && c->ymax + Bloat >= c2->ymin) { + + line.Point1.X = v->point[0]; + line.Point1.Y = v->point[1]; + line.Thickness = 2 * Bloat; + line.Clearance = 0; + line.Flags = pcb_no_flags(); + for (v = v->next; v != c->head; v = v->next) { + line.Point2.X = v->point[0]; + line.Point2.Y = v->point[1]; + pcb_line_bbox(&line); + if (pcb_isc_line_poly(ctx, &line, P2)) + return rnd_true; + line.Point1.X = line.Point2.X; + line.Point1.Y = line.Point2.Y; + } + } + } + + return rnd_false; +} + + /* --------------------------------------------------------------------------- * checks if a polygon has a connection to a second one * @@ -790,32 +826,10 @@ for(pa1 = pcb_poly_island_first(P1, &it1); pa1 != NULL; pa1 = pcb_poly_island_next(&it1)) { rnd_pline_t *c1 = pcb_poly_contour(&it1); for(pa2 = pcb_poly_island_first(P2, &it2); pa2 != NULL; pa2 = pcb_poly_island_next(&it2)) { - rnd_pline_t *c, *c2 = pcb_poly_contour(&it2); + rnd_pline_t *c2 = pcb_poly_contour(&it2); + if (pcb_isc_poly_poly_bloated(ctx, c1, c2, P2)) + return rnd_true; - if (!((c1->xmin - Bloat <= c2->xmax) && (c2->xmin <= c1->xmax + Bloat) && - (c1->ymin - Bloat <= c2->ymax) && (c2->ymin <= c1->ymax + Bloat))) continue; - for (c = c1; c; c = c->next) { - pcb_line_t line; - rnd_vnode_t *v = c->head; - if (c->xmin - Bloat <= c2->xmax && c->xmax + Bloat >= c2->xmin && - c->ymin - Bloat <= c2->ymax && c->ymax + Bloat >= c2->ymin) { - - line.Point1.X = v->point[0]; - line.Point1.Y = v->point[1]; - line.Thickness = 2 * Bloat; - line.Clearance = 0; - line.Flags = pcb_no_flags(); - for (v = v->next; v != c->head; v = v->next) { - line.Point2.X = v->point[0]; - line.Point2.Y = v->point[1]; - pcb_line_bbox(&line); - if (pcb_isc_line_poly(ctx, &line, P2)) - return rnd_true; - line.Point1.X = line.Point2.X; - line.Point1.Y = line.Point2.Y; - } - } - } if (!PCB_FLAG_TEST(PCB_FLAG_FULLPOLY, P2)) break; } @@ -1071,9 +1085,17 @@ case PCB_PSSH_POLY: { /* convert the shape poly to a new poly so that it can be intersected */ - rnd_bool res; + rnd_bool res = rnd_false; + pcb_poly_it_t it2; + rnd_polyarea_t *pa2; rnd_polyarea_t *shp = pcb_pstk_shp_poly2area(ps, shape); - res = rnd_polyarea_touching(shp, poly->Clipped); + rnd_pline_t *c1 = shp->contours; + + for(pa2 = pcb_poly_island_first(poly, &it2); pa2 != NULL; pa2 = pcb_poly_island_next(&it2)) { + rnd_pline_t *c2 = pcb_poly_contour(&it2); + if (pcb_isc_poly_poly_bloated(ctx, c1, c2, poly)) + res = rnd_true; + } rnd_polyarea_free(&shp); return res; }