From 5d4e2aa59597135b8d69b8137140a1008f45bb63 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 3 Jun 2022 17:22:15 -0400 Subject: [PATCH] PNS: Remove offsets from hull generation This is likely an old workaround to numerical precision issues in the DRC system that no longer exist. Removing this is necessary for "exact" hull generation to produce walkaround results that look nice (paths falling exactly on the grid lines) Fixes https://gitlab.com/kicad/code/kicad/-/issues/10710 --- pcbnew/router/pns_solid.cpp | 4 ++-- pcbnew/router/pns_utils.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pcbnew/router/pns_solid.cpp b/pcbnew/router/pns_solid.cpp index fd8195b996..2441a0c71d 100644 --- a/pcbnew/router/pns_solid.cpp +++ b/pcbnew/router/pns_solid.cpp @@ -49,7 +49,7 @@ static const SHAPE_LINE_CHAIN buildHullForPrimitiveShape( const SHAPE* aShape, i const SHAPE_RECT* rect = static_cast( aShape ); return OctagonalHull( rect->GetPosition(), rect->GetSize(), - cl + 1, + cl, 0 ); } @@ -59,7 +59,7 @@ static const SHAPE_LINE_CHAIN buildHullForPrimitiveShape( const SHAPE* aShape, i int r = circle->GetRadius(); return OctagonalHull( circle->GetCenter() - VECTOR2I( r, r ), VECTOR2I( 2 * r, 2 * r ), - cl + 1, + cl, 2.0 * ( 1.0 - M_SQRT1_2 ) * ( r + cl ) ); } diff --git a/pcbnew/router/pns_utils.cpp b/pcbnew/router/pns_utils.cpp index efa2e35ca9..79d4259d5a 100644 --- a/pcbnew/router/pns_utils.cpp +++ b/pcbnew/router/pns_utils.cpp @@ -65,7 +65,7 @@ const SHAPE_LINE_CHAIN OctagonalHull( const VECTOR2I& aP0, const VECTOR2I& aSize const SHAPE_LINE_CHAIN ArcHull( const SHAPE_ARC& aSeg, int aClearance, int aWalkaroundThickness ) { - int d = aSeg.GetWidth() / 2 + aClearance + aWalkaroundThickness / 2 + HULL_MARGIN + int d = aSeg.GetWidth() / 2 + aClearance + aWalkaroundThickness / 2 + SHAPE_ARC::DefaultAccuracyForPCB(); int x = (int) ( 2.0 / ( 1.0 + M_SQRT2 ) * d ) / 2; @@ -144,7 +144,7 @@ const SHAPE_LINE_CHAIN ArcHull( const SHAPE_ARC& aSeg, int aClearance, int aWalk const SHAPE_LINE_CHAIN SegmentHull ( const SHAPE_SEGMENT& aSeg, int aClearance, int aWalkaroundThickness ) { - int cl = aClearance + aWalkaroundThickness / 2 + HULL_MARGIN; + int cl = aClearance + aWalkaroundThickness / 2; int d = aSeg.GetWidth() / 2 + cl; int x = (int)( 2.0 / ( 1.0 + M_SQRT2 ) * d ); @@ -155,7 +155,7 @@ const SHAPE_LINE_CHAIN SegmentHull ( const SHAPE_SEGMENT& aSeg, int aClearance, { return OctagonalHull( a - VECTOR2I( aSeg.GetWidth() / 2, aSeg.GetWidth() / 2 ), VECTOR2I( aSeg.GetWidth(), aSeg.GetWidth() ), - cl + 1, + cl, 2.0 * ( 1.0 - M_SQRT1_2 ) * d ); } @@ -191,7 +191,6 @@ static void MoveDiagonal( SEG& aDiagonal, const SHAPE_LINE_CHAIN& aVertices, int int dist; aVertices.NearestPoint( aDiagonal, dist ); - dist -= HULL_MARGIN; VECTOR2I moveBy = ( aDiagonal.A - aDiagonal.B ).Perpendicular().Resize( dist - aClearance ); aDiagonal.A += moveBy; aDiagonal.B += moveBy; @@ -201,7 +200,7 @@ static void MoveDiagonal( SEG& aDiagonal, const SHAPE_LINE_CHAIN& aVertices, int const SHAPE_LINE_CHAIN ConvexHull( const SHAPE_SIMPLE& aConvex, int aClearance ) { // this defines the horizontal and vertical lines in the hull octagon - BOX2I box = aConvex.BBox( aClearance + HULL_MARGIN ); + BOX2I box = aConvex.BBox( aClearance ); box.Normalize(); SEG topline = SEG( VECTOR2I( box.GetX(), box.GetY() + box.GetHeight() ),