13,047,131 members (59,934 online)
alternative version

#### Stats

176.6K views
23 bookmarked
Posted 6 Feb 2002

# Tesselation of Mono Connected Non Convex Polygon

, 6 Feb 2002
 Rate this:
Tesselation of mono connected non convex polygon

## Introduction

A simple alternative to OpenGL polygon tesselation callback. You can focus on file triangle.h that contain the class to evaluate convexity of polygon and tesselate the polygon. No extra points are inserted. You can work only with planar polygon also in 3D.

Every suggestion in order to speed up the class and create better tesselation ('better' triangles) is appreciated.

## History

• 6th February, 2002: Initial post

## Share

 United States
No Biography provided

## You may also be interested in...

 View All Threads First Prev Next
 Found an index range error in code TruePyroman23-Feb-03 14:38 TruePyroman 23-Feb-03 14:38
 Thank you very much for this example! It's the simple and best tesselation algorithm I found over the internet! I found a special case that pop-up an index range error (very hard to find!!! ) in the Triangulate function. The "k" index missed 2 hits because it starts at k=2... So I did a little patch! New loop: `for( int i=0 , j=1 , k=2 ; k < nVertex+3 ; )` New indexes: ```int ib = i % nVertex;
int jb = j % nVertex;
int kb = k % nVertex;``` Here is the modified function: ```// BEGIN
int nTriangle= 0;
int nVertex = nCount;
//
AllocIndex(nCount);
//
bool bNoErrors = true;
//
while( nVertex > 3 && bNoErrors )
{
//
// tri to remove one vertex...
//
bNoErrors = false;
//
for( int i=0 , j=1 , k=2 ; k < nVertex+3 ; )
{
if( nVertex == 0 )
break;

int ib = i % nVertex;
int jb = j % nVertex;
int kb = k % nVertex;

//
switch( TriangleArea(points,
m_nIndex[ib],
m_nIndex[jb],
m_nIndex[kb],
normal) )
{
//
// ok. flush face && remove vertex j
//
case convex :
//
// Testing containement
//
if( IsAnyPointInside(points,ib,jb,kb,nVertex) ){
//
//
i = j;
j = k;
k++;
}
else
{
nTriangle++;
//
// remove vertex j
//
nVertex = RemoveVertex(jb, nVertex);
bNoErrors= true;
}
break;
case concave :
//
//
i = j;
j = k;
k++;
break;
case degenerate :
//
// remove vertex j
//
nVertex = RemoveVertex(jb, nVertex);
bNoErrors= true;
break;
}
}
}
return nTriangle;

// END``` TruePyroman
 Re: Found an index range error in code topus10-Apr-03 2:46 topus 10-Apr-03 2:46
 Last Visit: 31-Dec-99 18:00     Last Update: 24-Jul-17 0:15 Refresh 1

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Web02 | 2.8.170713.1 | Last Updated 7 Feb 2002
Article Copyright 2002 by Peppino Sbargzeguti