Handle cases where Simplify removes all outlines
This could theoretically happen for a fully degenerate polygon Fixes https://gitlab.com/kicad/code/kicad/issues/12120
This commit is contained in:
parent
dbd38882c0
commit
5a37211fdb
|
@ -503,21 +503,22 @@ void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer )
|
||||||
polyset_areas.BooleanSubtract( polyset_holes, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
polyset_areas.BooleanSubtract( polyset_holes, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||||
|
|
||||||
// Ensure there are no self intersecting polygons
|
// Ensure there are no self intersecting polygons
|
||||||
polyset_areas.NormalizeAreaOutlines();
|
if( polyset_areas.NormalizeAreaOutlines() )
|
||||||
|
|
||||||
// Convert polygon with holes to a unique polygon
|
|
||||||
polyset_areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
|
||||||
|
|
||||||
// Output current resulting polygon(s)
|
|
||||||
for( int ii = 0; ii < polyset_areas.OutlineCount(); ii++ )
|
|
||||||
{
|
{
|
||||||
SHAPE_LINE_CHAIN& poly = polyset_areas.Outline( ii );
|
// Convert polygon with holes to a unique polygon
|
||||||
outputOnePolygon( poly, getBoardLayerName( aModLayer ));
|
polyset_areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||||
}
|
|
||||||
|
|
||||||
polyset_areas.RemoveAllContours();
|
// Output current resulting polygon(s)
|
||||||
polyset_holes.RemoveAllContours();
|
for( int ii = 0; ii < polyset_areas.OutlineCount(); ii++ )
|
||||||
main_outline = true;
|
{
|
||||||
|
SHAPE_LINE_CHAIN& poly = polyset_areas.Outline( ii );
|
||||||
|
outputOnePolygon( poly, getBoardLayerName( aModLayer ));
|
||||||
|
}
|
||||||
|
|
||||||
|
polyset_areas.RemoveAllContours();
|
||||||
|
polyset_holes.RemoveAllContours();
|
||||||
|
main_outline = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paths = paths->next;
|
paths = paths->next;
|
||||||
|
|
|
@ -1312,7 +1312,9 @@ int SHAPE_POLY_SET::NormalizeAreaOutlines()
|
||||||
BooleanSubtract( holesBuffer, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
BooleanSubtract( holesBuffer, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveNullSegments();
|
// In degenerate cases, simplify might return no outlines
|
||||||
|
if( OutlineCount() > 0 )
|
||||||
|
RemoveNullSegments();
|
||||||
|
|
||||||
return OutlineCount();
|
return OutlineCount();
|
||||||
}
|
}
|
||||||
|
@ -1608,7 +1610,7 @@ int SHAPE_POLY_SET::RemoveNullSegments()
|
||||||
|
|
||||||
ITERATOR iterator = IterateWithHoles();
|
ITERATOR iterator = IterateWithHoles();
|
||||||
|
|
||||||
VECTOR2I contourStart = *iterator;
|
VECTOR2I contourStart = *NormalizeAreaOutlinesiterator;
|
||||||
VECTOR2I segmentStart, segmentEnd;
|
VECTOR2I segmentStart, segmentEnd;
|
||||||
|
|
||||||
VERTEX_INDEX indexStart;
|
VERTEX_INDEX indexStart;
|
||||||
|
|
Loading…
Reference in New Issue