[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: pcb, howto get plain rats lines instead of circles
On Wed, 2008-10-08 at 15:56 +0100, Peter Clifton wrote:
> On Tue, 2008-10-07 at 23:46 -0700, Ben Jackson wrote:
> > On Wed, Oct 08, 2008 at 07:56:27AM +0200, Bert Timmerman wrote:
>
> > From my quick test it seems to be due to 'IsPointInBox' having wholly
> > unexpected behavior due to a rather bizzare implementation. It turns
> > the 'box' it gets as input into a pad and then calls the pad intersection.
> > It looks like the code is broken if the box is wider than tall. If you
> > replace the rectangle in that b2.pcb someone sent out with a new one
> > that's taller than wide, it works fine.
>
> Here is a patch "fixing" IsPointInBox. I've not tested it extensively
> (with a radius parameter passed).
And here's a fix to allow arbitrary polygons.
I scratched my head for quite a while trying to figure out why
IsPointInPolygon kept returning false, until I realised that due to the
clearance hole, the pad _isn't_ touching the polygon. I made a variant
function IsPointInPolygonIgnoreHoles() which just tests against the
first contour of the first clipped portion of the polygon. Since its
only caller doesn't use it, that call doesn't support bloating the
search by a radius.
--
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 2c425534d5cc5b9bf41668dc84f1ddef3c9044dc Mon Sep 17 00:00:00 2001
From: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Wed, 8 Oct 2008 16:27:34 +0100
Subject: [PATCH] Make rats to polygons work for arbitrary clipped shapes
---
src/polygon.c | 12 ++++++++++++
src/polygon.h | 1 +
src/rats.c | 29 +++++++----------------------
3 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/polygon.c b/src/polygon.c
index 54f8f9f..ca7691f 100644
--- a/src/polygon.c
+++ b/src/polygon.c
@@ -1540,6 +1540,18 @@ IsPointInPolygon (LocationType X, LocationType Y, BDimension r,
return isects (c, p, True);
}
+
+Boolean
+IsPointInPolygonIgnoreHoles (LocationType X, LocationType Y, PolygonTypePtr p)
+{
+ POLYAREA *c;
+ Vector v;
+ v[0] = X;
+ v[1] = Y;
+ if (poly_InsideContour (p->Clipped->contours, v))
+ return True;
+}
+
Boolean
IsRectangleInPolygon (LocationType X1, LocationType Y1, LocationType X2,
LocationType Y2, PolygonTypePtr p)
diff --git a/src/polygon.h b/src/polygon.h
index 2c78e94..8f444fd 100644
--- a/src/polygon.h
+++ b/src/polygon.h
@@ -58,6 +58,7 @@ void RestoreToPolygon(DataType *, int, void *, void *);
void ClearFromPolygon(DataType *, int, void *, void *);
Boolean IsPointInPolygon (LocationType, LocationType, BDimension, PolygonTypePtr);
+Boolean IsPointInPolygonIgnoreHoles (LocationType, LocationType, PolygonTypePtr);
Boolean IsRectangleInPolygon (LocationType, LocationType, LocationType,
LocationType, PolygonTypePtr);
Boolean isects (POLYAREA *, PolygonTypePtr, Boolean);
diff --git a/src/rats.c b/src/rats.c
index 5ac15ed..27ff95b 100644
--- a/src/rats.c
+++ b/src/rats.c
@@ -504,24 +504,11 @@ GatherSubnets (NetListTypePtr Netl, Boolean NoWarn, Boolean AndRats)
}
}
ENDALL_LOOP;
- /* add rectangular polygons so the auto-router can see them as targets */
- /* NB: code in DrawShortestRats below relies on only rectangular polys */
+ /* add polygons so the auto-router can see them as targets */
ALLPOLYGON_LOOP (PCB->Data);
{
if (TEST_FLAG (DRCFLAG, polygon) && polygon->PointN == 4)
{
- if (polygon->Points[0].X != polygon->Points[1].X &&
- polygon->Points[0].Y != polygon->Points[1].Y)
- continue;
- if (polygon->Points[1].X != polygon->Points[2].X &&
- polygon->Points[1].Y != polygon->Points[2].Y)
- continue;
- if (polygon->Points[2].X != polygon->Points[3].X &&
- polygon->Points[2].Y != polygon->Points[3].Y)
- continue;
- if (polygon->Points[0].X != polygon->Points[3].X &&
- polygon->Points[0].Y != polygon->Points[3].Y)
- continue;
conn = GetConnectionMemory (a);
/* make point on a vertex */
conn->X = polygon->Clipped->contours->head.point[0];
@@ -603,10 +590,9 @@ DrawShortestRats (NetListTypePtr Netl, void (*funcp) ())
*/
if (conn1->type == POLYGON_TYPE &&
(polygon = (PolygonTypePtr)conn1->ptr2) &&
- IsPointInBox (conn2->X, conn2->Y, (BoxTypePtr)polygon, 0)
- && !(distance == 0 &&
- firstpoint && firstpoint->type == VIA_TYPE))
- // IsPointInPolygon (conn2->X, conn2->Y, 0, polygon))
+ !(distance == 0 &&
+ firstpoint && firstpoint->type == VIA_TYPE) &&
+ IsPointInPolygonIgnoreHoles (conn2->X, conn2->Y, polygon))
{
distance = 0;
firstpoint = conn2;
@@ -615,10 +601,9 @@ DrawShortestRats (NetListTypePtr Netl, void (*funcp) ())
}
else if (conn2->type == POLYGON_TYPE &&
(polygon = (PolygonTypePtr)conn2->ptr2) &&
- IsPointInBox (conn1->X, conn1->Y, (BoxTypePtr)polygon, 0)
- && !(distance == 0 &&
- firstpoint && firstpoint->type == VIA_TYPE))
- // IsPointInPolygon (conn1->X, conn1->Y, 0, polygon))
+ !(distance == 0 &&
+ firstpoint && firstpoint->type == VIA_TYPE) &&
+ IsPointInPolygonIgnoreHoles (conn1->X, conn1->Y, polygon))
{
distance = 0;
firstpoint = conn1;
--
1.5.6.3
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user