Clean up layer handling and normalize to remove magic numbers.

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

(cherry picked from commit 5fe5534822)
This commit is contained in:
Jeff Young 2022-10-25 12:30:25 +01:00
parent a5fd03df88
commit 8c3cd200d1
1 changed files with 8 additions and 5 deletions

View File

@ -251,7 +251,7 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType,
if( parentA )
{
parentA->SetLayer( (PCB_LAYER_ID) aLayer );
parentA->SetLayer( ToLAYER_ID( aLayer ) );
static_cast<BOARD_CONNECTED_ITEM*>( parentA )->SetNetCode( aItemA->Net(), true );
}
}
@ -269,13 +269,13 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType,
if( parentB )
{
parentB->SetLayer( (PCB_LAYER_ID) aLayer );
parentB->SetLayer( ToLAYER_ID( aLayer ) );
static_cast<BOARD_CONNECTED_ITEM*>( parentB )->SetNetCode( aItemB->Net(), true );
}
}
if( parentA )
hostConstraint = drcEngine->EvalRules( hostType, parentA, parentB, (PCB_LAYER_ID) aLayer );
hostConstraint = drcEngine->EvalRules( hostType, parentA, parentB, ToLAYER_ID( aLayer ) );
if( hostConstraint.IsNull() )
return false;
@ -330,6 +330,9 @@ int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* a
else
layers = aA->Layers().Intersection( aB->Layers() );
// Normalize layer range (no -1 magic numbers)
layers = layers.Intersection( LAYER_RANGE( PCBNEW_LAYER_ID_START, GAL_LAYER_ID_END ) );
for( int layer = layers.Start(); layer <= layers.End(); ++layer )
{
if( isCopper( aA ) && ( !aB || isCopper( aB ) ) )
@ -1270,14 +1273,14 @@ bool PNS_KICAD_IFACE::IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) con
{
const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem->Parent() );
return via->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
return via->FlashLayer( ToLAYER_ID( aLayer ) );
}
case PCB_PAD_T:
{
const PAD* pad = static_cast<const PAD*>( aItem->Parent() );
return pad->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
return pad->FlashLayer( ToLAYER_ID( aLayer ) );
}
default: