Performance: better sharing of zone fills.
This commit is contained in:
parent
d8c4f2cb09
commit
2172810600
|
@ -644,7 +644,7 @@ void BOARD_ADAPTER::addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* a
|
|||
PCB_LAYER_ID aLayerId )
|
||||
{
|
||||
// Copy the polys list because we have to simplify it
|
||||
SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZone->GetFilledPolysList( aLayerId ) );
|
||||
SHAPE_POLY_SET polyList = SHAPE_POLY_SET( *aZone->GetFilledPolysList( aLayerId ) );
|
||||
|
||||
// This convert the poly in outline and holes
|
||||
ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aZone );
|
||||
|
|
|
@ -592,7 +592,7 @@ void CN_CONNECTIVITY_ALGO::PropagateNets( BOARD_COMMIT* aCommit, PROPAGATE_MODE
|
|||
void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE* aZone, PCB_LAYER_ID aLayer,
|
||||
std::vector<int>& aIslands )
|
||||
{
|
||||
if( aZone->GetFilledPolysList( aLayer ).IsEmpty() )
|
||||
if( aZone->GetFilledPolysList( aLayer )->IsEmpty() )
|
||||
return;
|
||||
|
||||
aIslands.clear();
|
||||
|
@ -644,7 +644,7 @@ void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( std::vector<CN_ZONE_ISOLAT
|
|||
{
|
||||
for( PCB_LAYER_ID layer : zone.m_zone->GetLayerSet().Seq() )
|
||||
{
|
||||
if( zone.m_zone->GetFilledPolysList( layer ).IsEmpty() )
|
||||
if( zone.m_zone->GetFilledPolysList( layer )->IsEmpty() )
|
||||
continue;
|
||||
|
||||
for( const std::shared_ptr<CN_CLUSTER>& cluster : m_connClusters )
|
||||
|
@ -732,7 +732,7 @@ void CN_VISITOR::checkZoneZoneConnection( CN_ZONE_LAYER* aZoneLayerA, CN_ZONE_LA
|
|||
return;
|
||||
|
||||
const SHAPE_LINE_CHAIN& outline =
|
||||
zoneA->GetFilledPolysList( layer ).COutline( aZoneLayerA->SubpolyIndex() );
|
||||
zoneA->GetFilledPolysList( layer )->COutline( aZoneLayerA->SubpolyIndex() );
|
||||
|
||||
for( int i = 0; i < outline.PointCount(); i++ )
|
||||
{
|
||||
|
@ -748,7 +748,7 @@ void CN_VISITOR::checkZoneZoneConnection( CN_ZONE_LAYER* aZoneLayerA, CN_ZONE_LA
|
|||
}
|
||||
|
||||
const SHAPE_LINE_CHAIN& outline2 =
|
||||
zoneB->GetFilledPolysList( layer ).COutline( aZoneLayerB->SubpolyIndex() );
|
||||
zoneB->GetFilledPolysList( layer )->COutline( aZoneLayerB->SubpolyIndex() );
|
||||
|
||||
for( int i = 0; i < outline2.PointCount(); i++ )
|
||||
{
|
||||
|
|
|
@ -93,7 +93,7 @@ int CN_ZONE_LAYER::AnchorCount() const
|
|||
return 0;
|
||||
|
||||
const ZONE* zone = static_cast<const ZONE*>( Parent() );
|
||||
const SHAPE_LINE_CHAIN& outline = zone->GetFilledPolysList( m_layer ).COutline( m_subpolyIndex );
|
||||
const SHAPE_LINE_CHAIN& outline = zone->GetFilledPolysList( m_layer )->COutline( m_subpolyIndex );
|
||||
|
||||
return outline.PointCount() ? 1 : 0;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ const VECTOR2I CN_ZONE_LAYER::GetAnchor( int n ) const
|
|||
return VECTOR2I();
|
||||
|
||||
const ZONE* zone = static_cast<const ZONE*>( Parent() );
|
||||
const SHAPE_LINE_CHAIN& outline = zone->GetFilledPolysList( m_layer ).COutline( m_subpolyIndex );
|
||||
const SHAPE_LINE_CHAIN& outline = zone->GetFilledPolysList( m_layer )->COutline( m_subpolyIndex );
|
||||
|
||||
return outline.CPoint( 0 );
|
||||
}
|
||||
|
@ -199,14 +199,14 @@ CN_ITEM* CN_LIST::Add( PCB_ARC* aArc )
|
|||
|
||||
const std::vector<CN_ITEM*> CN_LIST::Add( ZONE* zone, PCB_LAYER_ID aLayer )
|
||||
{
|
||||
const auto& polys = zone->GetFilledPolysList( aLayer );
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& polys = zone->GetFilledPolysList( aLayer );
|
||||
|
||||
std::vector<CN_ITEM*> rv;
|
||||
|
||||
for( int j = 0; j < polys.OutlineCount(); j++ )
|
||||
for( int j = 0; j < polys->OutlineCount(); j++ )
|
||||
{
|
||||
CN_ZONE_LAYER* zitem = new CN_ZONE_LAYER( zone, aLayer, false, j );
|
||||
const SHAPE_LINE_CHAIN& outline = zone->GetFilledPolysList( aLayer ).COutline( j );
|
||||
const SHAPE_LINE_CHAIN& outline = zone->GetFilledPolysList( aLayer )->COutline( j );
|
||||
|
||||
for( int k = 0; k < outline.PointCount(); k++ )
|
||||
zitem->AddAnchor( outline.CPoint( k ) );
|
||||
|
|
|
@ -290,13 +290,11 @@ public:
|
|||
m_subpolyIndex( aSubpolyIndex ),
|
||||
m_layer( aLayer )
|
||||
{
|
||||
const SHAPE_POLY_SET& fill = aParent->GetFilledPolysList( aLayer );
|
||||
m_triangulatedPoly = aParent->GetFilledPolysList( aLayer );
|
||||
|
||||
m_triangulatedPoly = fill;
|
||||
|
||||
for( unsigned int ii = 0; ii < m_triangulatedPoly.TriangulatedPolyCount(); ++ii )
|
||||
for( unsigned int ii = 0; ii < m_triangulatedPoly->TriangulatedPolyCount(); ++ii )
|
||||
{
|
||||
const auto* triangleSet = m_triangulatedPoly.TriangulatedPolygon( ii );
|
||||
const auto* triangleSet = m_triangulatedPoly->TriangulatedPolygon( ii );
|
||||
|
||||
if( triangleSet->GetSourceOutlineIndex() != aSubpolyIndex )
|
||||
continue;
|
||||
|
@ -373,7 +371,7 @@ private:
|
|||
std::vector<VECTOR2I> m_testOutlinePoints;
|
||||
int m_subpolyIndex;
|
||||
PCB_LAYER_ID m_layer;
|
||||
SHAPE_POLY_SET m_triangulatedPoly;
|
||||
std::shared_ptr<SHAPE_POLY_SET> m_triangulatedPoly;
|
||||
RTree<const SHAPE*, int, 2, double> m_rTree;
|
||||
};
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ void DRC_TEST_PROVIDER_MECHANICAL_CLEARANCE::testZoneLayer( ZONE* aZone, PCB_LAY
|
|||
{
|
||||
int epsilon = m_board->GetDesignSettings().GetDRCEpsilon();
|
||||
int clearance = aConstraint.GetValue().Min();
|
||||
SHAPE_POLY_SET fill = aZone->GetFilledPolysList( aLayer );
|
||||
SHAPE_POLY_SET fill = *aZone->GetFilledPolysList( aLayer );
|
||||
|
||||
if( aConstraint.GetSeverity() == RPT_SEVERITY_IGNORE || clearance - epsilon <= 0 )
|
||||
return;
|
||||
|
|
|
@ -115,7 +115,7 @@ bool DRC_TEST_PROVIDER_SLIVER_CHECKER::Run()
|
|||
{
|
||||
ZONE* zone = static_cast<ZONE*>( item );
|
||||
|
||||
poly.BooleanAdd( zone->GetFilledPolysList( layer ),
|
||||
poly.BooleanAdd( *zone->GetFilledPolysList( layer ),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -117,7 +117,7 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::addItemToRTrees( BOARD_ITEM* item )
|
|||
{
|
||||
if( zone->IsOnLayer( layer ) )
|
||||
{
|
||||
solderMask->GetFill( layer )->BooleanAdd( zone->GetFilledPolysList( layer ),
|
||||
solderMask->GetFill( layer )->BooleanAdd( *zone->GetFilledPolysList( layer ),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ bool DRC_TEST_PROVIDER_ZONE_CONNECTIONS::Run()
|
|||
|
||||
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
||||
{
|
||||
const SHAPE_POLY_SET& zoneFill = zone->GetFilledPolysList( layer );
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& zoneFill = zone->GetFilledPolysList( layer );
|
||||
|
||||
for( FOOTPRINT* footprint : board->Footprints() )
|
||||
{
|
||||
|
@ -142,8 +142,8 @@ bool DRC_TEST_PROVIDER_ZONE_CONNECTIONS::Run()
|
|||
std::vector<SHAPE_LINE_CHAIN::INTERSECTION> intersections;
|
||||
int spokes = 0;
|
||||
|
||||
for( int jj = 0; jj < zoneFill.OutlineCount(); ++jj )
|
||||
padOutline.Intersect( zoneFill.Outline( jj ), intersections, true );
|
||||
for( int jj = 0; jj < zoneFill->OutlineCount(); ++jj )
|
||||
padOutline.Intersect( zoneFill->Outline( jj ), intersections, true );
|
||||
|
||||
spokes += intersections.size() / 2;
|
||||
|
||||
|
@ -157,12 +157,12 @@ bool DRC_TEST_PROVIDER_ZONE_CONNECTIONS::Run()
|
|||
{
|
||||
if( padOutline.PointInside( track->GetStart() ) )
|
||||
{
|
||||
if( zone->GetFilledPolysList( layer ).Collide( track->GetEnd() ) )
|
||||
if( zone->GetFilledPolysList( layer )->Collide( track->GetEnd() ) )
|
||||
spokes++;
|
||||
}
|
||||
else if( padOutline.PointInside( track->GetEnd() ) )
|
||||
{
|
||||
if( zone->GetFilledPolysList( layer ).Collide( track->GetStart() ) )
|
||||
if( zone->GetFilledPolysList( layer )->Collide( track->GetStart() ) )
|
||||
spokes++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -485,7 +485,7 @@ bool HYPERLYNX_EXPORTER::writeNetObjects( const std::vector<BOARD_ITEM*>& aObjec
|
|||
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
||||
{
|
||||
const wxString layerName = m_board->GetLayerName( layer );
|
||||
SHAPE_POLY_SET filledShape = zone->GetFilledPolysList( layer );
|
||||
SHAPE_POLY_SET filledShape = *zone->GetFilledPolysList( layer );
|
||||
|
||||
filledShape.Simplify( SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
|
|
|
@ -894,7 +894,7 @@ SHAPE_POLY_SET FOOTPRINT::GetBoundingHull() const
|
|||
{
|
||||
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
||||
{
|
||||
SHAPE_POLY_SET layerPoly = zone->GetFilledPolysList( layer );
|
||||
SHAPE_POLY_SET layerPoly = *zone->GetFilledPolysList( layer );
|
||||
|
||||
for( int ii = 0; ii < layerPoly.OutlineCount(); ii++ )
|
||||
{
|
||||
|
|
|
@ -1916,9 +1916,9 @@ void PCB_PAINTER::draw( const ZONE* aZone, int aLayer )
|
|||
|| displayMode == ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS
|
||||
|| displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION )
|
||||
{
|
||||
const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer );
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& polySet = aZone->GetFilledPolysList( layer );
|
||||
|
||||
if( polySet.OutlineCount() == 0 ) // Nothing to draw
|
||||
if( polySet->OutlineCount() == 0 ) // Nothing to draw
|
||||
return;
|
||||
|
||||
m_gal->SetStrokeColor( color );
|
||||
|
@ -1936,7 +1936,7 @@ void PCB_PAINTER::draw( const ZONE* aZone, int aLayer )
|
|||
m_gal->SetIsStroke( true );
|
||||
}
|
||||
|
||||
m_gal->DrawPolygon( polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION );
|
||||
m_gal->DrawPolygon( *polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -608,7 +608,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
|
|||
if( !aLayerMask[layer] )
|
||||
continue;
|
||||
|
||||
SHAPE_POLY_SET mainArea = zone->GetFilledPolysList( layer );
|
||||
SHAPE_POLY_SET mainArea = *zone->GetFilledPolysList( layer );
|
||||
SHAPE_POLY_SET islands;
|
||||
|
||||
for( int i = mainArea.OutlineCount() - 1; i >= 0; i-- )
|
||||
|
|
|
@ -3692,15 +3692,12 @@ bool CADSTAR_PCB_ARCHIVE_LOADER::calculateZonePriorities( PCB_LAYER_ID& aLayer )
|
|||
SHAPE_POLY_SET intersectShape( *aHigherZone->Outline() );
|
||||
intersectShape.Inflate( inflateValue( aLowerZone, aHigherZone ) , 32 );
|
||||
|
||||
SHAPE_POLY_SET lowerZoneFill( aLowerZone->GetFilledPolysList( aLayer ) );
|
||||
|
||||
SHAPE_POLY_SET lowerZoneFill( *aLowerZone->GetFilledPolysList( aLayer ) );
|
||||
SHAPE_POLY_SET lowerZoneOutline( *aLowerZone->Outline() );
|
||||
|
||||
lowerZoneOutline.BooleanSubtract( intersectShape,
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
lowerZoneOutline.BooleanSubtract( intersectShape, SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
lowerZoneFill.BooleanSubtract( lowerZoneOutline,
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
lowerZoneFill.BooleanSubtract( lowerZoneOutline, SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
double leftOverArea = lowerZoneFill.Area();
|
||||
|
||||
|
@ -3758,8 +3755,8 @@ bool CADSTAR_PCB_ARCHIVE_LOADER::calculateZonePriorities( PCB_LAYER_ID& aLayer )
|
|||
continue; // The zones do not interact in any way
|
||||
}
|
||||
|
||||
SHAPE_POLY_SET thisZonePolyFill = thisZone->GetFilledPolysList( aLayer );
|
||||
SHAPE_POLY_SET otherZonePolyFill = otherZone->GetFilledPolysList( aLayer );
|
||||
SHAPE_POLY_SET thisZonePolyFill = *thisZone->GetFilledPolysList( aLayer );
|
||||
SHAPE_POLY_SET otherZonePolyFill = *otherZone->GetFilledPolysList( aLayer );
|
||||
|
||||
if( thisZonePolyFill.Area() > 0.0 && otherZonePolyFill.Area() > 0.0 )
|
||||
{
|
||||
|
|
|
@ -2215,9 +2215,9 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const
|
|||
// Save the PolysList (filled areas)
|
||||
for( PCB_LAYER_ID layer : aZone->GetLayerSet().Seq() )
|
||||
{
|
||||
const SHAPE_POLY_SET& fv = aZone->GetFilledPolysList( layer );
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& fv = aZone->GetFilledPolysList( layer );
|
||||
|
||||
for( int ii = 0; ii < fv.OutlineCount(); ++ii )
|
||||
for( int ii = 0; ii < fv->OutlineCount(); ++ii )
|
||||
{
|
||||
m_out->Print( aNestLevel + 1, "(filled_polygon\n" );
|
||||
m_out->Print( aNestLevel + 2, "(layer %s)\n",
|
||||
|
@ -2226,7 +2226,7 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const
|
|||
if( aZone->IsIsland( layer, ii ) )
|
||||
m_out->Print( aNestLevel + 2, "(island)\n" );
|
||||
|
||||
const SHAPE_LINE_CHAIN& chain = fv.COutline( ii );
|
||||
const SHAPE_LINE_CHAIN& chain = fv->COutline( ii );
|
||||
|
||||
formatPolyPts( chain, aNestLevel + 1, ADVANCED_CFG::GetCfg().m_CompactSave );
|
||||
m_out->Print( aNestLevel + 1, ")\n" );
|
||||
|
|
|
@ -149,7 +149,13 @@ void ZONE::InitDataFromSrcInCopyCtor( const ZONE& aZone )
|
|||
|
||||
for( PCB_LAYER_ID layer : aZone.GetLayerSet().Seq() )
|
||||
{
|
||||
m_FilledPolysList[layer] = aZone.m_FilledPolysList.at( layer );
|
||||
std::shared_ptr<SHAPE_POLY_SET> fill = aZone.m_FilledPolysList.at( layer );
|
||||
|
||||
if( fill )
|
||||
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>( *fill );
|
||||
else
|
||||
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>();
|
||||
|
||||
m_RawPolysList[layer] = aZone.m_RawPolysList.at( layer );
|
||||
m_filledPolysHash[layer] = aZone.m_filledPolysHash.at( layer );
|
||||
m_insulatedIslands[layer] = aZone.m_insulatedIslands.at( layer );
|
||||
|
@ -178,11 +184,11 @@ bool ZONE::UnFill()
|
|||
{
|
||||
bool change = false;
|
||||
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
||||
{
|
||||
change |= !pair.second.IsEmpty();
|
||||
change |= !pair.second->IsEmpty();
|
||||
m_insulatedIslands[pair.first].clear();
|
||||
pair.second.RemoveAllContours();
|
||||
pair.second->RemoveAllContours();
|
||||
}
|
||||
|
||||
m_isFilled = false;
|
||||
|
@ -250,7 +256,7 @@ void ZONE::SetLayerSet( LSET aLayerSet )
|
|||
|
||||
for( PCB_LAYER_ID layer : aLayerSet.Seq() )
|
||||
{
|
||||
m_FilledPolysList[layer] = {};
|
||||
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>();
|
||||
m_RawPolysList[layer] = {};
|
||||
m_filledPolysHash[layer] = {};
|
||||
m_insulatedIslands[layer] = {};
|
||||
|
@ -351,7 +357,7 @@ void ZONE::BuildHashValue( PCB_LAYER_ID aLayer )
|
|||
if( !m_FilledPolysList.count( aLayer ) )
|
||||
m_filledPolysHash[aLayer] = g_nullPoly.GetHash();
|
||||
else
|
||||
m_filledPolysHash[aLayer] = m_FilledPolysList.at( aLayer ).GetHash();
|
||||
m_filledPolysHash[aLayer] = m_FilledPolysList.at( aLayer )->GetHash();
|
||||
}
|
||||
|
||||
|
||||
|
@ -466,13 +472,12 @@ bool ZONE::HitTestFilledArea( PCB_LAYER_ID aLayer, const VECTOR2I& aRefPos, int
|
|||
// Rule areas have no filled area, but it's generally nice to treat their interior as if it were
|
||||
// filled so that people don't have to select them by their outline (which is min-width)
|
||||
if( GetIsRuleArea() )
|
||||
return m_Poly->Contains( VECTOR2I( aRefPos.x, aRefPos.y ), -1, aAccuracy );
|
||||
return m_Poly->Contains( aRefPos, -1, aAccuracy );
|
||||
|
||||
if( !m_FilledPolysList.count( aLayer ) )
|
||||
return false;
|
||||
|
||||
return m_FilledPolysList.at( aLayer ).Contains( VECTOR2I( aRefPos.x, aRefPos.y ), -1,
|
||||
aAccuracy );
|
||||
return m_FilledPolysList.at( aLayer )->Contains( aRefPos, -1, aAccuracy );
|
||||
}
|
||||
|
||||
|
||||
|
@ -622,7 +627,7 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
|
|||
|
||||
if( layer_it != m_FilledPolysList.end() )
|
||||
{
|
||||
msg.Printf( wxT( "%d" ), layer_it->second.TotalVertices() );
|
||||
msg.Printf( wxT( "%d" ), layer_it->second->TotalVertices() );
|
||||
aList.emplace_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg ) );
|
||||
}
|
||||
}
|
||||
|
@ -636,8 +641,8 @@ void ZONE::Move( const VECTOR2I& offset )
|
|||
|
||||
HatchBorder();
|
||||
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
pair.second.Move( offset );
|
||||
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
||||
pair.second->Move( offset );
|
||||
}
|
||||
|
||||
|
||||
|
@ -662,8 +667,8 @@ void ZONE::Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle )
|
|||
HatchBorder();
|
||||
|
||||
/* rotate filled areas: */
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
pair.second.Rotate( aAngle, aCentre );
|
||||
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
||||
pair.second->Rotate( aAngle, aCentre );
|
||||
}
|
||||
|
||||
|
||||
|
@ -686,8 +691,8 @@ void ZONE::Mirror( const VECTOR2I& aMirrorRef, bool aMirrorLeftRight )
|
|||
|
||||
HatchBorder();
|
||||
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
pair.second.Mirror( aMirrorLeftRight, !aMirrorLeftRight, aMirrorRef );
|
||||
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
||||
pair.second->Mirror( aMirrorLeftRight, !aMirrorLeftRight, aMirrorRef );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1018,13 +1023,13 @@ void ZONE::CacheTriangulation( PCB_LAYER_ID aLayer )
|
|||
{
|
||||
if( aLayer == UNDEFINED_LAYER )
|
||||
{
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
pair.second.CacheTriangulation();
|
||||
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
||||
pair.second->CacheTriangulation();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_FilledPolysList.count( aLayer ) )
|
||||
m_FilledPolysList[ aLayer ].CacheTriangulation();
|
||||
m_FilledPolysList[ aLayer ]->CacheTriangulation();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1175,16 +1180,16 @@ double ZONE::CalculateFilledArea()
|
|||
|
||||
// Iterate over each outline polygon in the zone and then iterate over
|
||||
// each hole it has to compute the total area.
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
for( std::pair<const PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>>& pair : m_FilledPolysList )
|
||||
{
|
||||
SHAPE_POLY_SET& poly = pair.second;
|
||||
std::shared_ptr<SHAPE_POLY_SET>& poly = pair.second;
|
||||
|
||||
for( int i = 0; i < poly.OutlineCount(); i++ )
|
||||
for( int i = 0; i < poly->OutlineCount(); i++ )
|
||||
{
|
||||
m_area += poly.Outline( i ).Area();
|
||||
m_area += poly->Outline( i ).Area();
|
||||
|
||||
for( int j = 0; j < poly.HoleCount( i ); j++ )
|
||||
m_area -= poly.Hole( i, j ).Area();
|
||||
for( int j = 0; j < poly->HoleCount( i ); j++ )
|
||||
m_area -= poly->Hole( i, j ).Area();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1302,7 +1307,7 @@ std::shared_ptr<SHAPE> ZONE::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
|
|||
}
|
||||
else
|
||||
{
|
||||
shape.reset( m_FilledPolysList.at( aLayer ).Clone() );
|
||||
shape.reset( m_FilledPolysList.at( aLayer )->Clone() );
|
||||
}
|
||||
|
||||
return shape;
|
||||
|
@ -1318,7 +1323,7 @@ void ZONE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
|||
if( !m_FilledPolysList.count( aLayer ) )
|
||||
return;
|
||||
|
||||
aCornerBuffer = m_FilledPolysList.at( aLayer );
|
||||
aCornerBuffer = *m_FilledPolysList.at( aLayer );
|
||||
|
||||
// Rebuild filled areas only if clearance is not 0
|
||||
if( aClearance )
|
||||
|
@ -1332,8 +1337,8 @@ void ZONE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
|||
void ZONE::TransformSolidAreasShapesToPolygon( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aCornerBuffer,
|
||||
int aError ) const
|
||||
{
|
||||
if( m_FilledPolysList.count( aLayer ) && !m_FilledPolysList.at( aLayer ).IsEmpty() )
|
||||
aCornerBuffer.Append( m_FilledPolysList.at( aLayer ) );
|
||||
if( m_FilledPolysList.count( aLayer ) && !m_FilledPolysList.at( aLayer )->IsEmpty() )
|
||||
aCornerBuffer.Append( *m_FilledPolysList.at( aLayer ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -639,7 +639,7 @@ public:
|
|||
/**
|
||||
* @return a reference to the list of filled polygons.
|
||||
*/
|
||||
const SHAPE_POLY_SET& GetFilledPolysList( PCB_LAYER_ID aLayer ) const
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& GetFilledPolysList( PCB_LAYER_ID aLayer ) const
|
||||
{
|
||||
wxASSERT( m_FilledPolysList.count( aLayer ) );
|
||||
return m_FilledPolysList.at( aLayer );
|
||||
|
@ -648,7 +648,7 @@ public:
|
|||
SHAPE_POLY_SET* GetFill( PCB_LAYER_ID aLayer )
|
||||
{
|
||||
wxASSERT( m_FilledPolysList.count( aLayer ) );
|
||||
return &m_FilledPolysList.at( aLayer );
|
||||
return m_FilledPolysList.at( aLayer ).get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -662,7 +662,7 @@ public:
|
|||
*/
|
||||
void SetFilledPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
|
||||
{
|
||||
m_FilledPolysList[aLayer] = aPolysList;
|
||||
m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -931,7 +931,7 @@ protected:
|
|||
* connecting "holes" with external main outline. In complex cases an outline
|
||||
* described by m_Poly can have many filled areas
|
||||
*/
|
||||
std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_FilledPolysList;
|
||||
std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> m_FilledPolysList;
|
||||
std::map<PCB_LAYER_ID, SHAPE_POLY_SET> m_RawPolysList;
|
||||
|
||||
/// Temp variables used while filling
|
||||
|
|
|
@ -339,23 +339,22 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
|
|||
// to allow deleting a polygon from list without breaking the remaining of the list
|
||||
std::sort( islands.begin(), islands.end(), std::greater<int>() );
|
||||
|
||||
SHAPE_POLY_SET poly = zone.m_zone->GetFilledPolysList( layer );
|
||||
std::shared_ptr<SHAPE_POLY_SET> poly = zone.m_zone->GetFilledPolysList( layer );
|
||||
long long int minArea = zone.m_zone->GetMinIslandArea();
|
||||
ISLAND_REMOVAL_MODE mode = zone.m_zone->GetIslandRemovalMode();
|
||||
|
||||
for( int idx : islands )
|
||||
{
|
||||
SHAPE_LINE_CHAIN& outline = poly.Outline( idx );
|
||||
SHAPE_LINE_CHAIN& outline = poly->Outline( idx );
|
||||
|
||||
if( mode == ISLAND_REMOVAL_MODE::ALWAYS )
|
||||
poly.DeletePolygon( idx );
|
||||
poly->DeletePolygon( idx );
|
||||
else if ( mode == ISLAND_REMOVAL_MODE::AREA && outline.Area() < minArea )
|
||||
poly.DeletePolygon( idx );
|
||||
poly->DeletePolygon( idx );
|
||||
else
|
||||
zone.m_zone->SetIsIsland( layer, idx );
|
||||
}
|
||||
|
||||
zone.m_zone->SetFilledPolysList( layer, poly );
|
||||
zone.m_zone->CalculateFilledArea();
|
||||
|
||||
if( m_progressReporter && m_progressReporter->IsCancelled() )
|
||||
|
@ -373,17 +372,16 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
|
|||
if( m_debugZoneFiller && LSET::InternalCuMask().Contains( layer ) )
|
||||
continue;
|
||||
|
||||
SHAPE_POLY_SET poly = zone->GetFilledPolysList( layer );
|
||||
std::shared_ptr<SHAPE_POLY_SET> poly = zone->GetFilledPolysList( layer );
|
||||
|
||||
for( int ii = poly.OutlineCount() - 1; ii >= 0; ii-- )
|
||||
for( int ii = poly->OutlineCount() - 1; ii >= 0; ii-- )
|
||||
{
|
||||
std::vector<SHAPE_LINE_CHAIN>& island = poly.Polygon( ii );
|
||||
std::vector<SHAPE_LINE_CHAIN>& island = poly->Polygon( ii );
|
||||
|
||||
if( island.empty() || !m_boardOutline.Contains( island.front().CPoint( 0 ) ) )
|
||||
poly.DeletePolygon( ii );
|
||||
poly->DeletePolygon( ii );
|
||||
}
|
||||
|
||||
zone->SetFilledPolysList( layer, poly );
|
||||
zone->CalculateFilledArea();
|
||||
|
||||
if( m_progressReporter && m_progressReporter->IsCancelled() )
|
||||
|
|
|
@ -151,7 +151,7 @@ BOOST_FIXTURE_TEST_CASE( NotchedZones, ZONE_FILL_TEST_FIXTURE )
|
|||
{
|
||||
if( zone->GetLayerSet().Contains( F_Cu ) )
|
||||
{
|
||||
frontCopper.BooleanAdd( zone->GetFilledPolysList( F_Cu ),
|
||||
frontCopper.BooleanAdd( *zone->GetFilledPolysList( F_Cu ),
|
||||
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ BOOST_FIXTURE_TEST_CASE( NotchedZones, ZONE_FILL_TEST_FIXTURE )
|
|||
{
|
||||
if( zone->GetLayerSet().Contains( F_Cu ) )
|
||||
{
|
||||
frontCopper.BooleanAdd( zone->GetFilledPolysList( F_Cu ),
|
||||
frontCopper.BooleanAdd( *zone->GetFilledPolysList( F_Cu ),
|
||||
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ int polygon_triangulation_main( int argc, char *argv[] )
|
|||
// to do that right now.
|
||||
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
||||
{
|
||||
SHAPE_POLY_SET poly = zone->GetFilledPolysList( layer );
|
||||
SHAPE_POLY_SET poly = *zone->GetFilledPolysList( layer );
|
||||
|
||||
poly.CacheTriangulation();
|
||||
|
||||
|
|
Loading…
Reference in New Issue