GeometryCollective / boundary-first-flattening

MIT License
768 stars 96 forks source link

Vector subscript is out of range exception. PolygonSoup.cpp. #90

Closed artemishenkov closed 1 year ago

artemishenkov commented 1 year ago

Hello, I have successfully built bff(main) library and ran bff-command-line application with hemisphere.obj file from the input folder and got the error 'Vector subscript is out of range exception' in two methods:

  1. VertexAdjacencyMaps::insert(int nV, std::vector<std::pair<int, int>>& vertexPairs)
  2. EdgeFaceAdjacencyMap::insert(const VertexAdjacencyMaps& vertexAdjacency, std::vector<std::pair<int, int>>& edgeFacePairs)

Because somehow j variable becomes bigger than the vector size.

My first thought was that I built something wrong but then I updated the while loop with condition j < edgeFacePairs.size() and j < vertexPairs.size() for another insert method and after that I got a nice result. image

rohan-sawhney commented 1 year ago

Hi, thanks for bringing this up. I'll try to have it fixed soon. I am noticing that in some cases, j ends up equaling vertexPairs.size() which shouldn't happen, but this only happens with non-manifold meshes. Weirdly enough, I wasn't able to reproduce this behavior with hemisphere.obj as you mention. I also didn't notice this behavior with EdgeFaceAdjacencyMap::insert, only with VertexAdjacencyMaps::insert.

If you have any more insights, that would be great to know. Thanks!

artemishenkov commented 1 year ago

Hi @rohan-sawhney, thank you for your quick response. I have tested it with maze.obj also and got the same problem. I am going to test the library with different drawings and let you know if I find something else. Thanks!

rohan-sawhney commented 1 year ago

@artemishenkov I just pushed a fix to master, though the binaries aren't updated yet. I'd be grateful if you could let me know whether the latest commit fixes the issue. Thanks for pointing out the bug!

artemishenkov commented 1 year ago

@rohan-sawhney I have just tested your new fix and it works just fine, with no errors, thank you for this quick fix!