diff --git a/pcbnew/drc/drc_test_provider_silk_clearance.cpp b/pcbnew/drc/drc_test_provider_silk_clearance.cpp index 3cb7089b0f..007cffd484 100644 --- a/pcbnew/drc/drc_test_provider_silk_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_silk_clearance.cpp @@ -173,18 +173,23 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() }; targetTree.QueryCollidingPairs( &silkTree, layerPairs, - [&]( const DRC_RTREE::LAYER_PAIR& aLayers, DRC_RTREE::ITEM_WITH_SHAPE* aRefItem, - DRC_RTREE::ITEM_WITH_SHAPE* aTestItem, bool* aCollisionDetected ) -> bool + [&]( const DRC_RTREE::LAYER_PAIR& aLayers, DRC_RTREE::ITEM_WITH_SHAPE* aRefItemShape, + DRC_RTREE::ITEM_WITH_SHAPE* aTestItemShape, bool* aCollisionDetected ) -> bool { + BOARD_ITEM* aRefItem = aRefItemShape->parent; + SHAPE* aRefShape = aRefItemShape->shape; + BOARD_ITEM* aTestItem = aTestItemShape->parent; + SHAPE* aTestShape = aTestItemShape->shape; + + if( m_drcEngine->IsErrorLimitExceeded( DRCE_OVERLAPPING_SILK ) ) return false; - if( isInvisibleText( aRefItem->parent ) || isInvisibleText( aTestItem->parent ) ) + if( isInvisibleText( aRefItem ) || isInvisibleText( aTestItem ) ) return true; DRC_CONSTRAINT constraint = m_drcEngine->EvalRules( SILK_CLEARANCE_CONSTRAINT, - aRefItem->parent, - aTestItem->parent, + aRefItem, aTestItem, aLayers.second ); if( constraint.IsNull() || constraint.GetSeverity() == RPT_SEVERITY_IGNORE ) @@ -200,19 +205,14 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() // Graphics are often compound shapes so ignore collisions between shapes in a // single footprint or on the board. - PCB_SHAPE* refGraphic = dynamic_cast( aRefItem->parent ); - PCB_SHAPE* testGraphic = dynamic_cast( aTestItem->parent ); - - if( refGraphic && testGraphic ) + if( aRefItem->Type() == PCB_SHAPE_T && aTestItem->Type() == PCB_SHAPE_T ) { - FOOTPRINT *refParentFP = dynamic_cast( refGraphic->GetParent() ); - FOOTPRINT *testParentFP = dynamic_cast( testGraphic->GetParent() ); - - if( refParentFP == testParentFP ) // also true when both are nullptr + // also true when both are nullptr + if( aRefItem->GetParentFootprint() == aTestItem->GetParentFootprint() ) return true; } - if( aRefItem->shape->Collide( aTestItem->shape, minClearance, &actual, &pos ) ) + if( aRefShape->Collide( aTestShape, minClearance, &actual, &pos ) ) { std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_SILK ); @@ -226,7 +226,7 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); } - drcItem->SetItems( aRefItem->parent, aTestItem->parent ); + drcItem->SetItems( aRefItem, aTestItem ); drcItem->SetViolatingRule( constraint.GetParentRule() ); reportViolation( drcItem, pos, aLayers.second ); diff --git a/pcbnew/pcb_shape.cpp b/pcbnew/pcb_shape.cpp index 65c7a84b49..17358f9d21 100644 --- a/pcbnew/pcb_shape.cpp +++ b/pcbnew/pcb_shape.cpp @@ -148,10 +148,7 @@ void PCB_SHAPE::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) FOOTPRINT* PCB_SHAPE::GetParentFootprint() const { - if( !m_parent || m_parent->Type() != PCB_FOOTPRINT_T ) - return nullptr; - - return (FOOTPRINT*) m_parent; + return dynamic_cast( BOARD_ITEM::GetParentFootprint() ); }