KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ZONE_FILLER Class Reference

#include <zone_filler.h>

Public Member Functions

 ZONE_FILLER (BOARD *aBoard, COMMIT *aCommit)
 
 ~ZONE_FILLER ()
 
void SetProgressReporter (PROGRESS_REPORTER *aReporter)
 
PROGRESS_REPORTERGetProgressReporter () const
 
bool Fill (const std::vector< ZONE * > &aZones, bool aCheck=false, wxWindow *aParent=nullptr)
 Fills the given list of zones.
 
bool IsDebug () const
 

Private Member Functions

void addKnockout (PAD *aPad, PCB_LAYER_ID aLayer, int aGap, SHAPE_POLY_SET &aHoles)
 Add a knockout for a pad.
 
void addKnockout (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aGap, bool aIgnoreLineWidth, SHAPE_POLY_SET &aHoles)
 Add a knockout for a graphic item.
 
void addHoleKnockout (PAD *aPad, int aGap, SHAPE_POLY_SET &aHoles)
 Add a knockout for a pad's hole.
 
void knockoutThermalReliefs (const ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aFill, std::vector< PAD * > &aThermalConnectionPads, std::vector< PAD * > &aNoConnectionPads)
 Removes thermal reliefs from the shape for any pads connected to the zone.
 
void buildCopperItemClearances (const ZONE *aZone, PCB_LAYER_ID aLayer, const std::vector< PAD * > &aNoConnectionPads, SHAPE_POLY_SET &aHoles)
 Removes clearance from the shape for copper items which share the zone's layer but are not connected to it.
 
void subtractHigherPriorityZones (const ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aRawFill)
 Removes the outlines of higher-proirity zones with the same net.
 
bool fillCopperZone (const ZONE *aZone, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer, const SHAPE_POLY_SET &aSmoothedOutline, const SHAPE_POLY_SET &aMaxExtents, SHAPE_POLY_SET &aFillPolys)
 Function fillCopperZone Add non copper areas polygons (pads and tracks with clearance) to a filled copper area used in BuildFilledSolidAreasPolygons when calculating filled areas in a zone Non copper areas are pads and track and their clearance area The filled copper area must be computed before BuildFilledSolidAreasPolygons() call this function just after creating the filled copper area polygon (without clearance areas.
 
bool fillNonCopperZone (const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aSmoothedOutline, SHAPE_POLY_SET &aFillPolys)
 
void buildThermalSpokes (const ZONE *box, PCB_LAYER_ID aLayer, const std::vector< PAD * > &aSpokedPadsList, std::deque< SHAPE_LINE_CHAIN > &aSpokes)
 Function buildThermalSpokes Constructs a list of all thermal spokes for the given zone.
 
void connect_nearby_polys (SHAPE_POLY_SET &aPolys, double aDistance)
 Create strands of zero-width between elements of SHAPE_POLY_SET that are within aDistance of each other.
 
bool fillSingleZone (ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aFillPolys)
 Build the filled solid areas polygons from zone outlines (stored in m_Poly) 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) in order to have drawable (and plottable) filled polygons.
 
bool addHatchFillTypeOnZone (const ZONE *aZone, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer, SHAPE_POLY_SET &aFillPolys)
 for zones having the ZONE_FILL_MODE::ZONE_FILL_MODE::HATCH_PATTERN, create a grid pattern in filled areas of aZone, giving to the filled polygons a fill style like a grid
 

Private Attributes

BOARDm_board
 
SHAPE_POLY_SET m_boardOutline
 
bool m_brdOutlinesValid
 
COMMITm_commit
 
PROGRESS_REPORTERm_progressReporter
 
int m_maxError
 
int m_worstClearance
 
bool m_debugZoneFiller
 

Detailed Description

Definition at line 39 of file zone_filler.h.

Constructor & Destructor Documentation

◆ ZONE_FILLER()

ZONE_FILLER::ZONE_FILLER ( BOARD aBoard,
COMMIT aCommit 
)

◆ ~ZONE_FILLER()

ZONE_FILLER::~ZONE_FILLER ( )

Definition at line 210 of file zone_filler.cpp.

Member Function Documentation

◆ addHatchFillTypeOnZone()

bool ZONE_FILLER::addHatchFillTypeOnZone ( const ZONE aZone,
PCB_LAYER_ID  aLayer,
PCB_LAYER_ID  aDebugLayer,
SHAPE_POLY_SET aFillPolys 
)
private

for zones having the ZONE_FILL_MODE::ZONE_FILL_MODE::HATCH_PATTERN, create a grid pattern in filled areas of aZone, giving to the filled polygons a fill style like a grid

Parameters
aZoneis the zone to modify
aFillPolysA reference to a SHAPE_POLY_SET buffer containing the initial filled areas, and after adding the grid pattern, the modified filled areas with holes

Definition at line 2235 of file zone_filler.cpp.

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Area(), SHAPE_POLY_SET::BBox(), SHAPE_POLY_SET::BooleanIntersection(), SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::Chamfer(), SHAPE_POLY_SET::CloneDropTriangulation(), SHAPE_POLY_SET::Deflate(), SHAPE_POLY_SET::DeletePolygon(), DUMP_POLYS_TO_COPPER_LAYER, ERROR_OUTSIDE, SHAPE_POLY_SET::Fillet(), BOARD::Footprints(), ZONE::GetBoundingBox(), BOARD::GetDesignSettings(), ZONE::GetHatchBorderAlgorithm(), ZONE::GetHatchGap(), ZONE::GetHatchHoleMinArea(), ZONE::GetHatchOrientation(), ZONE::GetHatchSmoothingLevel(), ZONE::GetHatchSmoothingValue(), ZONE::GetHatchThickness(), BOX2< Vec >::GetHeight(), ZONE::GetMinThickness(), BOARD_CONNECTED_ITEM::GetNetCode(), BOX2< Vec >::GetPosition(), BOX2< Vec >::GetWidth(), In10_Cu, In11_Cu, In12_Cu, In13_Cu, In14_Cu, EDA_ANGLE::IsZero(), KiROUND(), m_board, BOARD_DESIGN_SETTINGS::m_MaxError, EDA_IU_SCALE::mmToIU(), SHAPE_LINE_CHAIN::Move(), SHAPE_POLY_SET::Move(), ZONE::Outline(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), pad, PCB_VIA_T, pcbIUScale, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_POLY_SET::Rotate(), SHAPE_LINE_CHAIN::SetClosed(), SMOOTH_MIN_VAL_MM, SMOOTH_SMALL_VAL_MM, BOARD::Tracks(), TransformCircleToPolygon(), via, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by fillCopperZone(), and fillNonCopperZone().

◆ addHoleKnockout()

void ZONE_FILLER::addHoleKnockout ( PAD aPad,
int  aGap,
SHAPE_POLY_SET aHoles 
)
private

Add a knockout for a pad's hole.

Definition at line 945 of file zone_filler.cpp.

References ERROR_OUTSIDE, m_maxError, and PAD::TransformHoleToPolygon().

Referenced by buildCopperItemClearances(), and fillCopperZone().

◆ addKnockout() [1/2]

void ZONE_FILLER::addKnockout ( BOARD_ITEM aItem,
PCB_LAYER_ID  aLayer,
int  aGap,
bool  aIgnoreLineWidth,
SHAPE_POLY_SET aHoles 
)
private

Add a knockout for a graphic item.

The knockout is 'aGap' larger than the item (which might be either the electrical clearance or the board edge clearance).

Definition at line 955 of file zone_filler.cpp.

References ERROR_OUTSIDE, m_maxError, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_FIELD_T, PCB_SHAPE_T, PCB_TABLE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TEXTBOX_T, BOARD_ITEM::SetIsKnockout(), text, PCB_DIMENSION_BASE::TransformShapeToPolygon(), BOARD_ITEM::TransformShapeToPolygon(), PCB_TEXT::TransformShapeToPolygon(), and EDA_ITEM::Type().

◆ addKnockout() [2/2]

void ZONE_FILLER::addKnockout ( PAD aPad,
PCB_LAYER_ID  aLayer,
int  aGap,
SHAPE_POLY_SET aHoles 
)
private

Add a knockout for a pad.

The knockout is 'aGap' larger than the pad (which might be either the thermal clearance or the electrical clearance).

Definition at line 914 of file zone_filler.cpp.

References SHAPE_POLY_SET::Append(), BuildConvexHull(), PADSTACK::CONVEXHULL, ERROR_OUTSIDE, PAD::GetCustomShapeInZoneOpt(), PAD::GetShape(), m_maxError, SHAPE_POLY_SET::NewOutline(), and PAD::TransformShapeToPolygon().

Referenced by buildCopperItemClearances(), fillNonCopperZone(), and knockoutThermalReliefs().

◆ buildCopperItemClearances()

◆ buildThermalSpokes()

◆ connect_nearby_polys()

void ZONE_FILLER::connect_nearby_polys ( SHAPE_POLY_SET aPolys,
double  aDistance 
)
private

Create strands of zero-width between elements of SHAPE_POLY_SET that are within aDistance of each other.

When we inflate these strands, they will create minimum width bands

Definition at line 1568 of file zone_filler.cpp.

References SHAPE_POLY_SET::BBoxFromCaches(), SHAPE_LINE_CHAIN::CPoint(), VERTEX_CONNECTOR::FindResults(), VERTEX_CONNECTOR::GetResults(), SHAPE_LINE_CHAIN::Insert(), SHAPE_POLY_SET::Outline(), and SHAPE_POLY_SET::OutlineCount().

Referenced by fillCopperZone().

◆ Fill()

bool ZONE_FILLER::Fill ( const std::vector< ZONE * > &  aZones,
bool  aCheck = false,
wxWindow *  aParent = nullptr 
)

Fills the given list of zones.

NB: Invalidates connectivity - it is up to the caller to obtain a lock on the connectivity data before calling Fill to prevent access to stale data by other coroutines (for example, ratsnest redraw). This will generally be required if a UI-based progress reporter has been installed.

Caller is also responsible for re-building connectivity afterwards.

Definition at line 233 of file zone_filler.cpp.

References _, SHAPE_POLY_SET::AddOutline(), PROGRESS_REPORTER::AdvancePhase(), PROGRESS_REPORTER::AdvanceProgress(), LSET::AllCuMask(), SHAPE_POLY_SET::Area(), SHAPE_LINE_CHAIN::Area(), SHAPE_POLY_SET::BooleanIntersection(), ZONE::CacheTriangulation(), SHAPE_POLY_SET::Collide(), LSET::Contains(), KIDIALOG::DoNotShowCheckbox(), ERROR_OUTSIDE, fillSingleZone(), BOARD::Footprints(), ZONE::GetAssignedPriority(), BOARD_ITEM::GetBoard(), BOARD::GetBoardPolygonOutlines(), ZONE::GetBoundingBox(), BOARD::GetConnectivity(), BOARD::GetCopperLayerCount(), BOARD::GetEnabledLayers(), GetKiCadThreadPool(), ZONE::GetLock(), BOARD::GetMaxClearanceValue(), BOARD_CONNECTED_ITEM::GetNetCode(), ZONE::HigherPriority(), BOX2< Vec >::Inflate(), LSET::InternalCuMask(), BOX2< Vec >::Intersects(), PROGRESS_REPORTER::IsCancelled(), PROGRESS_REPORTER::KeepRefreshing(), m_board, m_boardOutline, m_brdOutlinesValid, m_commit, m_debugZoneFiller, m_progressReporter, m_worstClearance, COMMIT::Modify(), ZONE::Outline(), pad, PCB_VIA_T, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::RemoveAllContours(), PROGRESS_REPORTER::Report(), LSET::Seq(), ZONE::SetFilledPolysList(), ZONE::SetFillFlag(), PROGRESS_REPORTER::SetMaxProgress(), KIDIALOG::SetOKCancelLabels(), KIDIALOG::ShowModal(), tp, BOARD::Tracks(), via, ZLO_FORCE_FLASHED, ZLO_FORCE_NO_ZONE_CONNECTION, and BOARD::Zones().

Referenced by KI_TEST::FillZones(), and DIALOG_GLOBAL_EDIT_TEARDROPS::TransferDataFromWindow().

◆ fillCopperZone()

bool ZONE_FILLER::fillCopperZone ( const ZONE aZone,
PCB_LAYER_ID  aLayer,
PCB_LAYER_ID  aDebugLayer,
const SHAPE_POLY_SET aSmoothedOutline,
const SHAPE_POLY_SET aMaxExtents,
SHAPE_POLY_SET aFillPolys 
)
private

Function fillCopperZone Add non copper areas polygons (pads and tracks with clearance) to a filled copper area used in BuildFilledSolidAreasPolygons when calculating filled areas in a zone Non copper areas are pads and track and their clearance area The filled copper area must be computed before BuildFilledSolidAreasPolygons() call this function just after creating the filled copper area polygon (without clearance areas.

Parameters
aPcbthe current board

Definition at line 1633 of file zone_filler.cpp.

References addHatchFillTypeOnZone(), addHoleKnockout(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::BooleanIntersection(), SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::BuildBBoxCaches(), buildCopperItemClearances(), buildThermalSpokes(), SHAPE_POLY_SET::CloneDropTriangulation(), connect_nearby_polys(), SHAPE_POLY_SET::Contains(), SHAPE_POLY_SET::Deflate(), SHAPE_POLY_SET::DeletePolygon(), DUMP_POLYS_TO_COPPER_LAYER, epsilon, SHAPE_POLY_SET::Fracture(), BOARD::GetDesignSettings(), ZONE::GetFillMode(), ZONE::GetMinThickness(), BOX2< Vec >::GetSizeMax(), In10_Cu, In15_Cu, In16_Cu, In17_Cu, In18_Cu, In1_Cu, In2_Cu, In3_Cu, In4_Cu, In5_Cu, In6_Cu, In7_Cu, In8_Cu, In9_Cu, SHAPE_POLY_SET::Inflate(), PROGRESS_REPORTER::IsCancelled(), knockoutThermalReliefs(), m_board, m_debugZoneFiller, BOARD_DESIGN_SETTINGS::m_MaxError, m_maxError, m_progressReporter, BOX2< Vec >::Merge(), EDA_IU_SCALE::mmToIU(), SHAPE_POLY_SET::OutlineCount(), pad, pcbIUScale, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::Polygon(), and subtractHigherPriorityZones().

Referenced by fillSingleZone().

◆ fillNonCopperZone()

◆ fillSingleZone()

bool ZONE_FILLER::fillSingleZone ( ZONE aZone,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aFillPolys 
)
private

Build the filled solid areas polygons from zone outlines (stored in m_Poly) 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) in order to have drawable (and plottable) filled polygons.

Returns
true if OK, false if the solid polygons cannot be built
Parameters
aZoneis the zone to fill
aFillPolysA 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 by aZone->GetMinThickness() / 2 to be drawn with a outline thickness = aZone->GetMinThickness() aFillPolys are polygons that will be drawn on screen and plotted

Definition at line 1971 of file zone_filler.cpp.

References ZONE::BuildSmoothedPoly(), F_Cu, fillCopperZone(), fillNonCopperZone(), LSET::InternalCuMask(), PROGRESS_REPORTER::IsCancelled(), ZONE::IsOnCopperLayer(), m_boardOutline, m_brdOutlinesValid, m_debugZoneFiller, m_progressReporter, ZONE::SetNeedRefill(), and UNDEFINED_LAYER.

Referenced by Fill().

◆ GetProgressReporter()

PROGRESS_REPORTER * ZONE_FILLER::GetProgressReporter ( ) const
inline

Definition at line 46 of file zone_filler.h.

References m_progressReporter.

◆ IsDebug()

bool ZONE_FILLER::IsDebug ( ) const
inline

Definition at line 60 of file zone_filler.h.

References m_debugZoneFiller.

◆ knockoutThermalReliefs()

◆ SetProgressReporter()

void ZONE_FILLER::SetProgressReporter ( PROGRESS_REPORTER aReporter)

Definition at line 215 of file zone_filler.cpp.

References m_commit, and m_progressReporter.

Referenced by DIALOG_GLOBAL_EDIT_TEARDROPS::TransferDataFromWindow().

◆ subtractHigherPriorityZones()

void ZONE_FILLER::subtractHigherPriorityZones ( const ZONE aZone,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aRawFill 
)
private

Removes the outlines of higher-proirity zones with the same net.

These zones should be in charge of the fill parameters within their own outlines.

Definition at line 1516 of file zone_filler.cpp.

References SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::ClearArcs(), BOARD::Footprints(), ZONE::GetAssignedPriority(), ZONE::GetBoundingBox(), m_board, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::PM_FAST, and BOARD::Zones().

Referenced by fillCopperZone().

Member Data Documentation

◆ m_board

◆ m_boardOutline

SHAPE_POLY_SET ZONE_FILLER::m_boardOutline
private

Definition at line 139 of file zone_filler.h.

Referenced by Fill(), and fillSingleZone().

◆ m_brdOutlinesValid

bool ZONE_FILLER::m_brdOutlinesValid
private

Definition at line 140 of file zone_filler.h.

Referenced by Fill(), and fillSingleZone().

◆ m_commit

COMMIT* ZONE_FILLER::m_commit
private

Definition at line 141 of file zone_filler.h.

Referenced by Fill(), and SetProgressReporter().

◆ m_debugZoneFiller

bool ZONE_FILLER::m_debugZoneFiller
private

Definition at line 147 of file zone_filler.h.

Referenced by Fill(), fillCopperZone(), fillSingleZone(), IsDebug(), and ZONE_FILLER().

◆ m_maxError

◆ m_progressReporter

◆ m_worstClearance

int ZONE_FILLER::m_worstClearance
private

Definition at line 145 of file zone_filler.h.

Referenced by buildCopperItemClearances(), Fill(), and knockoutThermalReliefs().


The documentation for this class was generated from the following files: