user2976612
user2976612

Reputation: 137

Problem with reading neighboring vertices and faces for a vertex in OpenMesh

I have a 3D mesh of reconstructed scene with closed holes (regions with missing geometry) in obj file. I used Close Holes filter in MeshLab to recover geometry in hole regions.

enter image description here

This mesh has 7728 vertices and 2864 faces. For manipulating with mesh geometry I use OpenMesh library.

I follow the official tutorial on OpenMesh Python bindings. I use methods mesh.vf() and mesh.vv() to obtain neighboring vertices and faces for each vertex. Surprisingly I get 6141 vertices with no neighbors - methods mesh.vf() and mesh.vv() return empty lists. That's weird as soon as there is 2864 faces obtained by mesh.faces().

Moreover I used following code to obtain a list of all vertices in the mesh

unique_vertices = []
all_vertices = []
print('Total number of faces: ', len(mesh.faces()))
for fh in mesh.faces():
    # print('face ', fh.idx())
    for vh in mesh.fv(fh):
        # print('vertex ', vh.idx())
        all_vertices.append(vh)
    # print('')

unique_vertices = list(set(all_vertices))

This code returns 8592 unique vertices.

Do you know what could be the reason for these strange behavior in OpenMesh API?

Upvotes: 1

Views: 924

Answers (1)

Max
Max

Reputation: 101

8592 is 2864*3. So your set contains 3 vertices for every face. I assume different handle objects referring to the same vertex are not considered to be equal in the set. Have you tried inserting vh.idx() into all_vertices?

A closed triangle mesh has roughly half as many vertices as faces. So for your mesh one could expect roughly 2864/2 = 1432 vertices. Thus, we would expect 6296 isolated vertices for your total of 7728 vertices. Since your mesh is not closed it requires a few more vertices for the 2864 triangles which leaves you with only 6141 isolated vertices.

Upvotes: 1

Related Questions