pcb-rnd knowledge pool

 

Polygon lib bug #1 and workaround

polybug1 by Tibor 'Igor2' Palinkas on 2018-02-25

Tags: insight, polygon, bug, arc, line, clearance, intersection, rounding, error

node source

 

 

Abstract: Our polygon lib approximates arcs with lines in polygon contours and calculates the union of complex cutout shapes. This can go wrong, e.g. because of rounding errors. One of the bugs and the workaround is demonstrated.

  The clearance cutout of the non-axis aligned line is a straight line, which barely touches the circular cutout of the lower via on the following example board :

example board render

But they indeed touch, or even, overlap. This results two sharp spikes to be generated as the clipped contour of the polyong. The upper one ("v" shaped) looks like this when zoomed in, circled in red:

clipping generated 'v' shaped spike in polygon contour

In theory the spike ends in two lines that have similar, but not matching angles. More specifically, the spike ends in a single pont, where the two endpoints of the lines sit on the very same point (same, to the nanometer). This is demonstrated on the left of the following drawing:

line crosing error

Unfortunately there is a bug somewhere deep in the polygon boolean algebra code that subtracts the line clearance and the via clearance (circle) from the polygon so the resulting lines don't fully connect. Instead they cross a 3..6 nanometers away from the intended endpoint, as shown on the right side of the above drawing.

We are not going to debug or fix this before the polygon lib rewrite. Instead, as a temporary workaround , I've relaxed the contour check code so that it accepts at most 10 nanometers of error on such line endpoints (instead of the 10^-8 nanometer floating point EPSILON we should use).

(To trigger the bug, compile pcb-rnd r14968 with --debug, open trigger.lht and delete the upper via. This will force a poly reclip that will bump into self intersecting contour.)