Blog

What happens when you press Fill: how a PCB editor pours copper

Knock out, connect, thin, prune: the polygon pipeline behind every ground plane.

You draw a rough rectangle on the bottom layer, assign it to GND and press fill. A second later the copper hugs every pad on the board with exactly the right gap, wraps thin spokes round the ground pins, and quietly drops a few scraps you never asked about. It looks like painting. It's actually a pipeline of polygon operations, and every setting in the zone dialog is a knob on one of its passes.

Contents
  1. A pour is a recipe, not a shape
  2. Start from the outline
  3. Knock out everything that isn't yours
  4. Connect your own net: solid or thermal
  5. Thin necks: the minimum width pass
  6. Prune the islands
  7. When two pours overlap
  8. Why filling is slow, and never live
  9. The settings, mapped to the passes
  10. So what is a ground plane, really?
  11. Sources

A pour is a recipe, not a shape

A track is geometry: you put it there and it stays there. A copper pour (KiCad calls it a zone, Altium a polygon pour) is closer to an instruction. It has:

  • an outline you draw, usually roughly;
  • a net it belongs to, usually ground or a power rail;
  • a layer;
  • and a set of rules: clearance, minimum width, how to connect pads, what to do with leftovers, and which pour wins when two overlap.

The copper you actually see, and that ends up in the Gerbers, is the fill. It's computed from the recipe and the board around it. Move a track and the recipe hasn't changed, but the fill is now wrong.

Left: the rough outline you draw for a ground pour. Right: the fill the editor computes, cut around other nets, with thermal spokes on the ground pad and an island removed
What you draw, what gets made

That's why editors keep both. KiCad saves the outline and the last computed fill in the board file, and has a separate command, Fill All Zones (B), to turn one into the other. Altium calls it repouring.

Almost every pass in that command is the same kind of operation: polygon boolean arithmetic. Union, difference, intersection, and offsetting, which grows or shrinks a shape by a fixed distance. Here are the passes in order.

Five passes of a pour fill: start from the outline, knock out other nets with clearance, add thermal spokes to ground pads, remove necks thinner than the minimum width, and drop islands
Five passes from outline to copper

1. Start from the outline

The first pass is cleanup. Keep the copper back from the board edge by the edge clearance, so it never runs up to a routed edge where the cutter would expose it. Subtract any keep-out areas that forbid copper on this layer. If a higher-priority pour sits on the same layer, its copper is an obstacle too (more on that later).

What's left is the region the pour is allowed to occupy. From here on, nearly every pass carves copper away. The exceptions are thermal spokes, and the grow-back half of the minimum-width pass, which only restores copper that was already there.

2. Knock out everything that isn't yours

This is the big one. Every object on the layer that belongs to another net has to be cut out of the pour, with clearance around it: pads, tracks, vias, text, other pours. Holes too, plated or not, because copper can't run up to a drill.

If you read the routing post, the trick will look familiar. To keep a gap of c from a pad, grow the pad by c and subtract the grown shape:

knockout = obstacle grown by c

Growing a shape by a distance is an offset, mathematically a Minkowski sum with a disc. A rectangular pad grows into a rounded rectangle. A track, which is already a centreline grown by half its width, grows into a fatter stadium. A via grows into a bigger circle.

Knockouts: grow every object on another net by its clearance, then subtract the grown shapes from the pour
Grow every foreign object by its clearance, then subtract

Two details make this harder than it sounds.

Clearance isn't one number. The gap depends on the pair: this pour against that net class, a pad against a track, a mains net that needs millimetres against everything. KiCad takes the larger of the zone's own clearance and the net class's, and custom rules can override both. The fill engine has to ask the same rule system as the design rule check (DRC), object by object, because that's the only way the two will agree. When they don't, you get one of the most confusing errors in PCB design: a clearance violation inside copper the tool drew itself.

Curves aren't curves. Polygon libraries work on straight segments, so every arc and circle is approximated by a polygon with a set maximum error. The direction of the error matters. A knockout's approximation has to err outward, sitting slightly outside the true circle, so the clearance is never short by a few microns. A finer approximation means more vertices, and more vertices make every later step slower.

The subtraction itself is a clipping algorithm. The classic general method is Bala Vatti's, from 1992: sweep a line across the plane and resolve every edge crossing as you go. It copes with any polygon, holes and self-intersections included. KiCad uses Angus Johnson's Clipper2, a library based on Vatti's method that also does the offsetting.

And to avoid subtracting every object on the board from every pour, the editor first asks a spatial index for the items whose bounding boxes actually touch the zone.

3. Connect your own net: solid or thermal

Pads on the pour's own net get the opposite treatment. They should join the copper, not be cut out of it, and there are two ways to join.

Solid. The pad merges straight into the pour. It's the lowest resistance and inductance, and the best path for heat and current.

It's also a problem at the soldering iron. A pad fused into a plane is attached to a heatsink, and the solder won't flow until the plane around it is hot.

Through-hole pins on solid connections are the classic cold joint. Small two-pad parts can tombstone when one end sits on a plane and the other on a thin track, because one end melts first.

Thermal relief. Cut the pad out with a small gap anyway, then add narrow spokes back across the gap. KiCad uses four, either along the pad's axes or rotated 45°. The spokes carry the current. The gap slows the heat escaping.

A through-hole ground pad joined to the pour two ways: solid, merged straight into the copper, or with a thermal relief, a gap crossed by four spokes
Same pad, two connections

For the fill engine, a thermal is two more boolean steps:

  1. Subtract the pad grown by the relief gap.
  2. Add the spokes back, keeping only those whose far end lands in pour copper.

The fiddly part is that spokes can still be lost. One that points into a neighbouring knockout, or off the edge of the pour, has nowhere to land. And a later pass can trim away one that's too thin.

Say you designed four spokes and two survive. The pad still looks connected, and still is, through half the copper you designed for. KiCad has a minimum thermal relief spoke count constraint, and DRC flags any pad left with fewer spokes than that minimum.

A common split: thermals for pads, especially through-hole, and solid for vias, since nobody solders to a via.

4. Thin necks: the minimum width pass

After the knockouts, the copper is full of awkward bits. Between two pads whose gap is just over twice the clearance, the pour leaves a ribbon of copper a few tens of microns wide. That's legal geometry but bad copper. It's too thin to etch reliably, and a strip that lifts can wander off and short something. Fabs call these slivers.

The fix is a neat trick borrowed from image processing, called an opening:

  1. Shrink the whole fill by half the minimum width.
  2. Grow it back by the same amount.

opening = grow(shrink(fill, w/2), w/2)

Any part of the copper narrower than w vanishes completely in step 1, so there's nothing left for step 2 to grow back. Everything wider shrinks and then returns to roughly its original shape, though outside corners can come back rounded.

Removing thin necks with an opening: shrink the fill by half the minimum width, then grow it back; the neck narrower than the minimum width does not return
Shrink by half the minimum, grow back: the neck doesn't return

It's the same offset operation as the knockouts, applied to the pour itself. KiCad's zone setting is simply minimum width. Altium calls it Remove Necks, below a width you set.

The opening has a side effect. It can cut a pour in two. If a neck was the only link between two halves of a ground plane, it's gone, and one half is now stranded. Which is exactly what the next pass is for.

5. Prune the islands

Knockouts and necks chop the pour into separate pieces. Some contain a pad, via or track on the pour's net. Others contain nothing: islands, or in Altium's words, dead copper.

Island removal: tracks on other nets cut the pour into three pieces; two contain a ground via or pad and stay, the third touches nothing on ground and is removed
Connected pieces stay, a floating one goes

Finding them is a connectivity question, not a geometry one. For each piece, look for any item of the same net inside it. A piece with no connection is an island.

What happens to them is a setting. KiCad offers always, never, or below area limit; Altium has Remove Dead Copper, though its rules differ in the details. One subtlety: KiCad never removes islands from a zone that has no connection at all, or a pour you've drawn on its own would delete itself.

Removal is the usual default, for good reason. An island isn't connected to anything, so its voltage is set by whatever couples into it. A big floating patch next to a fast edge is a good way to build an antenna. The case for keeping one is copper balance: fabs like copper spread evenly across a layer, because big bare areas plate and etch differently. But the better fix is usually a stitching via, which turns the island back into ground.

A pour isn't drawn. It's what's left after every other net has taken its share.

After the five core passes, a couple of optional ones can run. Smoothing chamfers or fillets the outline's corners. Hatching intersects the fill with a grid of bars instead of leaving it solid, which keeps flex circuits flexible. Hatching makes the minimum width matter more, because every bar is a potential neck. KiCad builds the hatch before the island check, so any pieces the bars cut off get caught there.

When two pours overlap

Say you have ground across the bottom layer and a separate 3.3 V pour under the regulator: two zones on the same layer, overlapping. Who gets the overlap?

Priority. The higher-priority pour fills first. When the lower one fills, the higher one's copper is an obstacle like any other: grown by clearance, knocked out. So the order of filling changes the result, just as the order of routing did for the autorouter.

Two overlapping pours on one layer, GND and 3V3: whichever has the higher priority fills first and keeps the overlap; the other is knocked out round it with clearance
Same two outlines, priority decides the shape

Two pours on the same net don't compete: neither is an obstacle to the other, so their fills generally merge. But for two different-net pours, don't leave the order to chance: set it explicitly. In KiCad it's the order of zones in the Zone Manager.

Why filling is slow, and never live

Count the work. Take a four-layer board with a ground pour on each layer and a few thousand pads and vias, with every round shape turned into a few dozen vertices. That's tens of thousands of shapes to offset and subtract, then an opening across the result, then a connectivity check on every piece. Boolean operations get more expensive as vertex counts climb, and the opening runs over the whole result at once.

Editors claw time back where they can. A spatial index keeps each pour from looking at far-away objects. Zones fill in parallel on a thread pool, except where a lower-priority zone has to wait for a higher one.

Even so, KiCad doesn't refill as you work, and in Altium automatic repour is an option you turn on. On a big board, recalculating the plane on every drag of the cursor would be unusable. So the fill goes stale: the outline is current, the copper isn't. You get pours overlapping tracks they no longer clear, pads that look connected but aren't, and on a bad day, Gerbers plotted from an old fill.

The defences are cheap. Let DRC refill zones before it runs (in KiCad, Refill all zones before performing DRC). Refill before you plot. And treat an out-of-date zone warning as a real error.

The settings, mapped to the passes

Setting Pass If it's wrong
Board-edge clearance Outline Copper exposed or shorted at the routed edge
Clearance Knockouts Too small: shorts and DRC errors. Too big: starved pads, a plane full of holes
Pad connection Thermals Solid: hard soldering, cold joints. Thermal: a weaker current path
Relief gap, spoke width Thermals Spokes too thin for the current, or trimmed away entirely
Minimum width Opening Too small: slivers. Too big: necks cut, the plane falls apart
Remove islands Pruning Floating copper left behind, or useful copper deleted
Priority Overlaps The wrong net wins the shared area

So what is a ground plane, really?

It's a subtraction. You draw the outline; the editor carves out everything that isn't yours, connects what's left, throws away the pieces nothing touches, and hands you the remainder. Every setting decides where one of those cuts falls.

Which is why a fill deserves the same scepticism as an autorouted track. Look at what got cut, especially under dense parts. A ground plane chopped into a lace of thin necks between rows of vias can pass every rule and still not be the return path you meant to give your signals.

Sources

  • B. R. Vatti, A Generic Solution to Polygon Clipping, Communications of the ACM, 1992.
  • A. Johnson, Clipper2: polygon clipping and offsetting library.
  • J. Serra, Image Analysis and Mathematical Morphology, Academic Press, 1982.
  • KiCad PCB Editor documentation: zones, zone priority, board setup constraints and DRC.
  • Altium Designer documentation: polygon pour properties (neck removal, dead copper, pour order).

More posts: Walkaround vs shove, ERC clean is where the checks start, or all posts.

Comments

Questions, corrections and war stories welcome. Sign in with GitHub to comment or react.

Get a board that works.

Describe it in plain English. Every check shows its arithmetic.

Request early access →What it checks