Handle more pad shapes when building diffpair gateways.

Fixes https://gitlab.com/kicad/code/kicad/issues/1883

(cherry picked from commit 1d19672054)
This commit is contained in:
Jeff Young 2023-04-08 23:25:53 +01:00
parent cbff011e3c
commit 03c3393616
2 changed files with 24 additions and 5 deletions

View File

@ -459,6 +459,10 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a
switch( shP->Type() ) switch( shP->Type() )
{ {
case SH_CIRCLE:
BuildGeneric ( p0_p, p0_n, true );
return;
case SH_RECT: case SH_RECT:
{ {
int w = static_cast<const SHAPE_RECT*>( shP )->GetWidth(); int w = static_cast<const SHAPE_RECT*>( shP )->GetWidth();
@ -482,9 +486,26 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a
break; 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: default:
BuildGeneric ( p0_p, p0_n, true ); wxFAIL_MSG( wxString::Format( wxT( "Unsupported starting primitive: %d (%s)." ),
return; shP->Type(),
SHAPE_TYPE_asString( shP->Type() ) ) );
break;
} }
if( checkDiagonalAlignment( p0_p, p0_n ) ) if( checkDiagonalAlignment( p0_p, p0_n ) )

View File

@ -78,17 +78,15 @@ static const SHAPE_LINE_CHAIN buildHullForPrimitiveShape( const SHAPE* aShape, i
case SH_SIMPLE: case SH_SIMPLE:
{ {
const SHAPE_SIMPLE* convex = static_cast<const SHAPE_SIMPLE*>( aShape ); const SHAPE_SIMPLE* convex = static_cast<const SHAPE_SIMPLE*>( aShape );
return ConvexHull( *convex, cl ); return ConvexHull( *convex, cl );
} }
default: default:
{
wxFAIL_MSG( wxString::Format( wxT( "Unsupported hull shape: %d (%s)." ), wxFAIL_MSG( wxString::Format( wxT( "Unsupported hull shape: %d (%s)." ),
aShape->Type(), aShape->Type(),
SHAPE_TYPE_asString( aShape->Type() ) ) ); SHAPE_TYPE_asString( aShape->Type() ) ) );
break; break;
} }
}
return SHAPE_LINE_CHAIN(); return SHAPE_LINE_CHAIN();
} }