tesselate: Check for non-polygons

Elements with only 0, 1 or 2 vertices cannot form valid polygons, so do
not attempt to tesselate them.
This commit is contained in:
Seth Hillbrand 2018-12-15 17:11:21 -07:00
parent fc69e6532c
commit 98d6d68e2d
1 changed files with 11 additions and 8 deletions

View File

@ -619,13 +619,16 @@ public:
if( !m_bbox.GetWidth() || !m_bbox.GetHeight() )
return;
Vertex* outerNode = createList( aPoly );
if( !outerNode )
/// Place the polygon Vertices into a circular linked list
/// and check for lists that have only 0, 1 or 2 elements and
/// therefore cannot be polygons
Vertex* firstVertex = createList( aPoly );
if( !firstVertex || firstVertex->prev == firstVertex->next )
return;
outerNode->updateList();
firstVertex->updateList();
if( !earcutList( outerNode ) )
if( !earcutList( firstVertex ) )
{
m_vertices.clear();
m_result.Clear();
@ -635,13 +638,13 @@ public:
for( auto path : simplified )
{
outerNode = createList( path );
firstVertex = createList( path );
if( !outerNode )
if( !firstVertex )
return;
outerNode->updateList();
earcutList( outerNode );
firstVertex->updateList();
earcutList( firstVertex );
}
}