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

Ensure no overlap with crinkle clip #6060

Merged
merged 4 commits into from
May 10, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions pyvista/core/filters/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def _clip_with_function(
a = _get_output(alg, oport=0)
b = _get_output(alg, oport=1)
if crinkle:
a = self.extract_cells(np.unique(a.cell_data['cell_ids']))
b = self.extract_cells(np.unique(b.cell_data['cell_ids']))
set_a = set(a.cell_data['cell_ids'])
set_b = set(b.cell_data['cell_ids']) - set_a
a = self.extract_cells(list(set_a))
b = self.extract_cells(list(set_b))
return a, b
clipped = _get_output(alg)
if crinkle:
Expand Down
9 changes: 7 additions & 2 deletions tests/core/test_dataset_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ def test_clip_filter(datasets):
assert isinstance(clp, pv.UnstructuredGrid)

# crinkle clip
clp = pv.Wavelet().clip(normal=(1, 1, 1), crinkle=True)
mesh = pv.Wavelet()
clp = mesh.clip(normal=(1, 1, 1), crinkle=True)
assert clp is not None
clp1, clp2 = pv.Wavelet().clip(normal=(1, 1, 1), return_clipped=True, crinkle=True)
clp1, clp2 = mesh.clip(normal=(1, 1, 1), return_clipped=True, crinkle=True)
assert clp1 is not None
assert clp2 is not None
set_a = set(clp1.cell_data['cell_ids'])
set_b = set(clp2.cell_data['cell_ids'])
assert set_a.isdisjoint(set_b)
banesullivan marked this conversation as resolved.
Show resolved Hide resolved
assert set_a.union(set_b) == set(range(mesh.n_cells))


@skip_mac
Expand Down