KiCad PCB EDA Suite
Loading...
Searching...
No Matches
zone_filler.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014-2017 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Tomasz Włostowski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef ZONE_FILLER_H
23#define ZONE_FILLER_H
24
25#include <map>
26#include <mutex>
27#include <vector>
28#include <zone.h>
30
32class BOARD;
33class COMMIT;
35
36
38{
39public:
40 ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit );
42
43 void SetProgressReporter( PROGRESS_REPORTER* aReporter );
45
56 bool Fill( const std::vector<ZONE*>& aZones, bool aCheck = false, wxWindow* aParent = nullptr );
57
58 bool IsDebug() const { return m_debugZoneFiller; }
59
60private:
61
62 void addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap, SHAPE_POLY_SET& aHoles );
63
64 void addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap, bool aIgnoreLineWidth,
65 SHAPE_POLY_SET& aHoles );
66
67 void addHoleKnockout( PAD* aPad, int aGap, SHAPE_POLY_SET& aHoles );
68
69 void knockoutThermalReliefs( const ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aFill,
70 std::vector<BOARD_ITEM*>& aThermalConnectionPads, std::vector<PAD*>& aNoConnectionPads,
71 std::vector<BOARD_ITEM*>& aSolidConnectionItems );
72
73 void buildCopperItemClearances( const ZONE* aZone, PCB_LAYER_ID aLayer,
74 const std::vector<PAD*>& aNoConnectionPads,
75 SHAPE_POLY_SET& aHoles,
76 bool aIncludeZoneClearances = true );
77
82 void buildDifferentNetZoneClearances( const ZONE* aZone, PCB_LAYER_ID aLayer,
83 SHAPE_POLY_SET& aHoles );
84
85 void subtractHigherPriorityZones( const ZONE* aZone, PCB_LAYER_ID aLayer,
86 SHAPE_POLY_SET& aRawFill );
87
99 bool fillCopperZone( const ZONE* aZone, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer,
100 const SHAPE_POLY_SET& aSmoothedOutline,
101 const SHAPE_POLY_SET& aMaxExtents, SHAPE_POLY_SET& aFillPolys );
102
103 bool fillNonCopperZone( const ZONE* candidate, PCB_LAYER_ID aLayer,
104 const SHAPE_POLY_SET& aSmoothedOutline, SHAPE_POLY_SET& aFillPolys );
109 void buildThermalSpokes( const ZONE* box, PCB_LAYER_ID aLayer,
110 const std::vector<BOARD_ITEM*>& aSpokedPadsList,
111 std::deque<SHAPE_LINE_CHAIN>& aSpokes );
112
121 void buildHatchZoneThermalRings( const ZONE* aZone, PCB_LAYER_ID aLayer,
122 const SHAPE_POLY_SET& aSmoothedOutline,
123 const std::vector<BOARD_ITEM*>& aThermalConnectionPads,
124 SHAPE_POLY_SET& aFillPolys,
125 SHAPE_POLY_SET& aThermalRings );
126
132 void connect_nearby_polys( SHAPE_POLY_SET& aPolys, double aDistance );
133
146 bool fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aFillPolys );
147
157 bool addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer,
158 SHAPE_POLY_SET& aFillPolys,
159 const SHAPE_POLY_SET& aThermalRings );
160
176 bool addCopperThievingPattern( const ZONE* aZone, PCB_LAYER_ID aLayer,
177 SHAPE_POLY_SET& aFillPolys );
178
184 void postKnockoutMinWidthPrune( const ZONE* aZone, SHAPE_POLY_SET& aFillPolys );
185
189 using FillSnapshot = std::map<std::pair<const ZONE*, PCB_LAYER_ID>, SHAPE_POLY_SET>;
190
200 bool refillZoneFromCache( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aFillPolys,
201 const FillSnapshot* aSnapshot = nullptr );
202
204 SHAPE_POLY_SET m_boardOutline; // the board outlines, if exists
205 bool m_brdOutlinesValid; // true if m_boardOutline is well-formed
208
211
213
214 // Cache of pre-knockout fills for iterative refill optimization (issue 21746)
215 // Key: (zone pointer, layer), Value: fill polygon before higher-priority zone knockout
216 std::map<std::pair<const ZONE*, PCB_LAYER_ID>, SHAPE_POLY_SET> m_preKnockoutFillCache;
217 mutable std::mutex m_cacheMutex;
218};
219
220#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
Definition pad.h:61
A progress reporter interface for use in multi-threaded environments.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
COMMIT * m_commit
void buildCopperItemClearances(const ZONE *aZone, PCB_LAYER_ID aLayer, const std::vector< PAD * > &aNoConnectionPads, SHAPE_POLY_SET &aHoles, bool aIncludeZoneClearances=true)
Removes clearance from the shape for copper items which share the zone's layer but are not connected ...
int m_worstClearance
bool m_debugZoneFiller
void buildHatchZoneThermalRings(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aSmoothedOutline, const std::vector< BOARD_ITEM * > &aThermalConnectionPads, SHAPE_POLY_SET &aFillPolys, SHAPE_POLY_SET &aThermalRings)
Build thermal rings for pads in hatch zones.
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 oth...
void knockoutThermalReliefs(const ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aFill, std::vector< BOARD_ITEM * > &aThermalConnectionPads, std::vector< PAD * > &aNoConnectionPads, std::vector< BOARD_ITEM * > &aSolidConnectionItems)
Removes thermal reliefs from the shape for any pads connected to the zone.
void buildThermalSpokes(const ZONE *box, PCB_LAYER_ID aLayer, const std::vector< BOARD_ITEM * > &aSpokedPadsList, std::deque< SHAPE_LINE_CHAIN > &aSpokes)
Function buildThermalSpokes Constructs a list of all thermal spokes for the given zone.
void buildDifferentNetZoneClearances(const ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aHoles)
Build clearance knockout holes for higher-priority zones on different nets.
std::map< std::pair< const ZONE *, PCB_LAYER_ID >, SHAPE_POLY_SET > FillSnapshot
Snapshot of zone fill polygons captured before an iterative refill wave.
ZONE_FILLER(BOARD *aBoard, COMMIT *aCommit)
void subtractHigherPriorityZones(const ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aRawFill)
Removes the outlines of higher-proirity zones with the same net.
void addKnockout(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aGap, SHAPE_POLY_SET &aHoles)
Add a knockout for a pad or via.
SHAPE_POLY_SET m_boardOutline
std::map< std::pair< const ZONE *, PCB_LAYER_ID >, SHAPE_POLY_SET > m_preKnockoutFillCache
bool m_brdOutlinesValid
void SetProgressReporter(PROGRESS_REPORTER *aReporter)
std::mutex m_cacheMutex
PROGRESS_REPORTER * GetProgressReporter() const
Definition zone_filler.h:44
BOARD * m_board
PROGRESS_REPORTER * m_progressReporter
bool refillZoneFromCache(ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aFillPolys, const FillSnapshot *aSnapshot=nullptr)
Refill a zone from cached pre-knockout fill.
bool addCopperThievingPattern(const ZONE *aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aFillPolys)
Stamp a regular grid of pattern shapes onto a zone's filled area for copper thieving.
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 co...
void addHoleKnockout(PAD *aPad, int aGap, SHAPE_POLY_SET &aHoles)
Add a knockout for a pad's hole.
bool fillNonCopperZone(const ZONE *candidate, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aSmoothedOutline, SHAPE_POLY_SET &aFillPolys)
void postKnockoutMinWidthPrune(const ZONE *aZone, SHAPE_POLY_SET &aFillPolys)
Remove minimum-width violations introduced by zone-to-zone knockouts.
bool addHatchFillTypeOnZone(const ZONE *aZone, PCB_LAYER_ID aLayer, PCB_LAYER_ID aDebugLayer, SHAPE_POLY_SET &aFillPolys, const SHAPE_POLY_SET &aThermalRings)
for zones having the ZONE_FILL_MODE::ZONE_FILL_MODE::HATCH_PATTERN, create a grid pattern in filled a...
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 mo...
bool Fill(const std::vector< ZONE * > &aZones, bool aCheck=false, wxWindow *aParent=nullptr)
Fills the given list of zones.
bool IsDebug() const
Definition zone_filler.h:58
Handle a list of polygons defining a copper zone.
Definition zone.h:70
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56