Skip to content

Commit e5a33de

Browse files
committed
update docs
1 parent c8edb90 commit e5a33de

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

docs/source/api_reference/pyvista.rst

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ PyVista
33

44
https://docs.pyvista.org
55

6-
PyVista is a great library that exposes a high level API for vtk, it has way more features
7-
than ipygany. For this reason, ipygany supports PyVista objects:
6+
PyVista is a great library that exposes a high level API for ``vtk``
7+
and it has way more features than ``ipygany``. For this reason,
8+
``ipygany`` supports PyVista objects:
89

910

1011
.. jupyter-execute::
1112

1213
import pyvista as pv
1314
from pyvista import examples
1415

15-
pvmesh = examples.download_st_helens()
16-
ugrid = pvmesh.cast_to_unstructured_grid()
17-
1816
from ipygany import PolyMesh, Scene, IsoColor, Warp
1917

20-
# Turn the PyVista mesh into a PolyMesh
21-
mesh = PolyMesh.from_vtk(ugrid)
18+
# Download a pyvista example and convert it to a PolyMesh
19+
pvmesh = examples.download_st_helens()
20+
mesh = PolyMesh.from_pyvista(pvmesh)
21+
22+
# Plot it
2223
warped_mesh = Warp(mesh, input=(0, 0, ('Elevation', 'X1')), warp_factor=1.)
2324
colored_mesh = IsoColor(warped_mesh, input='Elevation', min=682, max=2543)
24-
2525
Scene([colored_mesh])
2626

2727

@@ -30,13 +30,12 @@ than ipygany. For this reason, ipygany supports PyVista objects:
3030
import pyvista as pv
3131
from pyvista import examples
3232

33-
nefertiti = examples.download_nefertiti()
34-
ugrid = nefertiti.cast_to_unstructured_grid()
35-
3633
from ipygany import PolyMesh, Scene, IsoColor, Warp
3734

38-
# Turn the PyVista mesh into a PolyMesh
39-
mesh = PolyMesh.from_vtk(ugrid)
40-
mesh.default_color = 'gray'
35+
# Download the pyvista nefertiti example and convert it to a PolyMesh
36+
nefertiti = examples.download_nefertiti()
37+
mesh = PolyMesh.from_pyvista(nefertiti)
4138

39+
# Plot it
40+
mesh.default_color = 'gray'
4241
Scene([mesh])

ipygany/ipygany.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ def from_pyvista(obj, **kwargs):
298298

299299
# convert to an all-triangular surface
300300
if surf.is_all_triangles():
301-
trimesh = surf.triangulate()
302-
else:
303301
trimesh = surf
302+
else:
303+
trimesh = surf.triangulate()
304304

305305
# finally, pass the triangle vertices to PolyMesh
306306
triangle_indices = trimesh.faces.reshape(-1, 4)[:, 1:]

0 commit comments

Comments
 (0)