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

Crinkle Clip returns UnstructuredGrid instead of PolyData #6098

Open
kalingibbons opened this issue May 17, 2024 · 6 comments
Open

Crinkle Clip returns UnstructuredGrid instead of PolyData #6098

kalingibbons opened this issue May 17, 2024 · 6 comments
Labels
bug Uh-oh! Something isn't working as expected.

Comments

@kalingibbons
Copy link

Describe the bug, what's wrong, and what you expected.

Using the crinkle=True keyword in the clip filter returns an UnstructuredGrid object. I expected the clip filter to always return a PolyData object.

Steps to reproduce the bug.

dataset = pv.examples.download_action_figure()
dataset.clip('x', crinkle=False)  # returns PolyData
dataset.clip('x', crinkle=True)  # returns UnstructuredGrid)

image

System Information

--------------------------------------------------------------------------------
  Date: Fri May 17 15:35:58 2024 Mountain Daylight Time

                OS : Windows (10 10.0.19045 SP0 Multiprocessor Free)
            CPU(s) : 8
           Machine : AMD64
      Architecture : 64bit
               RAM : 39.9 GiB
       Environment : Python
        GPU Vendor : NVIDIA Corporation
      GPU Renderer : NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2
       GPU Version : 4.5.0 NVIDIA 536.99
  MathText Support : False

  Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:27:10) [MSC
  v.1938 64 bit (AMD64)]

           pyvista : 0.43.8
               vtk : 9.2.6
             numpy : 1.26.4
        matplotlib : 3.8.4
            scooby : 0.10.0
             pooch : 1.8.1
            pillow : 10.0.0
           imageio : 2.34.1
             PyQt5 : 5.15.9
           IPython : 8.24.0
        ipywidgets : 8.1.1
             scipy : 1.13.0
              tqdm : 4.66.4
            meshio : 5.3.5
        jupyterlab : 4.2.0
      nest_asyncio : 1.6.0
--------------------------------------------------------------------------------

Screenshots

No response

@kalingibbons kalingibbons added the bug Uh-oh! Something isn't working as expected. label May 17, 2024
@user27182
Copy link
Contributor

#6060 was recently patched into version 0.43.8, not sure if that affected the output. @kalingibbons do you get this same bug with 0.43.7 ?

@kalingibbons
Copy link
Author

I was actually on 0.43.3 when I first ran into it, then updated to see if it was fixed before submitting the issue.

@user27182
Copy link
Contributor

Ah ok thanks for checking, I guess this bug has been there for a while then.

@MatthewFlamm
Copy link
Contributor

when doing crinkle clip, it uses extract_cells under the hood. This is the reason that it returns UnstructuredGrid. I wonder if If should detect PolyData input and then cast appropriately.

https://docs.pyvista.org/version/stable/api/core/_autosummary/pyvista.DataSetFilters.extract_cells.html#pyvista.DataSetFilters.extract_cells

@user27182
Copy link
Contributor

remove_cells may be a good alternative to extract_cells. It has a PolyData to PolyData mapping. Though, the indices provided to these filters are kind of the inverse of each other. An alternative is to use vtkRemovePolyData for this purpose, this is what the connectivity filter currently uses under the hood for some cases.

Or, even using extract_surface would work, as suggested in #3009.

Not sure which implementation would be better to use. Some methods may alter the topology so probably whichever one best preserves the input data (e.g. correct cell winding, preserves orientation of the normals, ordering of cell ids, etc.

Having a PolyData to PolyData mapping for filters more generally is probably a good thing to add. It would eliminate the need to always cast the output back to PolyData if this kind of behavior was made standard for all DataSetFilters.
For example it would resolve this issue #5613.

Other filters such as extract_values, which also uses extract_cells under the hood and returns an UnstructuredGrid, would also benefit. E.g. #5968 uses extract_values but then has to call remove_cells to effectively cast the output back to PolyData. It would be nice to just get the PolyData output directly.

@darikg
Copy link
Contributor

darikg commented May 19, 2024

it's always irked me that PolyData.extract_cells returns an UnstructuredGrid. Big +1 on fixing that if it's possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh-oh! Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

4 participants