PJDIXIT

04-16-2012, 07:28 PM

I came across this issue when I was trying to triangulate Text entities using GLUtesselator. However, it can occur during triangulation of any polygon using GLUtesselator. The problem is that sometimes GLUtesselator generates zero-area triangles. Most of the times you can ignore them but there are cases where they can’t be ignored. I am trying to find a solution so that final triangulation of a given polygon do not have any zero-area triangles or T-intersections. As far as I know, GLUtesselator is one of the most robust and stable tesselator available so I would like to stick to it and won’t mind doing some post-processing to fix the triangulation rather than writing a new tesselator myself.

I will try to demonstrate the problem with tessellation of character ‘H’. Input vertices to the GLUtesselator are:

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_input.jpg

Vertex |x |y |z |Edge flag

------------------------------------------

V1 |298 |381 |0 |True

V2 |298 |0 |0 |True

V3 |266 |0 |0 |True

V4 |266 |185 |0 |True

V5 |32 |185 |0 |True

V6 |32 |0 |0 |True

V7 |0 |0 |0 |True

V8 |0 |381 |0 |True

V9 |32 |381 |0 |True

V10 |32 |212 |0 |True

V11 |266 |212 |0 |True

V12 |266 |381 |0 |True

This is how it was triangulated using GLUtesselator. I set the winding to GLU_TESS_WINDING_ODD and GLU_TESS_TOLERANCE was set to default 0.

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_Tesselation4.jpg

After preliminary inspection of the triangulation, it seemed as if there were T-intersections at vertex 5 and 10 which raised a red flag as the geometry was further processed by half-edge data structure and T-intersections were not allowed.

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_T-Intersection2.jpg

However, generating the list of triangles showed that tessellation actually generated zero-area triangles and not T-intersections. Here is the list of generated triangles:

Triangle | Vertex indices | Edge flags |Comment

----------------------------------------------

T1 | (1, 11, 12) |(F, T, T) |

T2 | (11, 1, 4) | (F, F, F) |

T3 | (4, 1, 3) | (F, F, T) |

T4 | (3, 1, 2) | (F, T, T) |

T5 | (11, 5, 10) | (F, F, T) |

T6 | (5, 11, 4) | (F, F, T) |

T7 | (9, 7, 8) | (F, T, T) |

T8 | (7, 9, 6) | (F, F, T) |

T9 | (6, 9, 10) | (F, T, F) |Zero-area

T10 | (6, 10, 5) | (F, F, T) |Zero-area

Legend : T = True , F = False

The problem is that I can’t use zero-area triangles either as I can’t calculate normal or equation of plane correctly for zero-area triangles. Normals and equation of planes can be very critical for implementing smoothing and shadow generation algorithms so they need to have a valid value.

So, I am stuck here with a very bad situation: If I have zero-area triangles then I can’t calculate normal and equation of plane correctly which is a must. It is trivial to remove zero-area triangles but if I remove them then I am stuck with T-intersections and I can’t live with them either.

So I would like to make sure that in cases where GLUtesselator generates zero-area triangles, my application will re-triangulate a sub-portion of the polygon such that there are no zero-area triangles or T-intersections. For our example case, triangulation should look some thing like this:

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_Wanted_Tesselation1.jpg

I think its a very fundamental problem and a solution to it will benefit lot of developers working in a similar area. I am sure I am not the first one to stumble upon it. Any suggestions how it can be done? Any alternate approach is very welcome as well.

If you have trouble reading the tables clearly, you can also check this post at GLUtesselator : Issues with zero-area triangles and T-intersections (http://dixittech.com/blog)

-Prasad

I will try to demonstrate the problem with tessellation of character ‘H’. Input vertices to the GLUtesselator are:

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_input.jpg

Vertex |x |y |z |Edge flag

------------------------------------------

V1 |298 |381 |0 |True

V2 |298 |0 |0 |True

V3 |266 |0 |0 |True

V4 |266 |185 |0 |True

V5 |32 |185 |0 |True

V6 |32 |0 |0 |True

V7 |0 |0 |0 |True

V8 |0 |381 |0 |True

V9 |32 |381 |0 |True

V10 |32 |212 |0 |True

V11 |266 |212 |0 |True

V12 |266 |381 |0 |True

This is how it was triangulated using GLUtesselator. I set the winding to GLU_TESS_WINDING_ODD and GLU_TESS_TOLERANCE was set to default 0.

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_Tesselation4.jpg

After preliminary inspection of the triangulation, it seemed as if there were T-intersections at vertex 5 and 10 which raised a red flag as the geometry was further processed by half-edge data structure and T-intersections were not allowed.

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_T-Intersection2.jpg

However, generating the list of triangles showed that tessellation actually generated zero-area triangles and not T-intersections. Here is the list of generated triangles:

Triangle | Vertex indices | Edge flags |Comment

----------------------------------------------

T1 | (1, 11, 12) |(F, T, T) |

T2 | (11, 1, 4) | (F, F, F) |

T3 | (4, 1, 3) | (F, F, T) |

T4 | (3, 1, 2) | (F, T, T) |

T5 | (11, 5, 10) | (F, F, T) |

T6 | (5, 11, 4) | (F, F, T) |

T7 | (9, 7, 8) | (F, T, T) |

T8 | (7, 9, 6) | (F, F, T) |

T9 | (6, 9, 10) | (F, T, F) |Zero-area

T10 | (6, 10, 5) | (F, F, T) |Zero-area

Legend : T = True , F = False

The problem is that I can’t use zero-area triangles either as I can’t calculate normal or equation of plane correctly for zero-area triangles. Normals and equation of planes can be very critical for implementing smoothing and shadow generation algorithms so they need to have a valid value.

So, I am stuck here with a very bad situation: If I have zero-area triangles then I can’t calculate normal and equation of plane correctly which is a must. It is trivial to remove zero-area triangles but if I remove them then I am stuck with T-intersections and I can’t live with them either.

So I would like to make sure that in cases where GLUtesselator generates zero-area triangles, my application will re-triangulate a sub-portion of the polygon such that there are no zero-area triangles or T-intersections. For our example case, triangulation should look some thing like this:

http://www.dixittech.com/blog/wp-content/uploads/2012/04/H_Wanted_Tesselation1.jpg

I think its a very fundamental problem and a solution to it will benefit lot of developers working in a similar area. I am sure I am not the first one to stumble upon it. Any suggestions how it can be done? Any alternate approach is very welcome as well.

If you have trouble reading the tables clearly, you can also check this post at GLUtesselator : Issues with zero-area triangles and T-intersections (http://dixittech.com/blog)

-Prasad