Threading additional 3d transform
Transforming solid areas to polygons can be time-intensive for some boards. This threads the transformation to all simultaneous builds in different layers
This commit is contained in:
parent
7869ac7e67
commit
3e815882c1
|
@ -686,19 +686,24 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
|
|||
if( aStatusReporter )
|
||||
aStatusReporter->Report( _( "Create zones" ) );
|
||||
|
||||
std::vector<std::pair<const ZONE*, PCB_LAYER_ID>> zones;
|
||||
std::vector<std::pair<ZONE*, PCB_LAYER_ID>> zones;
|
||||
std::unordered_map<PCB_LAYER_ID, std::unique_ptr<std::mutex>> layer_lock;
|
||||
|
||||
for( ZONE* zone : m_board->Zones() )
|
||||
{
|
||||
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
||||
{
|
||||
zones.emplace_back( std::make_pair( zone, layer ) );
|
||||
layer_lock.emplace( layer, std::make_unique<std::mutex>() );
|
||||
}
|
||||
}
|
||||
|
||||
// Add zones objects
|
||||
std::atomic<size_t> nextZone( 0 );
|
||||
std::atomic<size_t> threadsFinished( 0 );
|
||||
|
||||
size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
|
||||
size_t parallelThreadCount = std::min<size_t>( zones.size(),
|
||||
std::max<size_t>( std::thread::hardware_concurrency(), 2 ) );
|
||||
|
||||
for( size_t ii = 0; ii < parallelThreadCount; ++ii )
|
||||
{
|
||||
|
@ -708,7 +713,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
|
|||
areaId < zones.size();
|
||||
areaId = nextZone.fetch_add( 1 ) )
|
||||
{
|
||||
const ZONE* zone = zones[areaId].first;
|
||||
ZONE* zone = zones[areaId].first;
|
||||
|
||||
if( zone == nullptr )
|
||||
break;
|
||||
|
@ -716,9 +721,22 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
|
|||
PCB_LAYER_ID layer = zones[areaId].second;
|
||||
|
||||
auto layerContainer = m_layerMap.find( layer );
|
||||
auto layerPolyContainer = m_layers_poly.find( layer );
|
||||
|
||||
if( layerContainer != m_layerMap.end() )
|
||||
{
|
||||
addSolidAreasShapes( zone, layerContainer->second, layer );
|
||||
}
|
||||
|
||||
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
|
||||
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY )
|
||||
&& layerPolyContainer != m_layers_poly.end() )
|
||||
{
|
||||
auto mut_it = layer_lock.find( layer );
|
||||
|
||||
std::lock_guard< std::mutex > lock( *( mut_it->second ) );
|
||||
zone->TransformSolidAreasShapesToPolygon( layer, *layerPolyContainer->second );
|
||||
}
|
||||
}
|
||||
|
||||
threadsFinished++;
|
||||
|
@ -732,25 +750,6 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
|
|||
|
||||
}
|
||||
|
||||
if( GetFlag( FL_ZONE ) && GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
|
||||
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY ) )
|
||||
{
|
||||
// Add copper zones
|
||||
for( ZONE* zone : m_board->Zones() )
|
||||
{
|
||||
if( zone == nullptr )
|
||||
break;
|
||||
|
||||
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
||||
{
|
||||
auto layerContainer = m_layers_poly.find( layer );
|
||||
|
||||
if( layerContainer != m_layers_poly.end() )
|
||||
zone->TransformSolidAreasShapesToPolygon( layer, *layerContainer->second );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simplify layer polygons
|
||||
|
||||
if( aStatusReporter )
|
||||
|
|
Loading…
Reference in New Issue