Skip to content

Fix cropZoneByPolygon to return separate zones #911

Open
AvetosDesign wants to merge 1 commit into
yaqwsx:masterfrom
AvetosDesign:fix/crop-zone-multipolygon-split
Open

Fix cropZoneByPolygon to return separate zones #911
AvetosDesign wants to merge 1 commit into
yaqwsx:masterfrom
AvetosDesign:fix/crop-zone-multipolygon-split

Conversation

@AvetosDesign

Copy link
Copy Markdown

When a zone's outline extends outside the board boundary and the intersection of that zone with the board polygon produces multiple disconnected pieces (MultiPolygon), the previous code packed all pieces into a single zone's SHAPE_POLY_SET via multiple AddOutline calls.

This caused problems downstream: a multi-outline zone has one centroid (potentially outside any individual piece), KiCad's zone fill engine does not reliably handle multi-outline zones, and collectZones' bounding-box centroid filter could silently drop pieces whose centroids fell outside the expected area.

The function's own docstring already stated "If the zone is split into multiple zones, return all of them" but the return type was None and no zones were ever returned.

Fix: when the intersection is a MultiPolygon, return one Duplicate() of the input zone per piece, each with a single outline. The single-polygon case continues to modify the zone in place and return [zone]. The one call site in appendBoard is updated to iterate the returned list.

…sections

When a zone's outline extends outside the board boundary and the
intersection of that zone with the board polygon produces multiple
disconnected pieces (MultiPolygon), the previous code packed all pieces
into a single zone's SHAPE_POLY_SET via multiple AddOutline calls.

This caused problems downstream: a multi-outline zone has one centroid
(potentially outside any individual piece), KiCad's zone fill engine does
not reliably handle multi-outline zones, and collectZones' bounding-box
centroid filter could silently drop pieces whose centroids fell outside
the expected area.

The function's own docstring already stated "If the zone is split into
multiple zones, return all of them" but the return type was None and no
zones were ever returned.

Fix: when the intersection is a MultiPolygon, return one Duplicate() of
the input zone per piece, each with a single outline. The single-polygon
case continues to modify the zone in place and return [zone]. The one
call site in appendBoard is updated to iterate the returned list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants