Better progress reporting, and don't report necks that don't have items.

Since we aren't searching zones (they aren't in the m_CopperItemRTreeCache)
this will drop all errors that are zone-only (which are better handled by
zone-min-width).
This commit is contained in:
Jeff Young 2022-07-30 23:35:51 +01:00
parent 4bc7c16ce0
commit b0a9cea6f6
1 changed files with 77 additions and 58 deletions

View File

@ -583,6 +583,27 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
DRC_RTREE* tree = board->m_CopperItemRTreeCache.get();
auto calc_effort =
[&]( const std::set<BOARD_ITEM*>& items, PCB_LAYER_ID aLayer ) -> size_t
{
size_t effort = 0;
for( BOARD_ITEM* item : items )
{
if( item->Type() == PCB_ZONE_T )
{
ZONE* zone = static_cast<ZONE*>( item );
effort += zone->GetFilledPolysList( aLayer )->FullPointCount();
}
else
{
effort += 4;
}
}
return effort;
};
auto min_checker =
[&](const std::set<BOARD_ITEM*>& aItems, PCB_LAYER_ID aLayer ) -> size_t
{
@ -611,9 +632,11 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
for( const std::pair<int, int>& pt : ret )
{
VECTOR2I location = ( chain.CPoint( pt.first ) + chain.CPoint( pt.second ) ) / 2;
int dist = ( chain.CPoint( pt.first ) - chain.CPoint( pt.second ) ).EuclideanNorm();
std::set<BOARD_ITEM*> items = tree->GetObjectsAt( location, aLayer, minimum_width );
SEG span( chain.CPoint( pt.first ), chain.CPoint( pt.second ) );
VECTOR2I location = ( span.A + span.B ) / 2;
int dist = ( span.A - span.B ).EuclideanNorm();
std::set<BOARD_ITEM*> items = tree->GetObjectsAt( location, aLayer,
minimum_width );
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CONNECTION_WIDTH );
wxString msg;
@ -630,11 +653,12 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
drce->AddItem( item );
}
if( !drce->GetIDs().empty() )
reportViolation( drce, location, aLayer );
}
}
done.fetch_add( aItems.size() );
done.fetch_add( calc_effort( aItems, aLayer ) );
return 1;
};
@ -643,7 +667,7 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
{
auto& layer_items = net_items[layer];
for( ZONE* zone : board->Zones() )
for( ZONE* zone : board->m_DRCCopperZones )
{
if( !zone->GetIsRuleArea() && zone->IsOnLayer( layer ) )
layer_items[zone->GetNetCode()].emplace( zone );
@ -670,18 +694,14 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
layer_items[pad->GetNetCode()].emplace( pad );
}
for( FP_ZONE* zone : fp->Zones() )
{
if( !zone->GetIsRuleArea() && zone->IsOnLayer( layer ) )
layer_items[zone->GetNetCode()].emplace( zone );
}
// Footprint zones are also in the m_DRCCopperZones cache
}
}
thread_pool& tp = GetKiCadThreadPool();
std::vector<std::future<size_t>> returns;
size_t return_count = 0;
size_t total_count = 0;
size_t total_effort = 0;
for( auto& layer_items : net_items )
return_count += layer_items.second.size();
@ -693,18 +713,17 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
for( const auto& items : layer_items.second )
{
returns.emplace_back( tp.submit( min_checker, items.second, layer_items.first ) );
total_count += items.second.size();
total_effort += calc_effort( items.second, layer_items.first );
}
}
for( auto& retval : returns )
for( std::future<size_t>& retval : returns )
{
std::future_status status;
do
{
m_drcEngine->ReportProgress( static_cast<double>( done ) / total_count );
m_drcEngine->ReportProgress( static_cast<double>( done ) / total_effort );
status = retval.wait_for( std::chrono::milliseconds( 100 ) );
} while( status != std::future_status::ready );
}