← Back to team overview

kicad-developers team mailing list archive

Re: PCBNew: Segments/polygons not rendered correctly (from Bug 1806411])


Hi JP-
Am 2018-12-17 08:47, schrieb jp charras:
Note the incorrect rendering happens only when footprints are flipped.

Thank you for the samples. I had coded the tesselation assuming the copper layers, which always have the polygon in CW order for the outline and CCW for the holes. But flipped footprints put the line chain in the reverse order, so they render incorrectly.

I've added some checks for the winding order to the code and re-enabled the polygon caching. Let me know if you see any issues.

I am not familiar with the PolygonTriangulation:: code
and, of course, I can be wrong,
but I am worried by this code in
PolygonTriangulation::TesselatePolygon( const SHAPE_LINE_CHAIN& aPoly )

if the first attempt to tesselate aPoly does not work, a second attempt
is made on a "simplified" polygon, using this code:

ClipperLib::Paths simplified;
ClipperLib::SimplifyPolygon( aPoly.convertToClipper( true ), simplified );

If aPoly is self intersecting it can work, but our polygons are usually
not intersecting, but are polygons with holes linked by overlapping

The second step should never be called on normal polygons. It exists there to solve a specific error created by a third-party footprint generator where they had two, overlapping line chains of the same size, in different order. Normally, we wouldn't add code to handle someone else's error but since it used to work with the OpenGL tesselation and I couldn't _guarantee_ that pcbnew couldn't generate a similar polygon, I added the second step.

You are correct that the simplify code could produce polygon sets with holes. I've corrected this behavior to return the failure up to shape_poly_set for fracturing before trying again.


Follow ups