nmwsharp / geometry-central

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

Mismatch between uncompressed SurfaceMesh::nCorners() and CornerData::size() #188

Open HendrikBrueckler opened 1 week ago

HendrikBrueckler commented 1 week ago

Hi :) I encountered a small issue trying to use geometry-central with polyscope.

Currently SurfaceMesh::nCorners() returns nInteriorHalfedgesCount whereas the capacity check for CornerData uses nHalfedgesCapacity. On a compressed mesh with boundary, the two don't match; bigger CornerData buffers than necessary are allocated and CornerData::size() is larger than SurfaceMesh::nCorners() .

For compressed meshes with boundary this creates issues when trying to combine geometry-central with polyscope and trying to add a corner-based parameterization from geometry-central as a property to the polyscope-mesh (polyscope essentially expects a buffer of size nInteriorHalfedgesCount).

I would expect that intended behaviour here is that exterior halfedges do not contribute to "corners" and CornerData capacity should actually be equal to nInteriorHalfedgesCount for a compressed mesh?

HendrikBrueckler commented 1 week ago

I see now that you are supposed to use permutations for interfacing with polyscope, and that the 1-to-1 mapping of corners to halfedges is probably just the least cumbersome way to implement corner-based properties for modifiable polygonal meshes, despite the memory overhead.

I guess this can be closed, unless someone sees actual benefit in making CornerData::size() fit SurfaceMesh::nCorners() tightly.