nmwsharp / geometry-central

Applied 3D geometry in C++, with a focus on surface meshes.
https://geometry-central.net
MIT License
1.08k stars 150 forks source link

reinterpretTo for mesh elements #70

Open MarkGillespie opened 3 years ago

MarkGillespie commented 3 years ago

This is a minor feature request which I've found myself wanting a few times. I wish mesh elements had a reinterpretTo function similar to the mesh data function. For example, I often have a pair of meshes with the same vertex set, and it would be convenient to say

Vertex v1 = // some vertex from mesh1
Vertex v2 = v1.reinterpretTo(mesh2);
keenancrane commented 3 years ago

@nmwsharp and I had discussed how, just like Geometry classes have a hierarchy (intrinsic, extrinsic, embedded…) there really should be a hierarchy for Mesh classes as well. The most basic one would be a VertexSet. On top of this vertex set you can put additional structures, such as Graph (just edges connecting the vertices), FaceSet (basically a vertex-face adjacency data structure), Halfedge, and so on. This way, you could associate multiple different connectivities with the same vertex set, just as we currently associate multiple pieces of MeshData with the same mesh connectivity. For instance, the same VertexSet would sit beneath a point cloud, and a surface mesh triangulated from that point cloud. Likewise, in the context of intrinsic triangulations, you would just have one vertex set, but multiple triangulations (exactly as we think of the mathematical definition). This is of course more than just "nice math": for exactly the reasons @MarkGillespie raises, it's useful and convenient to not have to continuously map between identical vertex sets.

…of course this is a lot to implement / design!