Beispiel #1
0
def test_disc():
    geom = pyvista.Disc()
    assert np.any(geom.points)

    normal = np.array([1.2, 3.4, 5.6])
    unit_normal = normal / np.linalg.norm(normal)
    geom = pyvista.Disc(normal=unit_normal)

    normals = geom.compute_normals()['Normals']
    assert np.allclose(np.dot(normals, unit_normal), 1)
Beispiel #2
0
def test_disc():
    geom = pyvista.Disc()
    assert np.any(geom.points)

    normal = np.array([1.2, 3.4, 5.6])
    unit_normal = normal / np.linalg.norm(normal)
    geom = pyvista.Disc(normal=unit_normal)

    normals = geom.compute_normals()['Normals']
    assert np.allclose(np.dot(normals, unit_normal), 1)

    center = (1.2, 3.4, 5.6)
    geom = pyvista.Disc(center=center)

    assert np.allclose(
        geom.bounds,
        pyvista.Disc().bounds + np.array([1.2, 1.2, 3.4, 3.4, 5.6, 5.6]))
def test_disc():
    geom = pyvista.Disc()
    assert np.any(geom.points)
p = pv.BackgroundPlotter(shape=(1, 2))

center= (0, 0, 0)
inner_hi = 0.6
inner_lo = 0.4
outer = 1.2
normal = (0, 0, 1)
r_res = 1
c_res = 60
opacity = 0.8
color = "white"

p.subplot(0, 0)
p.add_mesh(sst, show_edges=True, cmap=cmap, show_scalar_bar=True)
p.add_text("C48 time-series", font_size=13, shadow=True, font="courier")
hi_disc = pv.Disc(center=center, inner=inner_hi, outer=outer, normal=normal, r_res=r_res, c_res=c_res)
hi_disc.translate((0, 0, np.cos(np.radians(90-hi))))
hi_disc_actor = p.add_mesh(hi_disc, opacity=opacity, color=color)
lo_disc = pv.Disc(center=center, inner=inner_lo, outer=outer, normal=normal, r_res=r_res, c_res=c_res)
lo_disc.translate((0, 0, np.cos(np.radians(90-lo))))
lo_disc_actor = p.add_mesh(lo_disc, opacity=opacity, color=color)
p.add_checkbox_button_widget(show_lo, value=True, size=20, border_size=2, color_on="green")
p.add_checkbox_button_widget(show_hi, value=True, size=20, border_size=2, color_on="green", position=(10, 33))

p.subplot(0, 1)
p.add_mesh(sst_threshold, show_edges=True, cmap=cmap, scalar_bar_args=sargs, show_scalar_bar=True)
p.add_text(f"C48 time-series [{lo}, {hi}] (overlap)", font_size=15, shadow=True, font="courier")
hi_disc_threshold = pv.Disc(center=center, inner=inner_hi, outer=outer, normal=normal, r_res=r_res, c_res=c_res)
hi_disc_threshold.translate((0, 0, np.cos(np.radians(90-hi))))
hi_disc_threshold_actor = p.add_mesh(hi_disc_threshold, opacity=opacity, color=color)
lo_disc_threshold = pv.Disc(center=center, inner=inner_lo, outer=outer, normal=normal, r_res=r_res, c_res=c_res)
###############################################################################
# This runs through several of the available geometric objects available in
# VTK which PyVista provides simple convenience methods for generating.
#
# Let's run through creating a few geometric objects!

cyl = pv.Cylinder()
arrow = pv.Arrow()
sphere = pv.Sphere()
plane = pv.Plane()
line = pv.Line()
box = pv.Box()
cone = pv.Cone()
poly = pv.Polygon()
disc = pv.Disc()

###############################################################################
# Now let's plot them all in one window

p = pv.Plotter(shape=(3, 3))
# Top row
p.subplot(0, 0)
p.add_mesh(cyl, color="tan", show_edges=True)
p.subplot(0, 1)
p.add_mesh(arrow, color="tan", show_edges=True)
p.subplot(0, 2)
p.add_mesh(sphere, color="tan", show_edges=True)
# Middle row
p.subplot(1, 0)
p.add_mesh(plane, color="tan", show_edges=True)