I have a 3D triangle mesh. A curve is found by some algorithm. The curve does not pass through the edges of the mesh. The curve intersects the edges of the mesh, the locations of which are given (P0, P1, P2 in image below).
In the image provided below, the input curve is denoted in red. The desired output passing through the edges is denoted by yellow. The output should not pass through any face of the mesh.
My approach: I tried to find nearest neighbour in the set of mesh vertices for every point in the input curve and draw the edge between them. However this results in curves which sometimes pass through a face of the mesh. The second approach which I could think of is using barycentric coordinates of each of the input points and then map them to the point on the mesh which is closest to the point on the corresponding edge. For example point P1 in image would get mapped to the nearest vertex along the edge on which P1 lies.
My question is How to approximate the curve by a set of continuous edges of the mesh. The output curve should not pass through any face of the mesh. Is there any algorithm which does the same?
