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

add manifold check #1684

Merged
merged 3 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pyvista/core/pointset.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,26 @@ def n_open_edges(self):
alg.Update()
return alg.GetOutput().GetNumberOfCells()

@property
def is_manifold(self) -> bool:
"""Return if the mesh is manifold (no open edges).

Examples
--------
Show a sphere is manifold.

>>> import pyvista
>>> pyvista.Sphere().is_manifold
True

Show a plane is not manifold.

>>> pyvista.Plane().is_manifold
False

"""
return self.n_open_edges == 0

def __del__(self):
"""Delete the object."""
if hasattr(self, '_obbTree'):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,11 @@ def test_reconstruct_surface_poly(sphere):
assert surf.is_all_triangles


def test_is_manifold(sphere, plane):
assert sphere.is_manifold
assert not plane.is_manifold


def test_reconstruct_surface_unstructured(datasets):
mesh = examples.load_hexbeam().reconstruct_surface()
assert isinstance(mesh, pyvista.PolyData)
Expand Down