示例#1
0
def test_multi_block_copy():
    multi = pyvista.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
    newobj = multi.copy()
    assert multi.n_blocks == 5 == newobj.n_blocks
    assert id(multi[0]) != id(newobj[0])
    assert id(multi[-1]) != id(newobj[-1])
    # Now check shallow
    newobj = multi.copy(deep=False)
    assert multi.n_blocks == 5 == newobj.n_blocks
    assert id(multi[0]) == id(newobj[0])
    assert id(multi[-1]) == id(newobj[-1])
    return
 def __init__(self, vtk_widget):
     self.vtk_widget = vtk_widget
     self.show_ref_vector_point = False
     self.spacecraft_model_2_orbit = None
     self.spacecraft_model_2_attitude = None
     # def add_sphere(self):
     # add a sphere to the pyqt frame
     self.vtk_widget.subplot(0, 0)
     sphere = examples.load_globe()
     sphere.points /= 1000
     # self.vtk_widget.add_background_image(examples.mapfile)
     self.vtk_widget.add_background_image("Model/background4.jpg")
     self.vtk_widget.set_background(color='k')
     self.sphere = sphere
     self.vtk_widget.add_mesh(self.sphere, smooth_shading=True, culling='back')
     self.sphere.rotate_z(0)
     self.add_eci_frame()
     self.vtk_widget.view_isometric()
     self.body_ref_point = None
     self.vector_line_from_sc = None
     self.tar_pos_eci = None
def test_multi_block_list_index():
    multi = pyvista.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
    indices = [0, 3, 4]
    sub = multi[indices]
    assert len(sub) == len(indices)
    for i, j in enumerate(indices):
        assert id(sub[i]) == id(multi[j])
        assert sub.get_block_name(i) == multi.get_block_name(j)
    # check list of key names
    multi = pyvista.MultiBlock()
    multi["foo"] = pyvista.Sphere()
    multi["goo"] = pyvista.Box()
    multi["soo"] = pyvista.Cone()
    indices = ["goo", "foo"]
    sub = multi[indices]
    assert len(sub) == len(indices)
    assert isinstance(sub["foo"], pyvista.PolyData)
示例#4
0
earth_alt = examples.download_topo_global()

pl = pv.Plotter()
actor = pl.add_mesh(examples.load_airplane(), smooth_shading=True)
# pl.add_background_image(examples.mapfile)
pl.plot()

###############################################################################
# Plot several earth related plots

pl = pv.Plotter(shape=(2, 2))

pl.subplot(0, 0)
pl.add_text('Earth Visible as Map')
pl.add_background_image(examples.mapfile, as_global=False)

pl.subplot(0, 1)
pl.add_text('Earth Altitude')
actor = pl.add_mesh(earth_alt, cmap='gist_earth')

pl.subplot(1, 0)
topo = examples.download_topo_land()
actor = pl.add_mesh(topo, cmap='gist_earth')
pl.add_text('Earth Land Altitude')

pl.subplot(1, 1)
pl.add_text('Earth Visible as Globe')
pl.add_mesh(examples.load_globe(), smooth_shading=True)

pl.show()
示例#5
0
"""

import pyvista as pv
from pyvista import examples

###############################################################################
# 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:`pyvista.BasePlotter.subplot` function to
# select the subplot you wish to be the active subplot.

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

plotter.subplot(0, 0)
plotter.add_text("Render Window 0", 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(pv.Cube(), show_edges=True, color="tan")

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

plotter.subplot(1, 1)
plotter.add_text("Render Window 3", font_size=30)
示例#6
0
def globe():
    return examples.load_globe()
示例#7
0
def test_plot_texture_associated():
    """"Test adding a texture to a plot"""
    globe = examples.load_globe()
    plotter = pyvista.Plotter(off_screen=OFF_SCREEN)
    plotter.add_mesh(globe, texture=True)
    plotter.show()
示例#8
0
def test_plot_texture_associated():
    """"Test adding a texture to a plot"""
    globe = examples.load_globe()
    plotter = pyvista.Plotter()
    plotter.add_mesh(globe, texture=True)
    plotter.show(before_close_callback=verify_cache_image)
示例#9
0
    Plot a globe mesh with Background plotter and make the mesh shrink over time

    Author: Jari Honkanen

"""

import time
import numpy as np
from threading import Thread
import pyvista as pv
import pyvistaqt as pvqt
from pyvista import examples

if __name__ == "__main__":

    globe = examples.load_globe()
    globe.point_arrays['scalars'] = np.random.rand(globe.n_points)
    globe.set_active_scalars('scalars')

    # Create background plotter
    plotter_bg = pvqt.BackgroundPlotter()
    plotter_bg.add_mesh(globe, scalars='scalars', lighting=False, show_edges=True, texture=True)
    plotter_bg.view_isometric()

    # Change globe size in the background
    def change_size():
        for i in range(50):
            globe.points *= 0.95
            globe.point_arrays['scalars'] = np.random.rand(globe.n_points)
            time.sleep(0.5)
示例#10
0
"""
Geodesic Paths
~~~~~~~~~~~~~~

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

sphere = examples.load_globe()

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

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

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

p = pv.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()

###############################################################################
# How long is that path?
distance = sphere.geodesic_distance(0, sphere.n_points - 1)
print(distance)
示例#11
0
"""
Extract Points
~~~~~~~~~~~~~~

This example will demonstrate how to extract the points and PointData of
any input data set that has valid PointData into a `vtkPolyData` object.

This example demos :class:`PVGeo.filters.ExtractPoints`
"""
# sphinx_gallery_thumbnail_number = 2
from pyvista import examples
from PVGeo.filters import ExtractPoints

################################################################################
# Have some input data source with valid PointData
data = examples.load_globe()
data.plot()

################################################################################
# Apply the filter:
polyData = ExtractPoints().apply(data)
polyData.plot()