Pcbnew: polygon boolean subtraction - allow holes

The problem was using outlines, not the UnitSet function.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/19348
This commit is contained in:
John Beard 2025-07-09 19:02:45 +08:00
parent 33a4d6ea6f
commit 563bb7a538

View File

@ -527,7 +527,8 @@ void POLYGON_BOOLEAN_ROUTINE::Finalize()
std::unique_ptr<PCB_SHAPE> new_poly_shape =
std::make_unique<PCB_SHAPE>( GetBoard(), SHAPE_T::POLY );
SHAPE_POLY_SET poly_set = m_workingPolygons.Outline( i );
SHAPE_POLY_SET poly_set = m_workingPolygons.UnitSet( i );
new_poly_shape->SetPolyShape( poly_set );
// Copy properties from the source polygon
@ -587,16 +588,6 @@ bool POLYGON_SUBTRACT_ROUTINE::ProcessSubsequentPolygon( const SHAPE_POLY_SET& a
SHAPE_POLY_SET working_copy = working_polygons;
working_copy.BooleanSubtract( aPolygon );
// Subtraction can create holes or delete the polygon
// In theory we can allow holes as the EDA_SHAPE will fracture for us, but that's
// probably not what the user has in mind (?)
if( working_copy.OutlineCount() != 1 || working_copy.HoleCount( 0 ) > 0
|| working_copy.VertexCount( 0 ) == 0 )
{
// If that happens, just skip the operation
return false;
}
working_polygons = std::move( working_copy );
return true;
}