Fix faulty copper-checking logic.

Fixes https://gitlab.com/kicad/code/kicad/issues/5978
This commit is contained in:
Jeff Young 2020-10-13 16:31:36 +01:00
parent 147d58728f
commit 3fc1a0c314
1 changed files with 58 additions and 61 deletions

View File

@ -80,9 +80,9 @@ private:
* @param aSortedPadsList is the sorted by X pos of all pads
* @param aRefPadIdx is the index of pad to test inside aSortedPadsList
* @param aX_limit is the max X pos of others pads that need to be tested
* To speed up the test, aSortedPadsList is a pad list sorted by X position,
* and only pads after the pad to test are tested, so this function must be called
* for each pad for the first in list to the last in list
* To speed up the test, aSortedPadsList is a pad list sorted by X position, and only pads
* after the pad to test are tested, so this function must be called for each pad for the
* first in list to the last in list
*/
bool doPadToPadHoleDrc( int aRefPadIdx, std::vector<D_PAD*>& aSortedPadsList, int aX_limit );
@ -171,6 +171,7 @@ void DRC_TEST_PROVIDER_HOLE_CLEARANCE::buildDrilledHoleList()
reportAux( "Total drilled holes : %d", m_drilledHoles.size());
}
void DRC_TEST_PROVIDER_HOLE_CLEARANCE::testPads2Holes()
{
const int delta = 25; // This is the number of tests between 2 calls to the progress bar
@ -238,15 +239,10 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::doPadToPadHoleDrc( int aRefPadIdx,
drc_dbg( 10, " chk1 against -> %p x0 %d x2 %d\n",
pad, pad->GetDrillSize().x, refPad->GetDrillSize().x );
// Since a hole pierces all layers we have to test pads which are on any copper layer.
// Pads just on technical layers are not an issue.
if( ( pad->GetLayerSet() & all_cu ) != 0 || ( refPad->GetLayerSet() & all_cu ) != 0 )
if( pad->GetDrillSize().x && ( refPad->GetLayerSet() & all_cu ).any() )
{
drc_dbg( 10, " chk3 against -> %p x0 %d x2 %d\n", pad, pad->GetDrillSize().x,
refPad->GetDrillSize().x );
// pad has a hole and refPad is on copper
if( pad->GetDrillSize().x ) // test pad has a hole
{
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE,
refPad, pad );
int minClearance = constraint.GetValue().Min();
@ -278,8 +274,10 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::doPadToPadHoleDrc( int aRefPadIdx,
}
}
if( refPad->GetDrillSize().x ) // reference pad has a hole
if( refPad->GetDrillSize().x && ( pad->GetLayerSet() & all_cu ).any() )
{
// refPad has a hole and pad is on copper
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE,
refPad, pad );
int minClearance = constraint.GetValue().Min();
@ -310,7 +308,6 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::doPadToPadHoleDrc( int aRefPadIdx,
}
}
}
}
return true;
}