Best way to include a polyline from the PullCurve method in a mesh?

Hello,
as always: Apologies if this is evident or answered elsewhere.
The method Mesh.PullCurve(…) results in polylines “on” the mesh.
Is there a way in the C# API to remesh the mesh in such a way that these polylines become mesh edges, and its vertices become mesh vertices? In other words, is there a remeshing way that does nothing other than including a polyline of the kind that is output by the PullCurve method, in the mesh?
If not, I guess it would get a little tedious to do manually … one would have to get the closest mesh points and then subdivide all faces, which seems to be a process with some extra cases to take care of.
If the only way is to do it manually: Is there a guarantees that there will be subdivisions of the polyline on edges between faces with differing normals? Edit: Trying it out on simple examples shows that when the mesh is planar, the polyline is just a projection of the discretized input curve onto the plane and it disregards the mesh edges entirely, but when the mesh isn’t planar, the polyline often but not always stays on mesh edges - but that is just empirical evidence. It would be great to understand the polyline better in order to devise a good remeshing strategy.
If possible, I’d like to place as few assumptions on the mesh as possible, for instance it might have non-manifold edges etc.
Thanks, Mathias
The screenshot below shows that the polyline prefers mesh edges but not always. Remeshing strategy: first subdivide edges, then triangles? any better idea/strategy for this?

Hi @mathias.fuchs,

Does the SplitMeshWithCurve do what you want? I believe Mesh.SplitWithProjectedPolylines is the magic behind this.

– Dale

Hello @dale, thanks for the answer, wow yes, that comes very close. Didn’t know about that method. I tried

    PolylineCurve yy = x.PullCurve(y, 1e-4); // where x is the mesh, and y is the curve
    Mesh[] splits = x.SplitWithProjectedPolylines(new List < PolylineCurve > {yy}, 1e-4);
    var result = new Mesh();
    result.Append(splits);

… which produces a mesh like the one below. Technically, that indeed answers the question. The mesh introduces some spurious non-manifold and naked edges, though, and has many almost degenerate triangles. I guess this can be remedied by reducing the resolution / number of subdivisions of the PullCurve. I’ll try and see if I there is a way to thin out the polyline before splitting the mesh with it.


(By the way, the reason why I’m trying to do this is that these curves on the mesh are intended to serve as domains of boundary conditions for color gradients for the tweener package). Thx again.