On Tue, 2008-09-30 at 13:38 +0100, Peter Clifton wrote:
> Attached again now.
This time it was my fault.. I'd not exported the patch properly!
I've attached an updated patch which re-adds extra bloat to the rect
being ubsubtracted.
What isn't clear to me, is why so much bloat? (50-101). Why in other
cases, is the bloat 50, or 101?
I've set bloat for the ubsubtract at 50 for now. Is that going to be
enough?
Should the calls to clearPoly all use the same bloat as the bloat on the
bouding box, or should that bloat be bigger?
Best wishes,
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
>From 7fd13cd13bcea0ab4a7825bf434d3e5eba42f24f Mon Sep 17 00:00:00 2001
From: Peter Clifton <[EMAIL PROTECTED]>
Date: Tue, 30 Sep 2008 14:09:41 +0100
Subject: [PATCH] Don't bother unsubtracting complex polygons when doing incremental updates
Since the polygon is re-cleared against any objects existing within the
bounding box of the update region, there is no point wasting CPU cycles
intersecting a more complex polygon than necessary. Just take the UNION
of the polygon being unsubtracted, and the bounding box of the hole to
be filed in.
---
src/polygon.c | 51 ++++++++++++++++++++++++++++++---------------------
src/polygon.h | 1 +
2 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/src/polygon.c b/src/polygon.c
index 3982708..b20c350 100644
--- a/src/polygon.c
+++ b/src/polygon.c
@@ -65,6 +65,8 @@ RCSID ("$Id$");
#define ROUND(x) ((long)(((x) >= 0 ? (x) + 0.5 : (x) - 0.5)))
+#define UNSUBTRACT_BLOAT 50
+
/* ---------------------------------------------------------------------------
* local prototypes
*/
@@ -641,6 +643,13 @@ PinPoly (PinType * pin, BDimension thick, BDimension clear)
return CirclePoly (pin->X, pin->Y, size);
}
+POLYAREA *
+BoxPolyBloated (BoxType *box, BDimension bloat)
+{
+ return RectPoly (box->X1 - bloat, box->X2 + bloat,
+ box->Y1 - bloat, box->Y2 + bloat);
+}
+
/* remove the pin clearance from the polygon */
static int
SubtractPin (DataType * d, PinType * pin, LayerType * l, PolygonType * p)
@@ -908,7 +917,7 @@ UnsubtractPin (PinType * pin, LayerType * l, PolygonType * p)
POLYAREA *np;
/* overlap a bit to prevent gaps from rounding errors */
- np = PinPoly (pin, pin->Thickness, pin->Clearance * 1.1);
+ np = BoxPolyBloated (&pin->BoundingBox, UNSUBTRACT_BLOAT);
if (!np)
return 0;
@@ -922,12 +931,15 @@ UnsubtractPin (PinType * pin, LayerType * l, PolygonType * p)
static int
UnsubtractArc (ArcType * arc, LayerType * l, PolygonType * p)
{
- POLYAREA *np = NULL;
+ POLYAREA *np;
if (!TEST_FLAG (CLEARLINEFLAG, arc))
return 0;
- /* overlap a bit to prevent notches from rounding errors */
- if (!(np = ArcPoly (arc, arc->Thickness + arc->Clearance + 100)))
+
+ /* overlap a bit to prevent gaps from rounding errors */
+ np = BoxPolyBloated (&arc->BoundingBox, UNSUBTRACT_BLOAT);
+
+ if (!np)
return 0;
if (!Unsubtract (np, p))
return 0;
@@ -938,12 +950,15 @@ UnsubtractArc (ArcType * arc, LayerType * l, PolygonType * p)
static int
UnsubtractLine (LineType * line, LayerType * l, PolygonType * p)
{
- POLYAREA *np = NULL;
+ POLYAREA *np;
if (!TEST_FLAG (CLEARLINEFLAG, line))
return 0;
+
/* overlap a bit to prevent notches from rounding errors */
- if (!(np = LinePoly (line, line->Thickness + line->Clearance + 100)))
+ np = BoxPolyBloated (&line->BoundingBox, UNSUBTRACT_BLOAT);
+
+ if (!np)
return 0;
if (!Unsubtract (np, p))
return 0;
@@ -955,11 +970,14 @@ static int
UnsubtractText (TextType * text, LayerType * l, PolygonType * p)
{
POLYAREA *np;
- const BoxType *b = &text->BoundingBox;
if (!TEST_FLAG (CLEARLINEFLAG, text))
return 0;
- if (!(np = RoundRect (b->X1, b->X2, b->Y1, b->Y2, PCB->Bloat + 100)))
+
+ /* overlap a bit to prevent notches from rounding errors */
+ np = BoxPolyBloated (&text->BoundingBox, UNSUBTRACT_BLOAT);
+
+ if (!np)
return -1;
if (!Unsubtract (np, p))
return 0;
@@ -970,20 +988,11 @@ UnsubtractText (TextType * text, LayerType * l, PolygonType * p)
static int
UnsubtractPad (PadType * pad, LayerType * l, PolygonType * p)
{
- POLYAREA *np = NULL;
+ POLYAREA *np;
+
+ /* overlap a bit to prevent notches from rounding errors */
+ np = BoxPolyBloated (&pad->BoundingBox, UNSUBTRACT_BLOAT);
- if (TEST_FLAG (SQUAREFLAG, pad))
- {
- if (!
- (np = SquarePadPoly (pad, pad->Thickness + pad->Clearance + 100)))
- return 0;
- }
- else
- {
- if (!
- (np = LinePoly ((LineType *) pad, pad->Thickness + pad->Clearance + 100)))
- return 0;
- }
if (!np)
return 0;
if (!Unsubtract (np, p))
diff --git a/src/polygon.h b/src/polygon.h
index 64eeea1..2c78e94 100644
--- a/src/polygon.h
+++ b/src/polygon.h
@@ -51,6 +51,7 @@ POLYAREA * OctagonPoly(LocationType x, LocationType y, BDimension radius);
POLYAREA * LinePoly(LineType *l, BDimension thick);
POLYAREA * ArcPoly(ArcType *l, BDimension thick);
POLYAREA * PinPoly(PinType *l, BDimension thick, BDimension clear);
+POLYAREA * BoxPolyBloated (BoxType *box, BDimension radius);
void frac_circle (PLINE *, LocationType, LocationType, Vector, int);
int InitClip(DataType *d, LayerType *l, PolygonType *p);
void RestoreToPolygon(DataType *, int, void *, void *);
--
1.5.6.3
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev