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:
Seth Hillbrand 2022-08-26 16:41:04 -07:00
parent dbd38882c0
commit 5a37211fdb
2 changed files with 18 additions and 15 deletions

View File

@ -503,8 +503,8 @@ 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 // Convert polygon with holes to a unique polygon
polyset_areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); polyset_areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
@ -519,6 +519,7 @@ void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer )
polyset_holes.RemoveAllContours(); polyset_holes.RemoveAllContours();
main_outline = true; main_outline = true;
} }
}
paths = paths->next; paths = paths->next;
} }

View File

@ -1312,6 +1312,8 @@ int SHAPE_POLY_SET::NormalizeAreaOutlines()
BooleanSubtract( holesBuffer, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); BooleanSubtract( holesBuffer, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
} }
// In degenerate cases, simplify might return no outlines
if( OutlineCount() > 0 )
RemoveNullSegments(); 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;