예제 #1
0
~~~~~~~~~~~~~~~

Increase the number of triangles in a single, connected triangular mesh.

The :func:`pyvista.PolyDataFilters.subdivide` filter utilizes three different
subdivision algorithms to subdivide a mesh's cells: `butterfly`, `loop`,
or `linear`.
"""
from pyvista import examples
import pyvista as pv

###############################################################################
# First, let's load a **triangulated** mesh to subdivide. We can use the
# :func:`pyvista.DataSetFilters.triangulate` filter to ensure the mesh we are
# using is purely triangles.
mesh = examples.download_bunny_coarse().triangulate()

cpos = [(-0.02788175062966399, 0.19293295656233056, 0.4334449972621349),
        (-0.053260899930287015, 0.08881197167521734, -9.016948161029588e-05),
        (-0.10170607813337212, 0.9686438023715356, -0.22668272496584665)]

###############################################################################
# Now, lets do a few subdivisions with the mesh and compare the results.
# Below is a helper function to make a comparison plot of thee different
# subdivisions.


def plot_subdivisions(mesh, a, b):
    display_args = dict(show_edges=True, color=True)
    p = pv.Plotter(shape=(3, 3))
예제 #2
0
~~~~~~~~~~~~~~~

Clip/cut any dataset using using planes, boxes, or surface meshes.
"""
# sphinx_gallery_thumbnail_number = 4
import pyvista as pv
from pyvista import examples
import numpy as np

###############################################################################
# Clip with Plane
# +++++++++++++++
#
# Clip any dataset by a user defined plane using the
# :func:`pyvista.DataSetFilters.clip` filter
dataset = examples.download_bunny_coarse()
clipped = dataset.clip('y', invert=False)

p = pv.Plotter()
p.add_mesh(dataset, style='wireframe', color='blue', label='Input')
p.add_mesh(clipped, label='Clipped')
p.add_legend()
p.camera_position = [(0.24, 0.32, 0.7), (0.02, 0.03, -0.02),
                     (-0.12, 0.93, -0.34)]
p.show()

###############################################################################
# Clip with Box
# +++++++++++++
#
# Clip any dataset by a solid box using the
예제 #3
0
 def test_download_bunny_coarse():
     data = examples.download_bunny_coarse()
     assert data.n_cells
예제 #4
0
mesh.faces.reshape(-1, 4)[:, 1:]  # triangular faces

###############################################################################
# Loading other files types is just as easy! Simply pass your file path to the
# :func:`pyvista.read` function and that's it!
#
# Here are a few other examples - simply replace ``examples.download_*`` in the
# examples below with ``pyvista.read('path/to/you/file.ext')``

###############################################################################
# Example STL file:
mesh = examples.download_cad_model()
cpos = [(107.0, 68.5, 204.0), (128.0, 86.5, 223.5), (0.45, 0.36, -0.8)]
mesh.plot(cpos=cpos)

###############################################################################
# Example OBJ file
mesh = examples.download_doorman()
mesh.plot(cpos="xy")

###############################################################################
# Example BYU file
mesh = examples.download_teapot()
mesh.plot(cpos=[-1, 2, -5], show_edges=True)

###############################################################################
# Example VTK file
mesh = examples.download_bunny_coarse()
cpos = [(0.2, 0.3, 0.9), (0, 0, 0), (0, 1, 0)]
mesh.plot(cpos=cpos, show_edges=True, color=True)