Polygon Triangulation with Holes

前端 未结 9 848
终归单人心
终归单人心 2020-11-30 19:12

I am looking for an algorithm or library (better) to break down a polygon into triangles. I will be using these triangles in a Direct3D application. What are the best availa

相关标签:
9条回答
  • 2020-11-30 19:35

    CGAL has the tool you need: Constrained Triangulations

    You can simply provide boundaries of your polygon (incuding the boundaries of the holes) as constraints (the best would be that you insert all vertices, and then specify the constraints as pairs of Vertex_handles).

    You can then tag the triangles of the triangulation by any traversal algorithm: start with a triangle incident to the infinite vertex and tag it as being outside, and each time you cross a constraint, switch to the opposite tag (inside if you were previously tagging the triangles as outsider, outside if you were tagging triangles as insider before).

    0 讨论(0)
  • 2020-11-30 19:38

    try libtess2

    https://code.google.com/p/libtess2/downloads/list

    based on the original SGI GLU tesselator (with liberal licensing). Solves some memory management issues around lots of small mallocs.

    0 讨论(0)
  • 2020-11-30 19:40

    You can add the holes relatively easily yourself. Basically triangulate to the convex hull of the input points, as per CGAL, and then delete any triangle whose incentre lies inside any of the hole polygons (or outside any of the external boundaries). When dealing with lots of holes in a large dataset, masking techniques may be used to significantly speed this process up.

    edit: A common extension to this technique is to weed weak triangles on the hull, where the longest edge or smallest internal angle exceeds a given value. This will form a better concave hull.

    0 讨论(0)
提交回复
热议问题