|
|
|
@ -45,6 +45,7 @@ |
|
|
|
#include <geometry/shape_file_io.h>
|
|
|
|
#include <geometry/convex_hull.h>
|
|
|
|
#include <geometry/geometry_utils.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
|
|
|
|
#include "zone_filler.h"
|
|
|
|
|
|
|
|
@ -75,12 +76,12 @@ ZONE_FILLER::~ZONE_FILLER() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ZONE_FILLER::SetProgressReporter( PROGRESS_REPORTER* aReporter ) |
|
|
|
void ZONE_FILLER::SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ) |
|
|
|
{ |
|
|
|
m_progressReporter = aReporter; |
|
|
|
} |
|
|
|
|
|
|
|
void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones ) |
|
|
|
void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck ) |
|
|
|
{ |
|
|
|
int parallelThreadCount = std::max( ( int )std::thread::hardware_concurrency(), 2 ); |
|
|
|
|
|
|
|
@ -90,9 +91,6 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones ) |
|
|
|
if( !connectivity->TryLock() ) |
|
|
|
return; |
|
|
|
|
|
|
|
// Remove segment zones
|
|
|
|
m_board->m_Zone.DeleteAll(); |
|
|
|
|
|
|
|
for( auto zone : aZones ) |
|
|
|
{ |
|
|
|
// Keepout zones are not filled
|
|
|
|
@ -114,28 +112,32 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones ) |
|
|
|
|
|
|
|
if( m_progressReporter ) |
|
|
|
{ |
|
|
|
m_progressReporter->Report( _( "Calculating zone fills..." ) ); |
|
|
|
m_progressReporter->Report( _( "Checking zone fills..." ) ); |
|
|
|
m_progressReporter->SetMaxProgress( toFill.size() ); |
|
|
|
} |
|
|
|
|
|
|
|
m_next = 0; |
|
|
|
m_out_of_date = false; |
|
|
|
m_count_done = 0; |
|
|
|
std::vector<std::thread> fillWorkers; |
|
|
|
|
|
|
|
for( ssize_t ii = 0; ii < parallelThreadCount; ++ii ) |
|
|
|
{ |
|
|
|
fillWorkers.push_back( std::thread( [ this, toFill ]() |
|
|
|
fillWorkers.push_back( std::thread( [ this, aCheck, toFill ]() |
|
|
|
{ |
|
|
|
size_t i = m_next.fetch_add( 1 ); |
|
|
|
while( i < toFill.size() ) |
|
|
|
{ |
|
|
|
SHAPE_POLY_SET rawPolys, finalPolys; |
|
|
|
ZONE_SEGMENT_FILL segFill; |
|
|
|
fillSingleZone( toFill[i].m_zone, rawPolys, finalPolys ); |
|
|
|
ZONE_CONTAINER* zone = toFill[i].m_zone; |
|
|
|
fillSingleZone( zone, rawPolys, finalPolys ); |
|
|
|
|
|
|
|
toFill[i].m_zone->SetRawPolysList( rawPolys ); |
|
|
|
toFill[i].m_zone->SetFilledPolysList( finalPolys ); |
|
|
|
toFill[i].m_zone->SetIsFilled( true ); |
|
|
|
if( aCheck && zone->GetFilledPolysList().GetHash() != finalPolys.GetHash() ) |
|
|
|
m_out_of_date.store( true ); |
|
|
|
|
|
|
|
zone->SetRawPolysList( rawPolys ); |
|
|
|
zone->SetFilledPolysList( finalPolys ); |
|
|
|
zone->SetIsFilled( true ); |
|
|
|
|
|
|
|
if( m_progressReporter ) |
|
|
|
m_progressReporter->AdvanceProgress(); |
|
|
|
@ -181,10 +183,36 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones ) |
|
|
|
zone.m_zone->SetFilledPolysList( poly ); |
|
|
|
} |
|
|
|
|
|
|
|
if( aCheck && m_out_of_date ) |
|
|
|
{ |
|
|
|
bool cancel = !IsOK( nullptr, _( "Zone fills may be out-of-date. Re-fill all zones?" ) ); |
|
|
|
|
|
|
|
if( m_progressReporter ) |
|
|
|
{ |
|
|
|
// Sigh. Patch another case of "fall behind" dialogs on Mac.
|
|
|
|
if( m_progressReporter->GetParent() ) |
|
|
|
m_progressReporter->GetParent()->Raise(); |
|
|
|
m_progressReporter->Raise(); |
|
|
|
} |
|
|
|
|
|
|
|
if( cancel ) |
|
|
|
{ |
|
|
|
if( m_commit ) |
|
|
|
m_commit->Revert(); |
|
|
|
|
|
|
|
connectivity->SetProgressReporter( nullptr ); |
|
|
|
connectivity->Unlock(); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Remove segment zones
|
|
|
|
m_board->m_Zone.DeleteAll(); |
|
|
|
|
|
|
|
if( m_progressReporter ) |
|
|
|
{ |
|
|
|
m_progressReporter->AdvancePhase(); |
|
|
|
m_progressReporter->Report( _( "Caching polygon triangulations..." ) ); |
|
|
|
m_progressReporter->Report( _( "Performing polygon fills..." ) ); |
|
|
|
m_progressReporter->SetMaxProgress( toFill.size() ); |
|
|
|
} |
|
|
|
|
|
|
|
@ -236,7 +264,7 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones ) |
|
|
|
if( m_progressReporter ) |
|
|
|
{ |
|
|
|
m_progressReporter->AdvancePhase(); |
|
|
|
m_progressReporter->Report( _( "Fill with segments..." ) ); |
|
|
|
m_progressReporter->Report( _( "Performing segment fills..." ) ); |
|
|
|
m_progressReporter->SetMaxProgress( zones_to_fill_count ); |
|
|
|
} |
|
|
|
|
|
|
|
|