nmwsharp / geometry-central

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

"Assertion failed: mesh != nullptr" when alling VertexPositionGeometry::vertexIndices but not with Vertex::getIndex() #161

Closed Fletterio closed 1 year ago

Fletterio commented 1 year ago

I'm losing my mind trying to understand what's going on. I'm following CMU's DDG course: https://github.com/GeometryCollective/ddg-exercises

In the first project (simplicial-complex-operators) the cpp clearly states that one should use (since it's safer and potentially faster) the VertexPositionGeometry::vertexIndices (or edge, face, etc) method for recovering a simplex's label instead of using Vertex::getIndex method

If I compile and run the project as is, it runs. If somewhere in the project I call the VertexPositionGeometry::vertexIndices method to retrieve a vertex's label, the assertion in the title fails and I don't know why. It doesn't happen if I instead use Vertex::getIndex.

Why is this? The reason I'm asking this here is because this question would seem specific to how geometrycentral initializes meshes and not a bug in that project's code