Zone Fill performance enhancement
Don't wait until all zones are filled before tesselating fills. Tesselation happens on a layer-by-layer basis, so once the zones' layers are filled, we can tesselate them in parallel with the remaining fill work
This commit is contained in:
parent
0295090135
commit
9b4eb91f12
|
@ -264,24 +264,37 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
auto tesselate_lambda =
|
||||||
|
[&]( std::pair<ZONE*, PCB_LAYER_ID> aFillItem ) -> int
|
||||||
|
{
|
||||||
|
PCB_LAYER_ID layer = aFillItem.second;
|
||||||
|
ZONE* zone = aFillItem.first;
|
||||||
|
|
||||||
|
zone->CacheTriangulation( layer );
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
// Calculate the copper fills (NB: this is multi-threaded)
|
// Calculate the copper fills (NB: this is multi-threaded)
|
||||||
//
|
//
|
||||||
std::vector<std::pair<std::future<int>, bool>> returns;
|
std::vector<std::pair<std::future<int>, int>> returns;
|
||||||
returns.reserve( toFill.size() );
|
returns.reserve( toFill.size() );
|
||||||
size_t finished = 0;
|
size_t finished = 0;
|
||||||
|
|
||||||
|
|
||||||
thread_pool& tp = GetKiCadThreadPool();
|
thread_pool& tp = GetKiCadThreadPool();
|
||||||
|
|
||||||
for( const std::pair<ZONE*, PCB_LAYER_ID>& fillItem : toFill )
|
for( const std::pair<ZONE*, PCB_LAYER_ID>& fillItem : toFill )
|
||||||
returns.emplace_back( std::make_pair( tp.submit( fill_lambda, fillItem ), false ) );
|
returns.emplace_back( std::make_pair( tp.submit( fill_lambda, fillItem ), 0 ) );
|
||||||
|
|
||||||
while( finished != toFill.size() )
|
while( finished != 2 * toFill.size() )
|
||||||
{
|
{
|
||||||
for( size_t ii = 0; ii < returns.size(); ++ii )
|
for( size_t ii = 0; ii < returns.size(); ++ii )
|
||||||
{
|
{
|
||||||
auto& ret = returns[ii];
|
auto& ret = returns[ii];
|
||||||
|
|
||||||
if( ret.second )
|
if( ret.second > 1 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::future_status status = ret.first.wait_for( std::chrono::seconds( 0 ) );
|
std::future_status status = ret.first.wait_for( std::chrono::seconds( 0 ) );
|
||||||
|
@ -291,7 +304,11 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
|
||||||
if( ret.first.get() )
|
if( ret.first.get() )
|
||||||
{
|
{
|
||||||
++finished;
|
++finished;
|
||||||
ret.second = true;
|
|
||||||
|
if( ret.second == 0 )
|
||||||
|
returns[ii].first = tp.submit( tesselate_lambda, toFill[ii] );
|
||||||
|
|
||||||
|
ret.second++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -312,10 +329,6 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Triangulate the copper fills (NB: this is multi-threaded)
|
|
||||||
//
|
|
||||||
m_board->CacheTriangulation( m_progressReporter, aZones );
|
|
||||||
|
|
||||||
// Now update the connectivity to check for isolated copper islands
|
// Now update the connectivity to check for isolated copper islands
|
||||||
// (NB: FindIsolatedCopperIslands() is multi-threaded)
|
// (NB: FindIsolatedCopperIslands() is multi-threaded)
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue