Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 10053) +++ trunk/src/polygon.c (revision 10054) @@ -1926,3 +1926,24 @@ pcb_board_set_changed_flag(pcb_true); } + +int pcb_pline_is_rectangle(pcb_pline_t *pl) +{ + int n; + pcb_coord_t x[4], y[4]; + pcb_vnode_t *v; + + v = pl->head.next; + n = 0; + do { + x[n] = v->point[0]; + y[n] = v->point[1]; + n++; + v = v->next; + } while((n < 4) && (v != pl->head.next)); + + if (n != 4) + return 0; + + return sqr(x[0] - x[2]) * sqr(y[0] - y[2]) == sqr(x[1] - x[3]) * sqr(y[1] - y[3]); +} Index: trunk/src/polygon.h =================================================================== --- trunk/src/polygon.h (revision 10053) +++ trunk/src/polygon.h (revision 10054) @@ -92,5 +92,7 @@ void pcb_poly_square_pin_factors(int style, double *xm, double *ym); +int pcb_pline_is_rectangle(pcb_pline_t *pl); + #endif