Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Beginner Question] Is there a way to check if a given vertex is manifold or not in trimesh ? #2208

Closed
aradhyamathur opened this issue Apr 9, 2024 · 2 comments

Comments

@aradhyamathur
Copy link

Hi I wanted to know if there is a way to check if a vertex is manifold or not ? Something like is_vertex_manifold in igl but that returns for individual vertex instead for the entire mesh.

@mikedh
Copy link
Owner

mikedh commented Apr 9, 2024

Hey, I think it depends on exactly what you're looking for, but to find "is a vertex only included in edges that occur exactly twice" it's pretty easy to use boolean masks to get those:

In [1]: import trimesh

In [2]: import numpy as np

In [3]: m = trimesh.load('models/rabbit.obj')

In [4]: m.is_watertight
Out[4]: False

In [5]: edges_ok = trimesh.grouping.group_rows(m.edges_sorted, require_count=2).ravel()

In [8]: vertices_ok = np.zeros(len(m.vertices), dtype=bool)

In [9]: vertices_ok[m.edges_sorted[edges_ok].ravel()] = True

In [10]: vertices_ok.all()
Out[10]: False

# these are indices of vertices that are "bad" 
In [12]: np.nonzero(~vertices_ok)[0]
Out[12]: array([ 16,  77, 341, 364])

@mikedh mikedh closed this as completed Apr 9, 2024
@aradhyamathur
Copy link
Author

and the vertices that occur in 2 triangle fans like in the example shown here, I think the above wouldn't cover the case ? E.g
download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants