You say that you have a triangulation method that works in 2D. Good. Place both of your contours on the same plane z = 0
, perform two-dimensional triangulation, then set the z
coordinate of the vertices of the outer contour to the desired value. As you said, move the outer contour into a parallel plane.
Why is this approach not suitable for you?
Yes, you may encounter some horizontal triangles that have all three vertices with the same z
coordinate. If you used "true" three-dimensional triangulation, you can also end up in the same horizontal triangle. It all depends on the shape of the circuit and the algorithm.
If it is unacceptable to have such horizontal triangles, you can add a second pass to try to eliminate them:
Find the horizontal triangle. Its two edges will belong to either the original inner or the original outer contour. The third edge "shorted" the vertices of the original contour. Find another triangle that has the same edge as the "third" edge described above. A pair of these triangles forms a rhombus. There are only two ways to triangulate a rhombus. The one you have is unacceptable, so just reorient the rhombus differently.
It is hard to explain this without pictures.
source share