Performance: get rid of rawPolys / finalPolys distinction.

(The final fractured polys are required, and we don't really ever use
the raw polys anyway, so they were removed.)
This commit is contained in:
Jeff Young 2022-02-16 15:33:12 +00:00
parent 08383e923c
commit 327ddad79f
6 changed files with 36 additions and 70 deletions

View File

@ -2103,8 +2103,8 @@ void ALTIUM_PCB::ParseRegions6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFi
linechain.Append( elem.outline.at( 0 ).position ); linechain.Append( elem.outline.at( 0 ).position );
linechain.SetClosed( true ); linechain.SetClosed( true );
SHAPE_POLY_SET rawPolys; SHAPE_POLY_SET fill;
rawPolys.AddOutline( linechain ); fill.AddOutline( linechain );
for( const std::vector<ALTIUM_VERTICE>& hole : elem.holes ) for( const std::vector<ALTIUM_VERTICE>& hole : elem.holes )
{ {
@ -2115,20 +2115,15 @@ void ALTIUM_PCB::ParseRegions6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFi
hole_linechain.Append( hole.at( 0 ).position ); hole_linechain.Append( hole.at( 0 ).position );
hole_linechain.SetClosed( true ); hole_linechain.SetClosed( true );
rawPolys.AddHole( hole_linechain ); fill.AddHole( hole_linechain );
} }
if( zone->HasFilledPolysForLayer( klayer ) ) if( zone->HasFilledPolysForLayer( klayer ) )
{ fill.BooleanAdd( *zone->GetFill( klayer ), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
rawPolys.BooleanAdd( zone->RawPolysList( klayer ),
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
}
SHAPE_POLY_SET finalPolys = rawPolys; fill.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
finalPolys.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
zone->SetRawPolysList( klayer, rawPolys ); zone->SetFilledPolysList( klayer, fill );
zone->SetFilledPolysList( klayer, finalPolys );
zone->SetIsFilled( true ); zone->SetIsFilled( true );
zone->SetNeedRefill( false ); zone->SetNeedRefill( false );
} }

View File

@ -2028,7 +2028,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers()
if( !csCopper.PouredTemplateID.IsEmpty() ) if( !csCopper.PouredTemplateID.IsEmpty() )
{ {
ZONE* pouredZone = m_zonesMap.at( csCopper.PouredTemplateID ); ZONE* pouredZone = m_zonesMap.at( csCopper.PouredTemplateID );
SHAPE_POLY_SET rawPolys; SHAPE_POLY_SET fill;
int copperWidth = getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth ); int copperWidth = getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth );
@ -2058,28 +2058,26 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers()
} }
poly.ClearArcs(); poly.ClearArcs();
rawPolys.BooleanAdd( poly, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); fill.BooleanAdd( poly, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
} }
} }
else else
{ {
rawPolys = getPolySetFromCadstarShape( csCopper.Shape, -1 ); fill = getPolySetFromCadstarShape( csCopper.Shape, -1 );
rawPolys.ClearArcs(); fill.ClearArcs();
rawPolys.Inflate( copperWidth / 2, 32 ); fill.Inflate( copperWidth / 2, 32 );
} }
if( pouredZone->HasFilledPolysForLayer( getKiCadLayer( csCopper.LayerID ) ) ) if( pouredZone->HasFilledPolysForLayer( getKiCadLayer( csCopper.LayerID ) ) )
{ {
rawPolys.BooleanAdd( pouredZone->RawPolysList( getKiCadLayer( csCopper.LayerID )), fill.BooleanAdd( *pouredZone->GetFill( getKiCadLayer( csCopper.LayerID ) ),
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
} }
SHAPE_POLY_SET finalPolys = rawPolys; fill.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
finalPolys.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
pouredZone->SetRawPolysList( getKiCadLayer( csCopper.LayerID ), rawPolys ); pouredZone->SetFilledPolysList( getKiCadLayer( csCopper.LayerID ), fill );
pouredZone->SetFilledPolysList( getKiCadLayer( csCopper.LayerID ), finalPolys );
pouredZone->SetIsFilled( true ); pouredZone->SetIsFilled( true );
pouredZone->SetNeedRefill( false ); pouredZone->SetNeedRefill( false );
continue; continue;
@ -2155,12 +2153,11 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers()
zone->SetPadConnection( ZONE_CONNECTION::FULL ); zone->SetPadConnection( ZONE_CONNECTION::FULL );
zone->SetNet( getKiCadNet( csCopper.NetRef.NetID ) ); zone->SetNet( getKiCadNet( csCopper.NetRef.NetID ) );
zone->SetPriority( m_zonesMap.size() + 1 ); // Highest priority (always fill first) zone->SetPriority( m_zonesMap.size() + 1 ); // Highest priority (always fill first)
zone->SetRawPolysList( getKiCadLayer( csCopper.LayerID ), *zone->Outline() );
SHAPE_POLY_SET fillePolys( *zone->Outline() ); SHAPE_POLY_SET fill( *zone->Outline() );
fillePolys.Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_STRICTLY_SIMPLE ); fill.Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_STRICTLY_SIMPLE );
zone->SetFilledPolysList( getKiCadLayer( csCopper.LayerID ), fillePolys ); zone->SetFilledPolysList( getKiCadLayer( csCopper.LayerID ), fill );
} }
} }
} }

View File

@ -156,7 +156,6 @@ void ZONE::InitDataFromSrcInCopyCtor( const ZONE& aZone )
else else
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>(); 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_filledPolysHash[layer] = aZone.m_filledPolysHash.at( layer );
m_insulatedIslands[layer] = aZone.m_insulatedIslands.at( layer ); m_insulatedIslands[layer] = aZone.m_insulatedIslands.at( layer );
} }
@ -250,14 +249,12 @@ void ZONE::SetLayerSet( LSET aLayerSet )
UnFill(); UnFill();
m_FilledPolysList.clear(); m_FilledPolysList.clear();
m_RawPolysList.clear();
m_filledPolysHash.clear(); m_filledPolysHash.clear();
m_insulatedIslands.clear(); m_insulatedIslands.clear();
for( PCB_LAYER_ID layer : aLayerSet.Seq() ) for( PCB_LAYER_ID layer : aLayerSet.Seq() )
{ {
m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>(); m_FilledPolysList[layer] = std::make_shared<SHAPE_POLY_SET>();
m_RawPolysList[layer] = {};
m_filledPolysHash[layer] = {}; m_filledPolysHash[layer] = {};
m_insulatedIslands[layer] = {}; m_insulatedIslands[layer] = {};
} }

View File

@ -665,14 +665,6 @@ public:
m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList ); m_FilledPolysList[aLayer] = std::make_shared<SHAPE_POLY_SET>( aPolysList );
} }
/**
* Set the list of filled polygons.
*/
void SetRawPolysList( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
{
m_RawPolysList[aLayer] = aPolysList;
}
/** /**
* Check if a given filled polygon is an insulated island. * Check if a given filled polygon is an insulated island.
* *
@ -717,12 +709,6 @@ public:
void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon ); void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
SHAPE_POLY_SET& RawPolysList( PCB_LAYER_ID aLayer )
{
wxASSERT( m_RawPolysList.count( aLayer ) );
return m_RawPolysList.at( aLayer );
}
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
BITMAPS GetMenuImage() const override; BITMAPS GetMenuImage() const override;
@ -932,7 +918,6 @@ protected:
* described by m_Poly can have many filled areas * described by m_Poly can have many filled areas
*/ */
std::map<PCB_LAYER_ID, std::shared_ptr<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 /// Temp variables used while filling
EDA_RECT m_bboxCache; EDA_RECT m_bboxCache;

View File

@ -238,13 +238,12 @@ bool ZONE_FILLER::Fill( std::vector<ZONE*>& aZones, bool aCheck, wxWindow* aPare
continue; continue;
// Now we're ready to fill. // Now we're ready to fill.
SHAPE_POLY_SET rawPolys, finalPolys; SHAPE_POLY_SET fillPolys;
fillSingleZone( zone, layer, rawPolys, finalPolys ); fillSingleZone( zone, layer, fillPolys );
std::unique_lock<std::mutex> zoneLock( zone->GetLock() ); std::unique_lock<std::mutex> zoneLock( zone->GetLock() );
zone->SetRawPolysList( layer, rawPolys ); zone->SetFilledPolysList( layer, fillPolys );
zone->SetFilledPolysList( layer, finalPolys );
zone->SetFillFlag( layer, true ); zone->SetFillFlag( layer, true );
if( m_progressReporter ) if( m_progressReporter )
@ -987,11 +986,11 @@ void ZONE_FILLER::subtractHigherPriorityZones( const ZONE* aZone, PCB_LAYER_ID a
* 5 - Removes unconnected copper islands, deleting any affected spokes * 5 - Removes unconnected copper islands, deleting any affected spokes
* 6 - Adds in the remaining spokes * 6 - Adds in the remaining spokes
*/ */
bool ZONE_FILLER::computeRawFilledArea( const ZONE* aZone, bool ZONE_FILLER::fillCopperZone( const ZONE* aZone,
PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer,
const SHAPE_POLY_SET& aSmoothedOutline, const SHAPE_POLY_SET& aSmoothedOutline,
const SHAPE_POLY_SET& aMaxExtents, const SHAPE_POLY_SET& aMaxExtents,
SHAPE_POLY_SET& aRawPolys ) SHAPE_POLY_SET& aRawPolys )
{ {
m_maxError = m_board->GetDesignSettings().m_MaxError; m_maxError = m_board->GetDesignSettings().m_MaxError;
@ -1160,8 +1159,7 @@ bool ZONE_FILLER::computeRawFilledArea( const ZONE* aZone,
* The solid areas can be more than one on copper layers, and do not have holes * The solid areas can be more than one on copper layers, and do not have holes
* ( holes are linked by overlapping segments to the main outline) * ( holes are linked by overlapping segments to the main outline)
*/ */
bool ZONE_FILLER::fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aRawPolys, bool ZONE_FILLER::fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aFillPolys )
SHAPE_POLY_SET& aFinalPolys )
{ {
SHAPE_POLY_SET* boardOutline = m_brdOutlinesValid ? &m_boardOutline : nullptr; SHAPE_POLY_SET* boardOutline = m_brdOutlinesValid ? &m_boardOutline : nullptr;
SHAPE_POLY_SET maxExtents; SHAPE_POLY_SET maxExtents;
@ -1182,10 +1180,8 @@ bool ZONE_FILLER::fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_S
if( aZone->IsOnCopperLayer() ) if( aZone->IsOnCopperLayer() )
{ {
if( computeRawFilledArea( aZone, aLayer, debugLayer, smoothedPoly, maxExtents, aRawPolys ) ) if( fillCopperZone( aZone, aLayer, debugLayer, smoothedPoly, maxExtents, aFillPolys ) )
aZone->SetNeedRefill( false ); aZone->SetNeedRefill( false );
aFinalPolys = aRawPolys;
} }
else else
{ {
@ -1206,10 +1202,9 @@ bool ZONE_FILLER::fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_S
if( half_min_width - epsilon > epsilon ) if( half_min_width - epsilon > epsilon )
smoothedPoly.Inflate( half_min_width - epsilon, numSegs ); smoothedPoly.Inflate( half_min_width - epsilon, numSegs );
aRawPolys = smoothedPoly; aFillPolys = smoothedPoly;
aFinalPolys = smoothedPoly;
aFinalPolys.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); aFillPolys.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
aZone->SetNeedRefill( false ); aZone->SetNeedRefill( false );
} }

View File

@ -75,7 +75,7 @@ private:
SHAPE_POLY_SET& aRawFill ); SHAPE_POLY_SET& aRawFill );
/** /**
* Function computeRawFilledArea * Function fillCopperZone
* Add non copper areas polygons (pads and tracks with clearance) * Add non copper areas polygons (pads and tracks with clearance)
* to a filled copper area * to a filled copper area
* used in BuildFilledSolidAreasPolygons when calculating filled areas in a zone * used in BuildFilledSolidAreasPolygons when calculating filled areas in a zone
@ -85,9 +85,9 @@ private:
* filled copper area polygon (without clearance areas * filled copper area polygon (without clearance areas
* @param aPcb: the current board * @param aPcb: the current board
*/ */
bool computeRawFilledArea( const ZONE* aZone, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer, bool fillCopperZone( const ZONE* aZone, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer,
const SHAPE_POLY_SET& aSmoothedOutline, const SHAPE_POLY_SET& aSmoothedOutline,
const SHAPE_POLY_SET& aMaxExtents, SHAPE_POLY_SET& aRawPolys ); const SHAPE_POLY_SET& aMaxExtents, SHAPE_POLY_SET& aRawPolys );
/** /**
* Function buildThermalSpokes * Function buildThermalSpokes
@ -104,15 +104,12 @@ private:
* in order to have drawable (and plottable) filled polygons. * in order to have drawable (and plottable) filled polygons.
* @return true if OK, false if the solid polygons cannot be built * @return true if OK, false if the solid polygons cannot be built
* @param aZone is the zone to fill * @param aZone is the zone to fill
* @param aRawPolys: A reference to a SHAPE_POLY_SET buffer to store * @param aFillPolys: A reference to a SHAPE_POLY_SET buffer to store polygons with no holes
* filled solid areas polygons (with holes)
* @param aFinalPolys: A reference to a SHAPE_POLY_SET buffer to store polygons with no holes
* (holes are linked to main outline by overlapping segments, and these polygons are shrunk * (holes are linked to main outline by overlapping segments, and these polygons are shrunk
* by aZone->GetMinThickness() / 2 to be drawn with a outline thickness = aZone->GetMinThickness() * by aZone->GetMinThickness() / 2 to be drawn with a outline thickness = aZone->GetMinThickness()
* aFinalPolys are polygons that will be drawn on screen and plotted * aFinalPolys are polygons that will be drawn on screen and plotted
*/ */
bool fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aRawPolys, bool fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aFillPolys );
SHAPE_POLY_SET& aFinalPolys );
/** /**
* for zones having the ZONE_FILL_MODE::ZONE_FILL_MODE::HATCH_PATTERN, create a grid pattern * for zones having the ZONE_FILL_MODE::ZONE_FILL_MODE::HATCH_PATTERN, create a grid pattern