From 64f1fb9e792ceadb29cb19692ad583d8c432b19c Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 18 Dec 2018 17:22:32 -0700 Subject: [PATCH] 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. --- common/geometry/shape_poly_set.cpp | 6 +++++- include/geometry/polygon_triangulation.h | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/geometry/shape_poly_set.cpp b/common/geometry/shape_poly_set.cpp index a00a903d1a..3dd21d32aa 100644 --- a/common/geometry/shape_poly_set.cpp +++ b/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; } } diff --git a/include/geometry/polygon_triangulation.h b/include/geometry/polygon_triangulation.h index 335eee49da..b419b45c6f 100644 --- a/include/geometry/polygon_triangulation.h +++ b/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();