Polygon triangulation: Check for broken remainders
If the last three points of a tesselation are concave, we will never be able to triangulate them. They were likely formed from a bad polygon, so we will drop the triangle and return completed Fixes https://gitlab.com/kicad/code/kicad/issues/9380
This commit is contained in:
parent
35e90d0cf4
commit
c1e6fdfb47
|
@ -468,6 +468,15 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
// Check to see if we are left with only three points in the polygon
|
||||
if( aPoint->next && aPoint->prev == aPoint->next->next )
|
||||
{
|
||||
// Three concave points will never be able to be triangulated because they were
|
||||
// created by an intersecting polygon, so just drop them.
|
||||
if( area( aPoint->prev, aPoint, aPoint->next ) >= 0 )
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point, our polygon should be fully tessellated.
|
||||
*/
|
||||
|
|
|
@ -2378,6 +2378,10 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition )
|
|||
|
||||
while( tmpSet.OutlineCount() > 0 )
|
||||
{
|
||||
|
||||
if( !m_triangulatedPolys.empty() && m_triangulatedPolys.back()->GetTriangleCount() == 0 )
|
||||
m_triangulatedPolys.erase( m_triangulatedPolys.end() - 1 );
|
||||
|
||||
m_triangulatedPolys.push_back( std::make_unique<TRIANGULATED_POLYGON>() );
|
||||
PolygonTriangulation tess( *m_triangulatedPolys.back() );
|
||||
|
||||
|
|
Loading…
Reference in New Issue