Search code examples
graphics3dtriangulationcadtriangle.net

Triangle.NET and touching polygons


How do I triangulate a polygon with an hole like the one below using Triangle.NET?

I need the green area covered by triangles. I guess I need to split the right segment of the outer contour on the touch point but afterward I don't know if I need to combine the two contours into one (with a duplicated point at the black square?) or keep them separated.

Thanks.

enter image description here


Solution

  • In Triangle (which Triangle.NET is just a port of), you define this with connected input segments and specify a "hole" in the domain to clean out the interior triangles that you don't need. I created a ".poly" input file for triangle with a similar geometry:

    8 2 0 0
    1 1.0 1.0
    2 -1.0 1.0
    3 -1.0 -1.0
    4 1.0 -1.0
    5 1.0 0.0
    6 0.5 0.5
    7 0.0 0.0
    8 0.5 -0.5
    9 0
    1 1 2
    2 2 3
    3 3 4
    4 4 5
    5 5 1
    6 5 6
    7 6 7
    8 7 8
    9 8 5
    1
    1 0.5 0.0
    

    The input looks like this

    this.

    You can see the small "x" in the inner box indicating that region is a hole (and will not get triangulated).

    Meshing with triangle gives you something like this

    this

    where you see a domain corresponding to the green area in the post get triangulated.