🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to add a face indexed in opposite order?

Started by
1 comment, last by JoeJ 3 years, 8 months ago

I'm using OpenMesh on Linux. Lets say I have a model composed of two boxes, top box and bottom box, one evenly on top of the other. I import the model where each box is a separate mesh. In my app I can select to highlight the top box or the bottom box as different components.

Now I want to merge each mesh (i.e., each box) into a single mesh (or even start out creating a single mesh), but the problem is that the bottom side of the top box uses points drawn in one direction and the top side of the bottom box is drawn in the opposite direction and OpenMesh doesn't allow this when adding all elements to a single mesh.

The problem is described in this post. https://stackoverflow.com/questions/24205196/addfacecomplex-edge-error-in-openmesh

Basically, the error is

This error results from some of the faces' vertices being added in the wrong order.

And to add to my problem, this is how these file formats are generated and given to me. It's not that the vertices are in the wrong order as normally I'd just place each set of vertices in their own mesh. But in order to use OpenMesh in the way it's meant (searching the entire mesh for specific edge types and not just a single component or mesh that meets another mesh), I need to add each mesh component as part of a single mesh.

Does anyone have thoughts on how to do this with OpenMesh or working with meshes in general?

Advertisement

I know OpenMesh uses Half Edge data structure, which can not represent non manifold cases like flipping a polygon by reversing vertex order.

Though, i fail to imagine why you try to do this? It sounds what you want is to delete those faces, not to flip them?
To merge two meshes like you describe, i would first think about finding overlapping faces, then remove those, finally join open edges and vertices.

I assume OpenMesh has tools to do this, and you'd end up with something like this:

  1. Make one single mesh from both cubes (which will have duplicated vertices then)
  2. Search for pairs of duplicates.
  3. Search adjacent faces if they overlap (sharing all vertices in opposite order) and exist on both cubes. Store edge duplicates for later use and delete those Faces.
  4. Keep only one vertex from duplicates, replace and delete the other.
  5. We now have cases of two open edges between two vertices. They are not visible but topologically the mesh has holes. So we need to join them by using the edge duplicates data we have stored.

Notice the later step could be optional if you do no further processing but convert to indexed triangles, e.g. for rendering.

This topic is closed to new replies.

Advertisement