Clean up layer handling and normalize to remove magic numbers.

Fixes https://gitlab.com/kicad/code/kicad/issues/12747
This commit is contained in:
Jeff Young 2022-10-25 12:30:25 +01:00
parent f480cbf93f
commit 5fe5534822
1 changed files with 8 additions and 5 deletions

View File

@ -309,7 +309,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 );
}
}
@ -327,13 +327,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;
@ -399,6 +399,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 ) ) )
@ -1290,14 +1293,14 @@ bool PNS_KICAD_IFACE_BASE::IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer
{
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: