geometry-central
geometry-central copied to clipboard
GC reports nonmanifold mesh when mesh is just not oriented consistently
GC will report that a mesh is nonmanifold even in cases where it is manifold, but the faces are not consistently aligned.
Level 1 fix
A quick improvement would just be to change error reporting to something like:
Mesh is either nonmanifold, or faces are not oriented consistently.
Level 2 fix
A bigger fix would be to detect that faces are inconsistently oriented, and report this explicitly:
Mesh is manifold, but faces are not consistently oriented.
Level 3 fix
The ultimate fix would be to actually fix the normal orientation, if the mesh is manifold and orientable. There are some design decisions here (e.g., which of the two orientations should we pick?) but generally this should be pretty straightforward.
We could also implement this as a general-purpose method like orientFaces(), which is probably useful in its own right. Then the user can be asked to call this method explicitly:
Mesh is manifold, but faces are not consistently oriented. Please call orientFaces() before trying to build a ManifoldSurfaceMesh.
This may be better than automatically orienting someone's faces, which might violate the principle of least surprise.
A question about the "Level 3 fix". I have a number of meshes generated as the output of an OpenVDB voxel grid. Some of these meshes are reported by GC as not edge-manifold and not oriented/manifold.
After calling separateNonmanifoldEdges, this flips isEdgeManifold and isManifold to "true".
However, calling SurfaceMesh::greedilyOrientFaces does not fix the result of isOriented. Does this mean that the mesh is inherently not orientable, or just that this approach doesn't work on all orientable meshes? FWIW, the meshes I am working with are watertight regions extracted from architectural models, so they are intended to correspond to real-world geometry (i.e. they're not contrived counterexamples).