Browse Source

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.
pull/13/head
Seth Hillbrand 7 years ago
parent
commit
64f1fb9e79
  1. 6
      common/geometry/shape_poly_set.cpp
  2. 2
      include/geometry/polygon_triangulation.h

6
common/geometry/shape_poly_set.cpp

@ -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;
}
}

2
include/geometry/polygon_triangulation.h

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

Loading…
Cancel
Save