Allow negative clearances to signal supression of DRC test.

This commit is contained in:
Jeff Young 2021-01-23 00:09:18 +00:00
parent 0ba0160da9
commit 2d8cac658e
10 changed files with 102 additions and 125 deletions

View File

@ -1082,27 +1082,6 @@ bool DRC_ENGINE::ReportPhase( const wxString& aMessage )
}
#if 0
DRC_CONSTRAINT DRC_ENGINE::GetWorstGlobalConstraint( DRC_CONSTRAINT_T ruleID )
{
DRC_CONSTRAINT rv;
rv.m_Value.SetMin( std::numeric_limits<int>::max() );
rv.m_Value.SetMax( std::numeric_limits<int>::min() );
for( auto rule : QueryRulesById( ruleID ) )
{
auto mm = rule->GetConstraint().m_Value;
if( mm.HasMax() )
rv.m_Value.SetMax( std::max( mm.Max(), rv.m_Value.Max() ) );
if( mm.HasMin() )
rv.m_Value.SetMin( std::min( mm.Min(), rv.m_Value.Min() ) );
}
return rv;
}
#endif
bool DRC_ENGINE::HasRulesForConstraintType( DRC_CONSTRAINT_T constraintID )
{
//drc_dbg(10,"hascorrect id %d size %d\n", ruleID, m_ruleMap[ruleID]->sortedRules.size( ) );

View File

@ -55,6 +55,9 @@ const wxString DRC_TEST_PROVIDER::GetDescription() const { return ""; }
void DRC_TEST_PROVIDER::reportViolation( std::shared_ptr<DRC_ITEM>& item, wxPoint aMarkerPos )
{
if( item->GetViolatingRule() )
accountCheck( item->GetViolatingRule() );
item->SetViolatingTest( this );
m_drcEngine->ReportViolation( item, aMarkerPos );
}

View File

@ -99,8 +99,6 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run()
bool fail_min = false;
bool fail_max = false;
accountCheck( constraint );
if( constraint.Value().HasMin() )
{
v_min = constraint.Value().Min();

View File

@ -273,7 +273,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA
bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
bool testHoles = !m_drcEngine->IsErrorLimitExceeded( DRCE_HOLE_CLEARANCE );
DRC_CONSTRAINT constraint;
int clearance;
int clearance = -1;
int actual;
VECTOR2I pos;
@ -289,9 +289,10 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA
{
constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, track, other, layer );
clearance = constraint.GetValue().Min();
}
accountCheck( constraint );
if( clearance >= 0 )
{
// Special processing for track:track intersections
if( track->Type() == PCB_TRACE_T && other->Type() == PCB_TRACE_T )
{
@ -305,29 +306,32 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA
drcItem->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drcItem, (wxPoint) intersection.get() );
return true;
return m_drcEngine->GetReportAllTrackErrors();
}
}
std::shared_ptr<SHAPE> otherShape = getShape( other, layer );
if( trackShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) )
else
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
std::shared_ptr<SHAPE> otherShape = getShape( other, layer );
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) );
if( trackShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
drce->SetItems( track, other );
drce->SetViolatingRule( constraint.GetParentRule() );
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) );
reportViolation( drce, (wxPoint) pos );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
drce->SetItems( track, other );
drce->SetViolatingRule( constraint.GetParentRule() );
if( !m_drcEngine->GetReportAllTrackErrors() )
return false;
reportViolation( drce, (wxPoint) pos );
if( !m_drcEngine->GetReportAllTrackErrors() )
return false;
}
}
}
@ -356,9 +360,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA
constraint = m_drcEngine->EvalRulesForItems( HOLE_CLEARANCE_CONSTRAINT, other, track );
clearance = constraint.GetValue().Min();
accountCheck( constraint.GetParentRule() );
if( trackShape->Collide( holeShape.get(), clearance - m_drcEpsilon, &actual, &pos ) )
if( clearance >= 0 && trackShape->Collide( holeShape.get(),
std::max( 0, clearance - m_drcEpsilon ),
&actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
@ -372,6 +376,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA
drce->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drce, (wxPoint) pos );
if( !m_drcEngine->GetReportAllTrackErrors() )
return false;
}
}
}
@ -401,7 +408,11 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aItem
{
auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, aItem, zone,
aLayer );
int clearance = constraint.GetValue().Min();
int clearance = constraint.GetValue().Min();
if( clearance < 0 )
continue;
int actual;
VECTOR2I pos;
DRC_RTREE* zoneTree = m_zoneTrees[ zone ].get();
@ -586,10 +597,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
otherPad );
clearance = constraint.GetValue().Min();
accountCheck( constraint.GetParentRule() );
if( padShape->Collide( otherPad->GetEffectiveHoleShape(), clearance - m_drcEpsilon,
&actual, &pos ) )
if( clearance >= 0 && padShape->Collide( otherPad->GetEffectiveHoleShape(),
std::max( 0, clearance - m_drcEpsilon ),
&actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
@ -612,10 +622,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
otherPad );
clearance = constraint.GetValue().Min();
accountCheck( constraint.GetParentRule() );
if( otherShape->Collide( pad->GetEffectiveHoleShape(), clearance - m_drcEpsilon,
&actual, &pos ) )
if( clearance >= 0 && otherShape->Collide( pad->GetEffectiveHoleShape(),
std::max( 0, clearance - m_drcEpsilon ),
&actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
@ -645,9 +654,9 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, pad, other, layer );
clearance = constraint.GetValue().Min();
accountCheck( constraint );
if( padShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) )
if( clearance > 0 && padShape->Collide( otherShape.get(),
std::max( 0, clearance - m_drcEpsilon ),
&actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
@ -787,8 +796,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones()
if( zoneRef->GetPriority() != zoneToTest->GetPriority() )
continue;
// test for different types
if( zoneRef->GetIsRuleArea() != zoneToTest->GetIsRuleArea() )
// rule areas may overlap at will
if( zoneRef->GetIsRuleArea() || zoneToTest->GetIsRuleArea() )
continue;
// Examine a candidate zone: compare zoneToTest to zoneRef
@ -798,13 +807,6 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones()
zoneToTest );
int zone2zoneClearance = constraint.GetValue().Min();
accountCheck( constraint );
// Keepout areas have no clearance, so set zone2zoneClearance to 1
// ( zone2zoneClearance = 0 can create problems in test functions)
if( zoneRef->GetIsRuleArea() ) // fixme: really?
zone2zoneClearance = 1;
// test for some corners of zoneRef inside zoneToTest
for( auto iterator = smoothed_polys[ia].IterateWithHoles(); iterator; iterator++ )
{

View File

@ -170,7 +170,7 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
footprint, test, F_Cu );
clearance = constraint.GetValue().Min();
if( footprintFront.Collide( &testFront, clearance, &actual, &pos ) )
if( clearance >= 0 && footprintFront.Collide( &testFront, clearance, &actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS );
@ -197,7 +197,7 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
footprint, test, B_Cu );
clearance = constraint.GetValue().Min();
if( footprintBack.Collide( &testBack, clearance, &actual, &pos ) )
if( clearance >= 0 && footprintBack.Collide( &testBack, clearance, &actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS );

View File

@ -91,9 +91,7 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge( BOARD_ITEM* item, SHAPE*
int actual;
VECTOR2I pos;
accountCheck( constraint );
if( itemShape->Collide( edgeShape.get(), minClearance, &actual, &pos ) )
if( minClearance >= 0 && itemShape->Collide( edgeShape.get(), minClearance, &actual, &pos ) )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( aErrorCode );

View File

@ -281,9 +281,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::testHoleAgainstHole( BOARD_ITEM* aItem, S
auto constraint = m_drcEngine->EvalRulesForItems( HOLE_TO_HOLE_CONSTRAINT, aItem, aOther );
int minClearance = constraint.GetValue().Min();
accountCheck( constraint.GetParentRule() );
if( actual < minClearance )
if( minClearance >= 0 && actual < minClearance )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE );

View File

@ -134,8 +134,6 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPad( PAD* aPad )
bool fail_max = false;
int constraintValue;
accountCheck( constraint );
if( constraint.Value().HasMin() && holeMinor < constraint.Value().Min() )
{
fail_min = true;
@ -200,8 +198,6 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkVia( VIA* via, bool aExceedMicro, bool aE
bool fail_max = false;
int constraintValue;
accountCheck( constraint );
if( constraint.Value().HasMin() && via->GetDrillValue() < constraint.Value().Min() )
{
fail_min = true;

View File

@ -140,10 +140,7 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
if( m_drcEngine->IsErrorLimitExceeded( DRCE_OVERLAPPING_SILK ) )
return false;
if ( isInvisibleText( aRefItem->parent ) )
return true;
if ( isInvisibleText( aTestItem->parent ) )
if( isInvisibleText( aRefItem->parent ) || isInvisibleText( aTestItem->parent ) )
return true;
auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT,
@ -154,12 +151,14 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
if( constraint.IsNull() )
return true;
int minClearance = constraint.GetValue().Min();
int minClearance = constraint.GetValue().Min();
if( minClearance < 0 )
return true;
int actual;
VECTOR2I pos;
accountCheck( constraint );
// Graphics are often compound shapes so ignore collisions between shapes in a
// single footprint or on the board.
PCB_SHAPE* refGraphic = dynamic_cast<PCB_SHAPE*>( aRefItem->parent );
@ -174,27 +173,28 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
return true;
}
if( !aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) )
return true;
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_SILK );
if( minClearance > 0 )
if( aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) )
{
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetParentRule()->m_Name,
MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_SILK );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
if( minClearance > 0 )
{
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetParentRule()->m_Name,
MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
}
drcItem->SetItems( aRefItem->parent, aTestItem->parent );
drcItem->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drcItem, (wxPoint) pos );
*aCollisionDetected = true;
}
drcItem->SetItems( aRefItem->parent, aTestItem->parent );
drcItem->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drcItem, (wxPoint) pos );
*aCollisionDetected = true;
return true;
};

View File

@ -122,43 +122,46 @@ bool DRC_TEST_PROVIDER_SILK_TO_MASK::Run()
if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_MASK_CLEARANCE ) )
return false;
auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT,
aRefItem->parent,
aTestItem->parent );
int minClearance = constraint.GetValue().Min();
int actual;
VECTOR2I pos;
if( isInvisibleText( aRefItem->parent ) )
return true;
if( isInvisibleText( aTestItem->parent ) )
return true;
accountCheck( constraint );
auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT,
aRefItem->parent,
aTestItem->parent );
if( !aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) )
int minClearance = constraint.GetValue().Min();
if( minClearance < 0 )
return true;
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SILK_MASK_CLEARANCE );
int actual;
VECTOR2I pos;
if( minClearance > 0 )
if( aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) )
{
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) );
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_SILK_MASK_CLEARANCE );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
if( minClearance > 0 )
{
m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg );
}
drce->SetItems( aRefItem->parent, aTestItem->parent );
drce->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drce, (wxPoint) pos );
*aCollisionDetected = true;
}
drcItem->SetItems( aRefItem->parent, aTestItem->parent );
drcItem->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drcItem, (wxPoint) pos );
*aCollisionDetected = true;
return true;
};