Index: trunk/doc-rnd/hacking/renames =================================================================== --- trunk/doc-rnd/hacking/renames (revision 4989) +++ trunk/doc-rnd/hacking/renames (revision 4990) @@ -697,3 +697,12 @@ poly_Init -> pcb_polyarea_init poly_FreeContours -> pcb_poly_contours_free poly_Valid -> pcb_poly_valid +vect_dist2 -> pcb_vect_dist2 +vect_det2 -> pcb_vect_det2 +vect_len2 -> pcb_vect_len2 +vect_inters2 -> pcb_vect_inters2 +poly_Boolean -> pcb_polyarea_boolean +poly_Boolean_free -> pcb_polyarea_boolean_free +poly_AndSubtract_free -> pcb_polyarea_and_subtract_free +poly_bbox -> pcb_polyarea_bbox +Savepcb_polyarea_t -> pcb_polyarea_save Index: trunk/src/action_helper.c =================================================================== --- trunk/src/action_helper.c (revision 4989) +++ trunk/src/action_helper.c (revision 4990) @@ -1014,7 +1014,7 @@ new_hole = PolygonToPoly(&Crosshair.AttachedPolygon); /* Subtract the hole from the original polygon shape */ - poly_Boolean_free(original, new_hole, &result, PBO_SUB); + pcb_polyarea_boolean_free(original, new_hole, &result, PBO_SUB); /* Convert the resulting polygon(s) into a new set of nodes * and place them on the page. Delete the original polygon. Index: trunk/src/hid_draw_helpers.c =================================================================== --- trunk/src/hid_draw_helpers.c (revision 4989) +++ trunk/src/hid_draw_helpers.c (revision 4990) @@ -85,7 +85,7 @@ pcb_poly_contour_copy(&pl_copy, pl); piece_poly = pcb_polyarea_create(); pcb_polyarea_contour_include(piece_poly, pl_copy); - x = poly_Boolean_free(piece_poly, clip_poly, &clipped_pieces, PBO_ISECT); + x = pcb_polyarea_boolean_free(piece_poly, clip_poly, &clipped_pieces, PBO_ISECT); if (x != err_ok || clipped_pieces == NULL) return; Index: trunk/src/obj_pinvia.c =================================================================== --- trunk/src/obj_pinvia.c (revision 4989) +++ trunk/src/obj_pinvia.c (revision 4990) @@ -210,7 +210,7 @@ if ((PCB_FLAG_SQUARE_GET(Pin) > 1) && (PCB_FLAG_TEST(PCB_FLAG_SQUARE, Pin))) { pcb_polyarea_t *p = PinPoly(Pin, PIN_SIZE(Pin), Pin->Clearance); - poly_bbox(p, &Pin->BoundingBox); + pcb_polyarea_bbox(p, &Pin->BoundingBox); pcb_polyarea_free(&p); } Index: trunk/src/obj_pinvia_therm.c =================================================================== --- trunk/src/obj_pinvia_therm.c (revision 4989) +++ trunk/src/obj_pinvia_therm.c (revision 4990) @@ -318,20 +318,20 @@ p = OctagonPoly(pin->X, pin->Y, w, PCB_FLAG_SQUARE_GET(pin)); p2 = OctagonPoly(pin->X, pin->Y, pin->Thickness, PCB_FLAG_SQUARE_GET(pin)); /* make full clearance ring */ - poly_Boolean_free(p, p2, &m, PBO_SUB); + pcb_polyarea_boolean_free(p, p2, &m, PBO_SUB); switch (style) { default: case 1: p = diag_line(pin->X, pin->Y, w, t, pcb_true); - poly_Boolean_free(m, p, &p2, PBO_SUB); + pcb_polyarea_boolean_free(m, p, &p2, PBO_SUB); p = diag_line(pin->X, pin->Y, w, t, pcb_false); - poly_Boolean_free(p2, p, &m, PBO_SUB); + pcb_polyarea_boolean_free(p2, p, &m, PBO_SUB); return m; case 2: p = RectPoly(pin->X - t, pin->X + t, pin->Y - w, pin->Y + w); - poly_Boolean_free(m, p, &p2, PBO_SUB); + pcb_polyarea_boolean_free(m, p, &p2, PBO_SUB); p = RectPoly(pin->X - w, pin->X + w, pin->Y - t, pin->Y + t); - poly_Boolean_free(p2, p, &m, PBO_SUB); + pcb_polyarea_boolean_free(p2, p, &m, PBO_SUB); return m; /* fix me add thermal style 4 */ case 5: @@ -341,8 +341,8 @@ /* cheat by using the square therm's rounded parts */ p = square_therm(pin, style); q = RectPoly(pin->X - t, pin->X + t, pin->Y - t, pin->Y + t); - poly_Boolean_free(p, q, &p2, PBO_UNITE); - poly_Boolean_free(m, p2, &p, PBO_ISECT); + pcb_polyarea_boolean_free(p, q, &p2, PBO_UNITE); + pcb_polyarea_boolean_free(m, p2, &p, PBO_ISECT); return p; } } @@ -377,7 +377,7 @@ pa = CirclePoly(pin->X, pin->Y, t); arc = CirclePoly(pin->X, pin->Y, pin->Thickness / 2); /* create a thin ring */ - poly_Boolean_free(pa, arc, &m, PBO_SUB); + pcb_polyarea_boolean_free(pa, arc, &m, PBO_SUB); /* fix me needs error checking */ if (style == 2) { /* t is the theoretically required length, but we use twice that @@ -384,7 +384,7 @@ * to avoid descritisation errors in our circle approximation. */ pa = RectPoly(pin->X - t * 2, pin->X + t * 2, pin->Y - w, pin->Y + w); - poly_Boolean_free(m, pa, &arc, PBO_SUB); + pcb_polyarea_boolean_free(m, pa, &arc, PBO_SUB); pa = RectPoly(pin->X - w, pin->X + w, pin->Y - t * 2, pin->Y + t * 2); } else { @@ -392,10 +392,10 @@ * to avoid descritisation errors in our circle approximation. */ pa = diag_line(pin->X, pin->Y, t * 2, w, pcb_true); - poly_Boolean_free(m, pa, &arc, PBO_SUB); + pcb_polyarea_boolean_free(m, pa, &arc, PBO_SUB); pa = diag_line(pin->X, pin->Y, t * 2, w, pcb_false); } - poly_Boolean_free(arc, pa, &m, PBO_SUB); + pcb_polyarea_boolean_free(arc, pa, &m, PBO_SUB); return m; } Index: trunk/src/polyarea.h =================================================================== --- trunk/src/polyarea.h (revision 4989) +++ trunk/src/polyarea.h (revision 4990) @@ -154,18 +154,18 @@ PBO_XOR }; -double vect_dist2(pcb_vector_t v1, pcb_vector_t v2); -double vect_det2(pcb_vector_t v1, pcb_vector_t v2); -double vect_len2(pcb_vector_t v1); +double pcb_vect_dist2(pcb_vector_t v1, pcb_vector_t v2); +double pcb_vect_det2(pcb_vector_t v1, pcb_vector_t v2); +double pcb_vect_len2(pcb_vector_t v1); -int vect_inters2(pcb_vector_t A, pcb_vector_t B, pcb_vector_t C, pcb_vector_t D, pcb_vector_t S1, pcb_vector_t S2); +int pcb_vect_inters2(pcb_vector_t A, pcb_vector_t B, pcb_vector_t C, pcb_vector_t D, pcb_vector_t S1, pcb_vector_t S2); -int poly_Boolean(const pcb_polyarea_t * a, const pcb_polyarea_t * b, pcb_polyarea_t ** res, int action); -int poly_Boolean_free(pcb_polyarea_t * a, pcb_polyarea_t * b, pcb_polyarea_t ** res, int action); -int poly_AndSubtract_free(pcb_polyarea_t * a, pcb_polyarea_t * b, pcb_polyarea_t ** aandb, pcb_polyarea_t ** aminusb); -int Savepcb_polyarea_t(pcb_polyarea_t * PA, char *fname); +int pcb_polyarea_boolean(const pcb_polyarea_t * a, const pcb_polyarea_t * b, pcb_polyarea_t ** res, int action); +int pcb_polyarea_boolean_free(pcb_polyarea_t * a, pcb_polyarea_t * b, pcb_polyarea_t ** res, int action); +int pcb_polyarea_and_subtract_free(pcb_polyarea_t * a, pcb_polyarea_t * b, pcb_polyarea_t ** aandb, pcb_polyarea_t ** aminusb); +int pcb_polyarea_save(pcb_polyarea_t * PA, char *fname); /* calculate the bounding box of a pcb_polyarea_t and save result in b */ -void poly_bbox(pcb_polyarea_t * p, pcb_box_t * b); +void pcb_polyarea_bbox(pcb_polyarea_t * p, pcb_box_t * b); #endif /* PCB_POLYAREA_H */ Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 4989) +++ trunk/src/polygon.c (revision 4990) @@ -560,7 +560,7 @@ tmp1 = ArcPolyNoIntersect(&seg1, thick); tmp2 = ArcPolyNoIntersect(&seg2, thick); - poly_Boolean_free(tmp1, tmp2, &res, PBO_UNITE); + pcb_polyarea_boolean_free(tmp1, tmp2, &res, PBO_UNITE); return res; } @@ -709,9 +709,9 @@ assert(pcb_poly_valid(p->Clipped)); assert(pcb_poly_valid(np)); if (fnp) - x = poly_Boolean_free(p->Clipped, np, &merged, PBO_SUB); + x = pcb_polyarea_boolean_free(p->Clipped, np, &merged, PBO_SUB); else { - x = poly_Boolean(p->Clipped, np, &merged, PBO_SUB); + x = pcb_polyarea_boolean(p->Clipped, np, &merged, PBO_SUB); pcb_polyarea_free(&p->Clipped); } assert(!merged || pcb_poly_valid(merged)); @@ -895,7 +895,7 @@ longjmp(info->env, 1); } - poly_Boolean_free(info->accumulate, np, &merged, PBO_UNITE); + pcb_polyarea_boolean_free(info->accumulate, np, &merged, PBO_UNITE); info->accumulate = merged; info->batch_size++; @@ -961,7 +961,7 @@ if (!(np = LinePoly(line, line->Thickness + line->Clearance))) longjmp(info->env, 1); - poly_Boolean_free(info->accumulate, np, &merged, PBO_UNITE); + pcb_polyarea_boolean_free(info->accumulate, np, &merged, PBO_UNITE); info->accumulate = merged; info->batch_size++; @@ -1059,7 +1059,7 @@ orig_poly = original_poly(p); - x = poly_Boolean_free(np, orig_poly, &clipped_np, PBO_ISECT); + x = pcb_polyarea_boolean_free(np, orig_poly, &clipped_np, PBO_ISECT); if (x != err_ok) { fprintf(stderr, "Error while clipping PBO_ISECT: %d\n", x); pcb_polyarea_free(&clipped_np); @@ -1066,7 +1066,7 @@ goto fail; } - x = poly_Boolean_free(p->Clipped, clipped_np, &merged, PBO_UNITE); + x = pcb_polyarea_boolean_free(p->Clipped, clipped_np, &merged, PBO_UNITE); if (x != err_ok) { fprintf(stderr, "Error while clipping PBO_UNITE: %d\n", x); pcb_polyarea_free(&merged); @@ -1631,7 +1631,7 @@ /* make a rectangle of the left region slicing through the middle of the first hole */ poly2 = RectPoly(p->xmin, (p->next->xmin + p->next->xmax) / 2, p->ymin, p->ymax); - poly_AndSubtract_free(pa, poly2, &left, &right); + pcb_polyarea_and_subtract_free(pa, poly2, &left, &right); if (left) { pcb_polyarea_t *cur, *next; cur = left; @@ -1667,7 +1667,7 @@ /* clip to the bounding box */ if (clip) { pcb_polyarea_t *cbox = RectPoly(clip->X1, clip->X2, clip->Y1, clip->Y2); - poly_Boolean_free(main_contour, cbox, &main_contour, PBO_ISECT); + pcb_polyarea_boolean_free(main_contour, cbox, &main_contour, PBO_ISECT); } if (main_contour == NULL) return; Index: trunk/src/polygon1.c =================================================================== --- trunk/src/polygon1.c (revision 4989) +++ trunk/src/polygon1.c (revision 4990) @@ -73,11 +73,11 @@ void vect_min(pcb_vector_t res, pcb_vector_t v2, pcb_vector_t v3); void vect_max(pcb_vector_t res, pcb_vector_t v2, pcb_vector_t v3); -double vect_dist2(pcb_vector_t v1, pcb_vector_t v2); -double vect_det2(pcb_vector_t v1, pcb_vector_t v2); -double vect_len2(pcb_vector_t v1); +double pcb_vect_dist2(pcb_vector_t v1, pcb_vector_t v2); +double pcb_vect_det2(pcb_vector_t v1, pcb_vector_t v2); +double pcb_vect_len2(pcb_vector_t v1); -int vect_inters2(pcb_vector_t A, pcb_vector_t B, pcb_vector_t C, pcb_vector_t D, pcb_vector_t S1, pcb_vector_t S2); +int pcb_vect_inters2(pcb_vector_t A, pcb_vector_t B, pcb_vector_t C, pcb_vector_t D, pcb_vector_t S1, pcb_vector_t S2); /* note that a vertex v's Flags.status represents the edge defined by * v to v->next (i.e. the edge is forward of v) @@ -587,7 +587,7 @@ if (s->intersected || i->s->intersected) return R_DIR_NOT_FOUND; - cnt = vect_inters2(s->v->point, s->v->next->point, i->v->point, i->v->next->point, s1, s2); + cnt = pcb_vect_inters2(s->v->point, s->v->next->point, i->v->point, i->v->next->point, s1, s2); if (!cnt) return R_DIR_NOT_FOUND; if (i->touch) /* if checking touches one find and we're done */ @@ -2049,7 +2049,7 @@ } /* the main clipping routines */ -int poly_Boolean(const pcb_polyarea_t * a_org, const pcb_polyarea_t * b_org, pcb_polyarea_t ** res, int action) +int pcb_polyarea_boolean(const pcb_polyarea_t * a_org, const pcb_polyarea_t * b_org, pcb_polyarea_t ** res, int action) { pcb_polyarea_t *a = NULL, *b = NULL; @@ -2056,11 +2056,11 @@ if (!pcb_polyarea_m_copy0(&a, a_org) || !pcb_polyarea_m_copy0(&b, b_org)) return err_no_memory; - return poly_Boolean_free(a, b, res, action); + return pcb_polyarea_boolean_free(a, b, res, action); } /* poly_Boolean */ /* just like poly_Boolean but frees the input polys */ -int poly_Boolean_free(pcb_polyarea_t * ai, pcb_polyarea_t * bi, pcb_polyarea_t ** res, int action) +int pcb_polyarea_boolean_free(pcb_polyarea_t * ai, pcb_polyarea_t * bi, pcb_polyarea_t ** res, int action) { pcb_polyarea_t *a = ai, *b = bi; pcb_pline_t *a_isected = NULL; @@ -2161,7 +2161,7 @@ /* compute the intersection and subtraction (divides "a" into two pieces) * and frees the input polys. This assumes that bi is a single simple polygon. */ -int poly_AndSubtract_free(pcb_polyarea_t * ai, pcb_polyarea_t * bi, pcb_polyarea_t ** aandb, pcb_polyarea_t ** aminusb) +int pcb_polyarea_and_subtract_free(pcb_polyarea_t * ai, pcb_polyarea_t * bi, pcb_polyarea_t ** aandb, pcb_polyarea_t ** aminusb) { pcb_polyarea_t *a = ai, *b = bi; pcb_pline_t *p, *holes = NULL; @@ -2334,7 +2334,7 @@ * So, remove the point c */ - if (vect_det2(p1, p2) == 0) { + if (pcb_vect_det2(p1, p2) == 0) { pcb_poly_vertex_exclude(c); free(c); c = p; @@ -2831,9 +2831,9 @@ vect_sub(pdir, pn->point, pn->prev->point); vect_sub(ndir, pn->next->point, pn->point); - p_c = vect_det2(pdir, cdir) >= 0; - n_c = vect_det2(ndir, cdir) >= 0; - p_n = vect_det2(pdir, ndir) >= 0; + p_c = pcb_vect_det2(pdir, cdir) >= 0; + n_c = pcb_vect_det2(ndir, cdir) >= 0; + p_n = pcb_vect_det2(pdir, ndir) >= 0; if ((p_n && p_c && n_c) || ((!p_n) && (p_c || n_c))) return pcb_true; @@ -2853,20 +2853,20 @@ do { a2 = a1; do { - if (!node_neighbours(a1, a2) && (icnt = vect_inters2(a1->point, a1->next->point, a2->point, a2->next->point, i1, i2)) > 0) { + if (!node_neighbours(a1, a2) && (icnt = pcb_vect_inters2(a1->point, a1->next->point, a2->point, a2->next->point, i1, i2)) > 0) { if (icnt > 1) return pcb_true; - if (vect_dist2(i1, a1->point) < EPSILON) + if (pcb_vect_dist2(i1, a1->point) < EPSILON) hit1 = a1; - else if (vect_dist2(i1, a1->next->point) < EPSILON) + else if (pcb_vect_dist2(i1, a1->next->point) < EPSILON) hit1 = a1->next; else hit1 = NULL; - if (vect_dist2(i1, a2->point) < EPSILON) + if (pcb_vect_dist2(i1, a2->point) < EPSILON) hit2 = a2; - else if (vect_dist2(i1, a2->next->point) < EPSILON) + else if (pcb_vect_dist2(i1, a2->next->point) < EPSILON) hit2 = a2->next; else hit2 = NULL; @@ -2902,7 +2902,7 @@ return pcb_false; } -void poly_bbox(pcb_polyarea_t * p, pcb_box_t * b) +void pcb_polyarea_bbox(pcb_polyarea_t * p, pcb_box_t * b) { pcb_pline_t *n; /*int cnt;*/ @@ -3013,12 +3013,12 @@ v1[1] = (v2[1] > v3[1]) ? v2[1] : v3[1]; } /* vect_max */ -double vect_len2(pcb_vector_t v) +double pcb_vect_len2(pcb_vector_t v) { return ((double) v[0] * v[0] + (double) v[1] * v[1]); /* why sqrt? only used for compares */ } -double vect_dist2(pcb_vector_t v1, pcb_vector_t v2) +double pcb_vect_dist2(pcb_vector_t v1, pcb_vector_t v2) { double dx = v1[0] - v2[0]; double dy = v1[1] - v2[1]; @@ -3027,7 +3027,7 @@ } /* value has sign of angle between vectors */ -double vect_det2(pcb_vector_t v1, pcb_vector_t v2) +double pcb_vect_det2(pcb_vector_t v1, pcb_vector_t v2) { return (((double) v1[0] * v2[1]) - ((double) v2[0] * v1[1])); } @@ -3053,7 +3053,7 @@ (C) 1997 Michael Leonov, Alexey Nikitin */ -int vect_inters2(pcb_vector_t p1, pcb_vector_t p2, pcb_vector_t q1, pcb_vector_t q2, pcb_vector_t S1, pcb_vector_t S2) +int pcb_vect_inters2(pcb_vector_t p1, pcb_vector_t p2, pcb_vector_t q1, pcb_vector_t q2, pcb_vector_t S1, pcb_vector_t S2) { double s, t, deel; double rpx, rpy, rqx, rqy; @@ -3082,7 +3082,7 @@ /* If this product is not zero then p1-p2 and q1-q2 are not on same line! */ - if (vect_det2(q1p1, q1q2) != 0) + if (pcb_vect_det2(q1p1, q1q2) != 0) return 0; dc1 = 0; /* m_len(p1 - p1) */ Index: trunk/src_plugins/jostle/jostle.c =================================================================== --- trunk/src_plugins/jostle/jostle.c (revision 4989) +++ trunk/src_plugins/jostle/jostle.c (revision 4990) @@ -41,7 +41,7 @@ /*#define DEBUG_pcb_polyarea_t*/ -double vect_dist2(pcb_vector_t v1, pcb_vector_t v2); +double pcb_vect_dist2(pcb_vector_t v1, pcb_vector_t v2); #define Vcpy2(r,a) {(r)[0] = (a)[0]; (r)[1] = (a)[1];} #define Vswp2(a,b) { long t; \ t = (a)[0], (a)[0] = (b)[0], (b)[0] = t; \ @@ -287,7 +287,7 @@ line = Createpcb_vector_tLineOnLayer(layer, a, b, orig->Thickness, orig->Clearance, orig->Flags); if (line && expandp) { pcb_polyarea_t *p = LinePoly(line, line->Thickness + line->Clearance); - poly_Boolean_free(*expandp, p, expandp, PBO_UNITE); + pcb_polyarea_boolean_free(*expandp, p, expandp, PBO_UNITE); } return line; } @@ -327,14 +327,14 @@ pcb_polyarea_t_findXmostLine(brush, side, flatA, flatB, line->Thickness / 2); pcb_polyarea_t_findXmostLine(brush, rotateSide(side, 1), pA, pB, line->Thickness / 2); pcb_polyarea_t_findXmostLine(brush, rotateSide(side, -1), qA, qB, line->Thickness / 2); - hits = vect_inters2(lA, lB, qA, qB, a, junk) + - vect_inters2(qA, qB, flatA, flatB, b, junk) + - vect_inters2(pA, pB, flatA, flatB, c, junk) + vect_inters2(lA, lB, pA, pB, d, junk); + hits = pcb_vect_inters2(lA, lB, qA, qB, a, junk) + + pcb_vect_inters2(qA, qB, flatA, flatB, b, junk) + + pcb_vect_inters2(pA, pB, flatA, flatB, c, junk) + pcb_vect_inters2(lA, lB, pA, pB, d, junk); if (hits != 4) { return 0; } /* flip the line endpoints to match up with a/b */ - if (vect_dist2(lA, d) < vect_dist2(lA, a)) { + if (pcb_vect_dist2(lA, d) < pcb_vect_dist2(lA, a)) { Vswp2(lA, lB); } MakeBypassLine(layer, lA, a, line, NULL); @@ -412,7 +412,7 @@ lp = LinePoly(line, 1); if (!pcb_polyarea_m_copy0(©, info->brush)) return 0; - r = poly_Boolean_free(copy, lp, &tmp, PBO_SUB); + r = pcb_polyarea_boolean_free(copy, lp, &tmp, PBO_SUB); if (r != err_ok) { pcb_fprintf(stderr, "Error while jostling PBO_SUB: %d\n", r); return 0; @@ -423,7 +423,7 @@ */ pcb_fprintf(stderr, "try isect??\n"); lp = LinePoly(line, line->Thickness); - r = poly_Boolean_free(tmp, lp, &tmp, PBO_ISECT); + r = pcb_polyarea_boolean_free(tmp, lp, &tmp, PBO_ISECT); if (r != err_ok) { fprintf(stderr, "Error while jostling PBO_ISECT: %d\n", r); return 0; @@ -533,7 +533,7 @@ expand = NULL; MakeBypassingLines(info.smallest, info.layer, info.line, info.side, &expand); pcb_polyarea_free(&info.smallest); - poly_Boolean_free(info.brush, expand, &info.brush, PBO_UNITE); + pcb_polyarea_boolean_free(info.brush, expand, &info.brush, PBO_UNITE); } } while (found); SetChangedFlag(pcb_true); Index: trunk/src_plugins/polycombine/polycombine.c =================================================================== --- trunk/src_plugins/polycombine/polycombine.c (revision 4989) +++ trunk/src_plugins/polycombine/polycombine.c (revision 4990) @@ -256,7 +256,7 @@ for (cur_node = root; cur_node != NULL; cur_node = cur_node->next) { /* Process this element */ /* printf ("Processing node %ld %s\n", cur_node->polygon->ID, cur_node->forward ? "FWD" : "BWD");*/ - poly_Boolean_free(accumulate, cur_node->polyarea, &res, cur_node->forward ? PBO_UNITE : PBO_SUB); + pcb_polyarea_boolean_free(accumulate, cur_node->polyarea, &res, cur_node->forward ? PBO_UNITE : PBO_SUB); accumulate = res; /* And its children if it has them */