############################################################################### p = pv.Plotter() p.add_mesh(slc, cmap=cmap) p.add_mesh(model.outline()) p.show(cpos=[1, -1, 1]) ############################################################################### # Multiple Slices in Vector Direction # +++++++++++++++++++++++++++++++++++ # # Slice a mesh perpendicularly along a vector direction perpendicularly. mesh = examples.download_brain() # Create vector vec = np.random.rand(3) # Normalize the vector normal = vec / np.linalg.norm(vec) # Make points along that vector for the extent of your slices a = mesh.center + normal * mesh.length / 3.0 b = mesh.center - normal * mesh.length / 3.0 # Define the line/points for the slices n_slices = 5 line = pv.Line(a, b, n_slices) # Generate all of the slices
def test_download_brain(): data = examples.download_brain() assert data.n_cells
p.subplot(0, 1) p.add_text("Standard") p.add_mesh(room.copy(), opacity=0.5, color="tan") p.link_views() p.camera_position = [(43.6, 49.5, 19.8), (0.0, 2.25, 0.0), (-0.57, 0.70, -0.42)] p.show() ############################################################################### # And here is another example wheen rendering many translucent contour # surfaces. mesh = examples.download_brain().contour(5) cmap = "viridis_r" p = pv.Plotter(shape=(1, 2), multi_samples=4) p.add_mesh(mesh, opacity=0.5, cmap=cmap) p.enable_depth_peeling(10) p.add_text("Depth Peeling") p.subplot(0, 1) p.add_text("Standard") p.add_mesh(mesh.copy(), opacity=0.5, cmap=cmap) p.link_views() p.camera_position = [(418.3, 659., 53.8), (90.2, 111.5, 90.0), (0.03, 0.05, 1.0)]
p.subplot(1, 0) p.add_text("Gaussian smoothing, std=4", font_size=24) p.add_mesh(data.gaussian_smooth(std_dev=4.), rgb=True) p.camera_position = cp p.subplot(1, 1) p.add_text("Gaussian smoothing, std=8", font_size=24) p.add_mesh(data.gaussian_smooth(std_dev=8.), rgb=True) p.camera_position = cp p.show() ############################################################################### # Now let's see an example on a 3D dataset with volume rendering: data = examples.download_brain() smoothed_data = data.gaussian_smooth(std_dev=3.) dargs = dict(clim=smoothed_data.get_data_range(), opacity=[0, 0, 0, 0.1, 0.3, 0.6, 1]) n = [100, 150, 200, 245, 255] p = pv.Plotter(shape=(1, 2), notebook=0) p.subplot(0, 0) p.add_text("Original Image", font_size=24) # p.add_mesh(data.contour(n), **dargs) p.add_volume(data, **dargs) p.subplot(0, 1)
""" Moving Isovalue ~~~~~~~~~~~~~~~ Make an animation of an isovalue through a volumetric dataset """ import pyvista as pv from pyvista import examples import numpy as np vol = examples.download_brain() vol ############################################################################### # Now lets make an array of all of the isovalues for which we want to show. values = np.linspace(5, 150, num=25) ############################################################################### # Now let's create an initial isosurface that we can plot and move surface = vol.contour([values[0]],) ############################################################################### # Precompute the surfaces surfaces = [vol.contour([v]) for v in values] ############################################################################### # Set a single surface as the one being plotted that can be overwritten surface = surfaces[0].copy() ###############################################################################
def __init__(self): self._example_data = examples.download_brain() _ExampleLoader.__init__(self)
def plane(self, fbo): from pyvista import examples vol = examples.download_brain() fbo.add_mesh_clip_plane(vol) fbo.update()