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 support for poly data box in clip_box filter #433

Merged
merged 2 commits into from
Nov 2, 2019
Merged

Conversation

banesullivan
Copy link
Member

Resolve #372 - pinging @craigmillernz

This adds support for using a poly data box to clip a mesh. Why? the clip_surface filter isn't very efficient and the box clipping filter is very efficient. Most of the time, users just want a rotated volume/region of interest and this will provide a really good way to extract those!

from pyvista import examples
import pyvista as pv

# The mesh to clip
mesh = examples.load_airplane()

# Use `pv.Box()` or `pv.Cube()` to create a region of interest
roi = pv.Cube(center=(0.9e3, 0.2e3, mesh.center[2]), 
              x_length=500, y_length=500, z_length=500)
roi.rotate_z(33)

# Runt the box lipping algorithm
extracted = mesh.clip_box(box, invert=False)

p = pv.Plotter(shape=(1,2))
p.add_mesh(box, opacity=0.75, color="red")
p.add_mesh(mesh)
p.subplot(0,1)
p.add_mesh(extracted)
p.link_views()
p.view_isometric()
p.show()

download

@banesullivan banesullivan added the enhancement Changes that enhance the library label Oct 31, 2019
@banesullivan banesullivan added this to the 0.23.0 milestone Nov 1, 2019
Copy link
Member

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the speed and how often clipped data is often square, I think this is a great approach to clipping. Especially for geospatial data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rotated box clip
2 participants