def pyvista_render_window(): """ Allow to download and create a more complex example easily """ from pyvista import examples sphere = pv.Sphere() #test actor globe = examples.load_globe() #test texture head = examples.download_head() #test volume uniform = examples.load_uniform() #test structured grid scalars = sphere.points[:, 2] sphere.point_arrays['test'] = scalars #allow to test scalars sphere.set_active_scalars('test') uniform.set_active_scalars("Spatial Cell Data") #test datasetmapper threshed = uniform.threshold_percent([0.15, 0.50], invert=True) bodies = threshed.split_bodies() mapper = vtk.vtkCompositePolyDataMapper2() mapper.SetInputDataObject(0, bodies) multiblock = vtk.vtkActor() multiblock.SetMapper(mapper) pl = pv.Plotter() pl.add_mesh(globe) pl.add_mesh(sphere) pl.add_mesh(uniform) pl.add_actor(multiblock) pl.add_volume(head) return pl.ren_win
def test_download_head(): data = examples.download_head() assert data.n_points
############################################################################### # You can also use a custom opacity mapping opacity = [0, 0, 0, 0.1, 0.3, 0.6, 1] p = pv.Plotter() p.add_volume(vol, cmap="viridis", opacity=opacity) p.camera_position = cpos p.show() ############################################################################### # Cool Volume Examples # ++++++++++++++++++++ # # Here are a few more cool volume rendering examples head = examples.download_head() p = pv.Plotter() p.add_volume(head, cmap="cool", opacity="sigmoid_6") p.camera_position = [(-228.0, -418.0, -158.0), (94.0, 122.0, 82.0), (-0.2, -0.3, 0.9)] p.show() ############################################################################### bolt_nut = examples.download_bolt_nut() p = pv.Plotter() p.add_volume(bolt_nut, cmap="coolwarm", opacity="sigmoid_5") p.show()