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

Create an irregular polygon shaped cylinder and use it to clip a mesh #50

Closed
craigmillernz opened this issue Aug 14, 2019 · 2 comments
Closed
Labels
filtering General topics around filtering and usage of filters mesh-creation Topics around creating a PyVista mesh

Comments

@craigmillernz
Copy link

I'd like to be able to clip a mesh by an irregular shaped polygon cylinder. This polygon could be defined by the perimeter of a set of datapoints (ie like observations in a geophysical survey), or it could be defined manually using coordinates of the top and bottom of the cylinder.
I would then use this polygon cylinder surface as input into the dataset.clip_surface() filter. The intention is to clip a geophysical model (which is a rectangular cube) to the actual data measurement point distribution, which is a random shape.

@banesullivan
Copy link
Member

So just to clarify and follow up on some points from Slack - the clip_surface filter requires a closed ("watertight") mesh to work - we'd need to create a PolyData mesh of the defined surface that encloses all the data in the mesh that you'd like to extract.

Here is an example of how we might create a cyclider and clip a gridded dataset to extract a non-uniform ROI.

FYI - I'm experiencing a significant issue/bug with the clip_surface filter when using custom, irregular surfaces that will need to be mitigated, so I don't have an immediate solution for you when it comes to clipping with custom surfaces - I'll report back

Example A

Used PyVista' cylinder helper method to create a cylinder PolyData object that is closed and clip a UniformGrid with that surface:

import pyvista as pv
from pyvista import examples

# The gridded dataset to clip
mesh = examples.load_uniform()

# The surface that bounds the ROI
surf = pv.Cylinder(center=mesh.center, direction=(1,2,1),
                   height=15, radius=3.3)

p = pv.Plotter(notebook=0) 
p.add_mesh(surf, color='red', opacity=0.5,)
p.add_mesh(mesh, show_edges=True)
p.show()

2019-08-14 17 28 24

# Perform the clip
clipped = mesh.clip_surface(surf, compute_distance=True)

p = pv.Plotter(notebook=0) 
p.add_mesh(mesh.outline(), color=True)
p.add_mesh(clipped, show_edges=True)
p.show()

2019-08-14 17 28 43

@banesullivan banesullivan added filtering General topics around filtering and usage of filters mesh-creation Topics around creating a PyVista mesh labels Aug 16, 2019
@banesullivan
Copy link
Member

Also, the clip_box filter now allows a PolyData box to be passed which should address this.

ref pyvista/pyvista#433 which landed on v0.23.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filtering General topics around filtering and usage of filters mesh-creation Topics around creating a PyVista mesh
Projects
None yet
Development

No branches or pull requests

2 participants