tesselation: Re-check polygon count after fracturing

The fracture() call may result in zero polygons remaining, which will
cause failure in our tesselation routine, so we need to check whether
this is a valid POLYGON before re-tesselating.
This commit is contained in:
Seth Hillbrand 2018-12-18 17:22:32 -07:00
parent e5f5443762
commit 64f1fb9e79
2 changed files with 5 additions and 3 deletions

View File

@ -1882,11 +1882,15 @@ void SHAPE_POLY_SET::CacheTriangulation()
{
tmpSet.Fracture( PM_FAST );
if( !tess.TesselatePolygon( tmpSet.Polygon( i ).front() ) )
// After fracturing, we may have zero or one polygon
// Check for zero polygons before tesselating and break regardless
if( !tmpSet.OutlineCount() || !tess.TesselatePolygon( tmpSet.Polygon( i ).front() ) )
{
m_triangulatedPolys.pop_back();
m_triangulationValid = false;
}
break;
}
}

View File

@ -649,8 +649,6 @@ public:
bool TesselatePolygon( const SHAPE_LINE_CHAIN& aPoly )
{
ClipperLib::Clipper c;
m_bbox = aPoly.BBox();
m_result.Clear();