Drape 2d line onto 3d mesh

Thanks for the opinions in advance.

I have a 2d line that I want to draw onto a 3d surface (a vertical drape, so the vertex x/y are constant, and the elevation of each vertex is adjusted to surface). I am currently adding a large number of vertexes, and using octrees to find the pertinent face, and pull an elevation by raycasting onto the face.

It occurs to me that a better alternative would be to “walk” over the faces, adding a point wherever two different faces touch.

This seems like something that has probably already been done, but I can’t seem to find anything by googling. Any advice?

Here is a picture of the desired result.

image

Hi!
Could you provide a picture of the desired result?

What about flattenning your tin elevations. Then raycast to find all intersected edges. Once you have the edge and the intersection position you can unflatten and find 3d point? Only issue will be with overhanges