How to use the pyvista.Sphere function in pyvista

To help you get started, we’ve selected a few pyvista examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyvista / pyvista / tests / test_qt_plotting.py View on Github external
def test_background_plotting_orbit(qtbot):
    plotter = pyvista.BackgroundPlotter(show=False, title='Testing Window')
    plotter.add_mesh(pyvista.Sphere())
    # perfrom the orbit:
    plotter.orbit_on_path(bkg=False, step=0.0)
    plotter.close()
github pyvista / pyvista / tests / test_renderer.py View on Github external
def test_camera_position():
    plotter = pyvista.Plotter(off_screen=OFF_SCREEN)
    plotter.add_mesh(pyvista.Sphere())
    plotter.show()
    assert isinstance(plotter.camera_position, pyvista.CameraPosition)
github pyvista / pyvista / tests / test_qt_plotting.py View on Github external
def add_sphere(self):
        sphere = pyvista.Sphere()
        self.vtk_widget.add_mesh(sphere)
        self.vtk_widget.reset_camera()
github pyvista / pyvista / tests / test_plotting.py View on Github external
def test_axes():
    plotter = pyvista.Plotter(off_screen=True)
    plotter.add_axes()
    plotter.add_mesh(pyvista.Sphere())
    plotter.show()
github pyvista / pyvista / tests / test_plotting.py View on Github external
plotter.subplot(1, 1)
    plotter.add_text('Render Window 3', position=(0., 0.),
                     loc=loc, font_size=30, viewport=True)
    plotter.add_mesh(pyvista.Cone(), color='g', loc=loc, show_edges=True,
                     culling=True)
    plotter.add_bounding_box(render_lines_as_tubes=True, line_width=5)
    plotter.show_bounds(all_edges=True)

    plotter.update_bounds_axes()
    plotter.show()

    # Test subplot indices (2 rows by 1 column)
    plotter = pyvista.Plotter(shape=(2, 1), off_screen=OFF_SCREEN)
    # First row
    plotter.subplot(0,0)
    plotter.add_mesh(pyvista.Sphere())
    # Second row
    plotter.subplot(1,0)
    plotter.add_mesh(pyvista.Cube())
    plotter.show()

    # Test subplot indices (1 row by 2 columns)
    plotter = pyvista.Plotter(shape=(1, 2), off_screen=OFF_SCREEN)
    # First column
    plotter.subplot(0,0)
    plotter.add_mesh(pyvista.Sphere())
    # Second column
    plotter.subplot(0,1)
    plotter.add_mesh(pyvista.Cube())
    plotter.show()

    with pytest.raises(IndexError):
github pyvista / pyvista / tests / test_polydata.py View on Github external
import os
from math import pi

import numpy as np
import pytest

import pyvista
from pyvista import examples
from pyvista.plotting import system_supports_plotting

radius = 0.5
SPHERE = pyvista.Sphere(radius, theta_resolution=10, phi_resolution=10)

SPHERE_SHIFTED = pyvista.Sphere(center=[0.5, 0.5, 0.5],
                                theta_resolution=10, phi_resolution=10)

SPHERE_DENSE = pyvista.Sphere(radius, theta_resolution=100, phi_resolution=100)

try:
    test_path = os.path.dirname(os.path.abspath(__file__))
    test_data_path = os.path.join(test_path, 'test_data')
except:
    test_data_path = '/home/alex/afrl/python/source/pyvista/tests/test_data'

stl_test_file = os.path.join(test_data_path, 'sphere.stl')
ply_test_file = os.path.join(test_data_path, 'sphere.ply')
vtk_test_file = os.path.join(test_data_path, 'sphere.vtk')
test_files = [stl_test_file,
              ply_test_file,
              vtk_test_file]
github pyvista / pyvista / tests / test_qt_plotting.py View on Github external
def test_background_plotting_axes_scale(qtbot):
    sphere = pyvista.Sphere()
    plotter = pyvista.BackgroundPlotter(show=False, title='Testing Window')
    plotter.add_mesh(sphere)
    assert np.any(plotter.mesh.points)

    dlg = plotter.scale_axes_dialog(show=False)

    value = 2.0
    dlg.x_slider_group.value = value
    assert plotter.scale[0] == value

    dlg.x_slider_group.spinbox.setValue(-1)
    assert dlg.x_slider_group.value == 0
    dlg.x_slider_group.spinbox.setValue(1000.0)
    assert dlg.x_slider_group.value < 100

    plotter._last_update_time = 0.0
github pyvista / pyvista / examples / 02-plot / clear.py View on Github external
###############################################################################
# Clearing the entire plotting window:

plotter = pv.Plotter()
plotter.add_mesh(pv.Sphere())
plotter.add_mesh(pv.Plane())
plotter.clear()  # clears all actors
plotter.show()


###############################################################################
# Or you can give any actor a ``name`` when adding it and if an actor is added
# with that same name at a later time, it will replace the previous actor:

plotter = pv.Plotter()
plotter.add_mesh(pv.Sphere(), name="mydata")
plotter.add_mesh(pv.Plane(), name="mydata")
# Only the Plane is shown!
plotter.show()
github pyvista / pyvista / examples / 01-filter / poly-ray-trace.py View on Github external
"""
Ray Tracing
~~~~~~~~~~~

Single line segment ray tracing for PolyData objects.
"""

import pyvista as pv

# Create source to ray trace
sphere = pv.Sphere(radius=0.85)

# Define line segment
start = [0, 0, 0]
stop = [0.25, 1, 0.5]

# Perfrom ray trace
points, ind = sphere.ray_trace(start, stop)

# Create geometry to represent ray trace
ray = pv.Line(start, stop)
intersection = pv.PolyData(points)

# Render the result
p = pv.Plotter()
p.add_mesh(sphere, show_edges=True, opacity=0.5, color='w', lighting=False, label='Test Mesh')
p.add_mesh(ray, color='blue', line_width=5, label='Ray Segment')
github pyvista / pyvista / examples / 02-plot / shading.py View on Github external
"""
Types of Shading
~~~~~~~~~~~~~~~~

Comparison of default, flat shading vs. smooth shading.
"""
# sphinx_gallery_thumbnail_number = 2
import pyvista

pyvista.set_plot_theme("document")
###############################################################################
# PyVista supports two types of shading, flat and smooth shading that uses
# VTK's Phong shading algorithm.
#
# This is a plot with the default flat shading:
sphere = pyvista.Sphere()
sphere.plot(color="w")

###############################################################################
# Here's the same sphere with smooth shading:
sphere.plot(color="w", smooth_shading=True)