From 1d196720547a57820f28cec2956ffc2881cca88b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 8 Apr 2023 23:25:53 +0100 Subject: [PATCH] Handle more pad shapes when building diffpair gateways. Fixes https://gitlab.com/kicad/code/kicad/issues/1883 --- pcbnew/router/pns_diff_pair.cpp | 25 +++++++++++++++++++++++-- pcbnew/router/pns_solid.cpp | 4 +--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp index 641d5c5cd0..d6ad91b050 100644 --- a/pcbnew/router/pns_diff_pair.cpp +++ b/pcbnew/router/pns_diff_pair.cpp @@ -460,6 +460,10 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a switch( shP->Type() ) { + case SH_CIRCLE: + BuildGeneric ( p0_p, p0_n, true ); + return; + case SH_RECT: { int w = static_cast( shP )->GetWidth(); @@ -483,9 +487,26 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a break; } + case SH_SIMPLE: + case SH_COMPOUND: + { + BOX2I bbox = shP->BBox(); + int w = bbox.GetWidth(); + int h = bbox.GetHeight(); + + if( w < h ) + std::swap( w, h ); + + orthoFanDistance = ( w + 1 )* 3 / 2; + diagFanDistance = ( w - h ); + break; + } + default: - BuildGeneric ( p0_p, p0_n, true ); - return; + wxFAIL_MSG( wxString::Format( wxT( "Unsupported starting primitive: %d (%s)." ), + shP->Type(), + SHAPE_TYPE_asString( shP->Type() ) ) ); + break; } if( checkDiagonalAlignment( p0_p, p0_n ) ) diff --git a/pcbnew/router/pns_solid.cpp b/pcbnew/router/pns_solid.cpp index 2441a0c71d..1ea9a6d7b0 100644 --- a/pcbnew/router/pns_solid.cpp +++ b/pcbnew/router/pns_solid.cpp @@ -78,17 +78,15 @@ static const SHAPE_LINE_CHAIN buildHullForPrimitiveShape( const SHAPE* aShape, i case SH_SIMPLE: { const SHAPE_SIMPLE* convex = static_cast( aShape ); - return ConvexHull( *convex, cl ); } + default: - { wxFAIL_MSG( wxString::Format( wxT( "Unsupported hull shape: %d (%s)." ), aShape->Type(), SHAPE_TYPE_asString( aShape->Type() ) ) ); break; } - } return SHAPE_LINE_CHAIN(); }