Don't run DRC rules on non-existant layers.

Fixes https://gitlab.com/kicad/code/kicad/issues/13753
This commit is contained in:
Jeff Young 2023-02-03 13:20:45 +00:00
parent 235925d62c
commit 8ecf64b6c5
2 changed files with 12 additions and 7 deletions

View File

@ -38,6 +38,7 @@ bool DRC_CACHE_GENERATOR::Run()
int& m_largestClearance = m_board->m_DRCMaxClearance; int& m_largestClearance = m_board->m_DRCMaxClearance;
int& m_largestPhysicalClearance = m_board->m_DRCMaxPhysicalClearance; int& m_largestPhysicalClearance = m_board->m_DRCMaxPhysicalClearance;
DRC_CONSTRAINT worstConstraint; DRC_CONSTRAINT worstConstraint;
LSET boardCopperLayers = LSET::AllCuMask( m_board->GetCopperLayerCount() );
if( m_drcEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, worstConstraint ) ) if( m_drcEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, worstConstraint ) )
m_largestClearance = worstConstraint.GetValue().Min(); m_largestClearance = worstConstraint.GetValue().Min();
@ -61,7 +62,7 @@ bool DRC_CACHE_GENERATOR::Run()
{ {
m_board->m_DRCZones.push_back( zone ); m_board->m_DRCZones.push_back( zone );
if( ( zone->GetLayerSet() & LSET::AllCuMask() ).any() ) if( ( zone->GetLayerSet() & boardCopperLayers ).any() )
{ {
m_board->m_DRCCopperZones.push_back( zone ); m_board->m_DRCCopperZones.push_back( zone );
m_largestClearance = std::max( m_largestClearance, zone->GetLocalClearance() ); m_largestClearance = std::max( m_largestClearance, zone->GetLocalClearance() );
@ -82,7 +83,7 @@ bool DRC_CACHE_GENERATOR::Run()
{ {
m_board->m_DRCZones.push_back( zone ); m_board->m_DRCZones.push_back( zone );
if( ( zone->GetLayerSet() & LSET::AllCuMask() ).any() ) if( ( zone->GetLayerSet() & boardCopperLayers ).any() )
{ {
m_board->m_DRCCopperZones.push_back( zone ); m_board->m_DRCCopperZones.push_back( zone );
m_largestClearance = std::max( m_largestClearance, zone->GetLocalClearance() ); m_largestClearance = std::max( m_largestClearance, zone->GetLocalClearance() );
@ -109,7 +110,7 @@ bool DRC_CACHE_GENERATOR::Run()
if( !reportProgress( ii++, count, progressDelta ) ) if( !reportProgress( ii++, count, progressDelta ) )
return false; return false;
LSET layers = item->GetLayerSet(); LSET copperLayers = item->GetLayerSet() & boardCopperLayers;
// Special-case pad holes which pierce all the copper layers // Special-case pad holes which pierce all the copper layers
if( item->Type() == PCB_PAD_T ) if( item->Type() == PCB_PAD_T )
@ -117,10 +118,10 @@ bool DRC_CACHE_GENERATOR::Run()
PAD* pad = static_cast<PAD*>( item ); PAD* pad = static_cast<PAD*>( item );
if( pad->HasHole() ) if( pad->HasHole() )
layers |= LSET::AllCuMask(); copperLayers = boardCopperLayers;
} }
for( PCB_LAYER_ID layer : layers.Seq() ) for( PCB_LAYER_ID layer : copperLayers.Seq() )
{ {
if( IsCopperLayer( layer ) ) if( IsCopperLayer( layer ) )
m_board->m_CopperItemRTreeCache->Insert( item, layer, m_largestClearance ); m_board->m_CopperItemRTreeCache->Insert( item, layer, m_largestClearance );

View File

@ -442,12 +442,14 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances()
std::map<BOARD_ITEM*, int> freePadsUsageMap; std::map<BOARD_ITEM*, int> freePadsUsageMap;
std::unordered_map<PTR_PTR_CACHE_KEY, layers_checked> checkedPairs; std::unordered_map<PTR_PTR_CACHE_KEY, layers_checked> checkedPairs;
LSET boardCopperLayers = LSET::AllCuMask( m_board->GetCopperLayerCount() );
for( PCB_TRACK* track : m_board->Tracks() ) for( PCB_TRACK* track : m_board->Tracks() )
{ {
if( !reportProgress( ii++, m_board->Tracks().size(), progressDelta ) ) if( !reportProgress( ii++, m_board->Tracks().size(), progressDelta ) )
break; break;
for( PCB_LAYER_ID layer : LSET( track->GetLayerSet() & LSET::AllCuMask() ).Seq() ) for( PCB_LAYER_ID layer : LSET( track->GetLayerSet() & boardCopperLayers ).Seq() )
{ {
std::shared_ptr<SHAPE> trackShape = track->GetEffectiveShape( layer ); std::shared_ptr<SHAPE> trackShape = track->GetEffectiveShape( layer );
@ -765,11 +767,13 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances( )
std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs; std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
LSET boardCopperLayers = LSET::AllCuMask( m_board->GetCopperLayerCount() );
for( FOOTPRINT* footprint : m_board->Footprints() ) for( FOOTPRINT* footprint : m_board->Footprints() )
{ {
for( PAD* pad : footprint->Pads() ) for( PAD* pad : footprint->Pads() )
{ {
for( PCB_LAYER_ID layer : pad->GetLayerSet().Seq() ) for( PCB_LAYER_ID layer : LSET( pad->GetLayerSet() & boardCopperLayers ).Seq() )
{ {
std::shared_ptr<SHAPE> padShape = pad->GetEffectiveShape( layer ); std::shared_ptr<SHAPE> padShape = pad->GetEffectiveShape( layer );