Reputation: 619
I need to generate a triangulated mesh between two or more 3d contour lines. The contour lines are simply an array of points and are always closed.
I've tried using the Poly2Tri library to do a delaunay triangulation, but this doesn't work so great because it only works in 2d, and while I can get it to work in 3d, it doesn't deal with with contour lines that stack vertically (ie: have the same coordinates when the 3rd dimension is discarded)
Does anyone know what sort of algorithm is best to use and ideally an existing library I can use from a c# application?
Upvotes: 2
Views: 1376
Reputation: 121
You can keep using the 2D Delaunay algorithm, but do it between two neighboring layers (z1, z2) each time. (z1 < z2)
Assume contour lines are sampled and stored as a set of (x,y,z) in counter-clockwise order on z-plane. You need to construct a set of boundary/hole points for triangulation:
Do triangulation again for (z2, z3) layer, so on and so forth. Note that the hole/boundary points at z2 remains the same, but if overlapping happens, instead of moving inwards, it's now moving outwards. At the end, combine all triangles into one mesh.
Upvotes: 1