Skip to content

Commit

Permalink
Ensure no overlap with crinkle clip (#6060)
Browse files Browse the repository at this point in the history
* Ensure no overlap with crinkle clip

* Improve test
  • Loading branch information
banesullivan committed May 10, 2024
1 parent 3e9a19d commit 5561441
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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)
assert set_a.union(set_b) == set(range(mesh.n_cells))


@skip_mac
Expand Down

0 comments on commit 5561441

Please sign in to comment.