예제 #1
0
def test_read_texture_from_numpy():
    """"Test adding a texture to a plot"""
    globe = examples.load_globe()
    texture = vtki.numpy_to_texture(imageio.imread(examples.mapfile))
    plotter = vtki.Plotter(off_screen=OFF_SCREEN)
    plotter.add_mesh(globe, texture=texture)
    plotter.plot()
예제 #2
0
def test_plot_texture():
    """"Test adding a texture to a plot"""
    globe = examples.load_globe()
    texture = examples.load_globe_texture()
    plotter = vtki.Plotter(off_screen=OFF_SCREEN)
    plotter.add_mesh(globe, texture=texture)
    plotter.plot()
예제 #3
0
def test_export_texture(tmpdir):
    filename = str(tmpdir.mkdir("tmpdir").join('scene'))
    data = ex.load_globe()
    # Create the scene
    plotter = vtki.Plotter(off_screen=OFF_SCREEN)
    plotter.add_mesh(data, texture=True)
    plotter.export_vtkjs(filename)
    cpos_out = plotter.show()  # Export must be called before showing!
    plotter.close()
    # Now make sure the file is there
    assert os.path.isfile('{}.vtkjs'.format(filename))
예제 #4
0
def test_combine_filter():
    multi = vtki.MultiBlock()
    # Add examples
    multi.append(ex.load_ant())
    multi.append(ex.load_sphere())
    multi.append(ex.load_uniform())
    multi.append(ex.load_airplane())
    multi.append(ex.load_globe())
    # Now check everything
    assert multi.n_blocks == 5
    # Now apply the geometry filter to combine a plethora of data blocks
    geom = multi.combine()
    assert isinstance(geom, vtki.UnstructuredGrid)
예제 #5
0
def test_multi_block_io(extension, binary, tmpdir):
    filename = str(tmpdir.mkdir("tmpdir").join('tmp.%s' % extension))
    multi = vtki.MultiBlock()
    # Add examples
    multi.append(ex.load_ant())
    multi.append(ex.load_sphere())
    multi.append(ex.load_uniform())
    multi.append(ex.load_airplane())
    multi.append(ex.load_globe())
    # Now check everything
    assert multi.n_blocks == 5
    # Save it out
    multi.save(filename, binary)
    foo = vtki.MultiBlock(filename)
    assert foo.n_blocks == multi.n_blocks
    foo = vtki.read(filename)
    assert foo.n_blocks == multi.n_blocks
예제 #6
0
"""
Geodesic Paths
~~~~~~~~~~~~~~

Calculates the geodesic path betweeen two vertices using Dijkstra's algorithm
"""
# sphinx_gallery_thumbnail_number = 1
import vtki
from vtki import examples

sphere = examples.load_globe()

###############################################################################
# Get teh geodesic path as a new :class:`vtki.PolyData` object:

geodesic = sphere.geodesic(0, sphere.n_points - 1)

###############################################################################
# Render the path along the sphere

p = vtki.Plotter()
p.add_mesh(geodesic, line_width=10, color='red', label='Geodesic Path')
p.add_mesh(
    sphere,
    show_edges=True,
)
p.camera_position = [-1, -1, 1]
p.add_legend()
p.show()

###############################################################################
예제 #7
0
Subplotting: having multiple scenes in a signle window
"""
################################################################################
# This example shows how to create a multi-window plotter by specifying the
# ``shape`` parameter.  The window generated is a two by two window by setting
# ``shape=(2, 2)``. Use the :func:`vtki.BasePlotter.subplot` function to select
# the subplot you wish to be the active subplot.

import vtki
from vtki import examples

plotter = vtki.Plotter(shape=(2, 2))

plotter.subplot(0, 0)
plotter.add_text('Render Window 0', position=None, font_size=30)
plotter.add_mesh(examples.load_globe())

plotter.subplot(0, 1)
plotter.add_text('Render Window 1', font_size=30)
plotter.add_mesh(vtki.Cube(), show_edges=True, color='orange')

plotter.subplot(1, 0)
plotter.add_text('Render Window 2', font_size=30)
sphere = vtki.Sphere()
plotter.add_mesh(sphere, scalars=sphere.points[:, 2])
plotter.add_scalar_bar('Z', vertical=True)
# plotter.add_axes()
plotter.add_axes(interactive=True)

plotter.subplot(1, 1)
plotter.add_text('Render Window 3', font_size=30)