Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Jul 7, 2024
1 parent da233e8 commit 30cc373
Show file tree
Hide file tree
Showing 166 changed files with 1,014 additions and 496 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2023, PyVista Developers
Copyright (c) 2024, PyVista Developers
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
6 changes: 3 additions & 3 deletions examples/00-load/create-explicit-structured-grid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creating an Explicit Structured Grid {#create_explicit_structured_grid}\n====================================\n\nCreate an explicit structured grid from NumPy arrays.\n"
"Creating an Explicit Structured Grid {#create_explicit_structured_grid}\n====================================\n\nCreate an explicit structured grid from NumPy arrays using\n`pyvista.ExplicitStructuredGrid`{.interpreted-text role=\"class\"}.\n"
]
},
{
Expand All @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import numpy as np\n\nimport pyvista as pv\n\nni, nj, nk = 4, 5, 6\nsi, sj, sk = 20, 10, 1\n\nxcorn = np.arange(0, (ni + 1) * si, si)\nxcorn = np.repeat(xcorn, 2)\nxcorn = xcorn[1:-1]\nxcorn = np.tile(xcorn, 4 * nj * nk)\n\nycorn = np.arange(0, (nj + 1) * sj, sj)\nycorn = np.repeat(ycorn, 2)\nycorn = ycorn[1:-1]\nycorn = np.tile(ycorn, (2 * ni, 2 * nk))\nycorn = np.transpose(ycorn)\nycorn = ycorn.flatten()\n\nzcorn = np.arange(0, (nk + 1) * sk, sk)\nzcorn = np.repeat(zcorn, 2)\nzcorn = zcorn[1:-1]\nzcorn = np.repeat(zcorn, (4 * ni * nj))\n\ncorners = np.stack((xcorn, ycorn, zcorn))\ncorners = corners.transpose()\n\ndims = np.asarray((ni, nj, nk)) + 1\ngrid = pv.ExplicitStructuredGrid(dims, corners)\ngrid = grid.compute_connectivity()\ngrid.plot(show_edges=True)"
"from __future__ import annotations\n\nimport numpy as np\n\nimport pyvista as pv\n\nni, nj, nk = 4, 5, 6\nsi, sj, sk = 20, 10, 1\n\nxcorn = np.arange(0, (ni + 1) * si, si)\nxcorn = np.repeat(xcorn, 2)\nxcorn = xcorn[1:-1]\nxcorn = np.tile(xcorn, 4 * nj * nk)\n\nycorn = np.arange(0, (nj + 1) * sj, sj)\nycorn = np.repeat(ycorn, 2)\nycorn = ycorn[1:-1]\nycorn = np.tile(ycorn, (2 * ni, 2 * nk))\nycorn = np.transpose(ycorn)\nycorn = ycorn.flatten()\n\nzcorn = np.arange(0, (nk + 1) * sk, sk)\nzcorn = np.repeat(zcorn, 2)\nzcorn = zcorn[1:-1]\nzcorn = np.repeat(zcorn, (4 * ni * nj))\n\ncorners = np.stack((xcorn, ycorn, zcorn))\ncorners = corners.transpose()\n\ndims = np.asarray((ni, nj, nk)) + 1\ngrid = pv.ExplicitStructuredGrid(dims, corners)\ngrid = grid.compute_connectivity()\ngrid.plot(show_edges=True)"
]
}
],
Expand All @@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/00-load/create-geometric-objects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Geometric Objects {#geometric_example}\n=================\n\nThe \\\"Hello, world!\\\" of VTK\n"
"Geometric Objects {#geometric_example}\n=================\n\nThe \\\"Hello, world!\\\" of VTK. Uses objects from\n`geometry_api`{.interpreted-text role=\"ref\"}.\n"
]
},
{
Expand All @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import pyvista as pv"
"from __future__ import annotations\n\nimport pyvista as pv"
]
},
{
Expand Down Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-kochanek-spline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a Kochanek Spline {#create_kochanek_spline_example}\n========================\n\nCreate a Kochanek spline/polyline from a numpy array of XYZ vertices.\n"
"Create a Kochanek Spline {#create_kochanek_spline_example}\n========================\n\nCreate a Kochanek spline/polyline from a numpy array of XYZ vertices.\nUses `pyvista.KochanekSpline`{.interpreted-text role=\"func\"}.\n"
]
},
{
Expand Down Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/00-load/create-parametric-geometric-objects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Parametric Geometric Objects {#parametric_example}\n============================\n\nCreating parametric objects\n"
"Parametric Geometric Objects {#parametric_example}\n============================\n\nCreating parametric objects from `parametric_api`{.interpreted-text\nrole=\"ref\"}.\n"
]
},
{
Expand All @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"from math import pi\n\nimport pyvista as pv"
"from __future__ import annotations\n\nfrom math import pi\n\nimport pyvista as pv"
]
},
{
Expand Down Expand Up @@ -478,7 +478,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-pixel-art.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import pyvista as pv\nfrom pyvista.demos import logo"
"from __future__ import annotations\n\nimport pyvista as pv\nfrom pyvista.demos import logo"
]
},
{
Expand Down Expand Up @@ -100,7 +100,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-platonic-solids.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"outputs": [],
"source": [
"p = pv.Plotter(window_size=[1000, 1000])\nfor ind, solid in enumerate(solids):\n # only use smooth shading for the teapot\n smooth_shading = ind == len(solids) - 1\n p.add_mesh(\n solid, color='silver', smooth_shading=smooth_shading, specular=1.0, specular_power=10\n )\np.view_vector((5.0, 2, 3))\np.add_floor('-z', lighting=True, color='lightblue', pad=1.0)\np.enable_shadows()\np.show()"
"p = pv.Plotter(window_size=[1000, 1000])\nfor ind, solid in enumerate(solids):\n # only use smooth shading for the teapot\n smooth_shading = ind == len(solids) - 1\n p.add_mesh(\n solid,\n color='silver',\n smooth_shading=smooth_shading,\n specular=1.0,\n specular_power=10,\n )\np.view_vector((5.0, 2, 3))\np.add_floor('-z', lighting=True, color='lightblue', pad=1.0)\np.enable_shadows()\np.show()"
]
},
{
Expand All @@ -89,7 +89,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions examples/00-load/create-point-cloud.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples"
"from __future__ import annotations\n\nimport numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples"
]
},
{
Expand All @@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
"# Define some helpers - ignore these and use your own data.\ndef generate_points(subset=0.02):\n \"\"\"A helper to make a 3D NumPy array of points (n_points by 3)\"\"\"\n dataset = examples.download_lidar()\n ids = np.random.randint(low=0, high=dataset.n_points - 1, size=int(dataset.n_points * subset))\n return dataset.points[ids]\n\n\npoints = generate_points()\n# Print first 5 rows to prove its a numpy array (n_points by 3)\n# Columns are (X Y Z)\npoints[0:5, :]"
"# Seed the random number generator for generating data\nrng = np.random.default_rng(seed=0)\n\n\n# Define some helpers - ignore these and use your own data.\ndef generate_points(subset=0.02):\n \"\"\"A helper to make a 3D NumPy array of points (n_points by 3)\"\"\"\n dataset = examples.download_lidar()\n ids = rng.integers(\n low=0,\n high=dataset.n_points - 1,\n size=int(dataset.n_points * subset),\n )\n return dataset.points[ids]\n\n\npoints = generate_points()\n# Print first 5 rows to prove its a numpy array (n_points by 3)\n# Columns are (X Y Z)\npoints[0:5, :]"
]
},
{
Expand Down Expand Up @@ -152,7 +152,7 @@
},
"outputs": [],
"source": [
"# Create random XYZ points\npoints = np.random.rand(100, 3)\n# Make PolyData\npoint_cloud = pv.PolyData(points)\n\n\ndef compute_vectors(mesh):\n origin = mesh.center\n vectors = mesh.points - origin\n vectors = vectors / np.linalg.norm(vectors, axis=1)[:, None]\n return vectors\n\n\nvectors = compute_vectors(point_cloud)\nvectors[0:5, :]"
"# Create random XYZ points\npoints = rng.random((100, 3))\n# Make PolyData\npoint_cloud = pv.PolyData(points)\n\n\ndef compute_vectors(mesh):\n origin = mesh.center\n vectors = mesh.points - origin\n return vectors / np.linalg.norm(vectors, axis=1)[:, None]\n\n\nvectors = compute_vectors(point_cloud)\nvectors[0:5, :]"
]
},
{
Expand Down Expand Up @@ -201,7 +201,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-pointset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import time\n\nimport pyvista as pv\nfrom pyvista import examples\n\nlidar = examples.download_lidar()\n\ntstart = time.time()\nclipped = lidar.clip(origin=(0, 0, 1.76e3), normal=(0, 0, 1))\nt_elapsed = time.time() - tstart\nprint(f\"Time to clip with a PolyData {t_elapsed:.2f} seconds.\")"
"from __future__ import annotations\n\nimport time\n\nimport pyvista as pv\nfrom pyvista import examples\n\nlidar = examples.download_lidar()\n\ntstart = time.time()\nclipped = lidar.clip(origin=(0, 0, 1.76e3), normal=(0, 0, 1))\nt_elapsed = time.time() - tstart\nprint(f\"Time to clip with a PolyData {t_elapsed:.2f} seconds.\")"
]
},
{
Expand Down Expand Up @@ -100,7 +100,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/00-load/create-poly.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import numpy as np\n\nimport pyvista as pv"
"from __future__ import annotations\n\nimport numpy as np\n\nimport pyvista as pv"
]
},
{
Expand All @@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
"# mesh points\nvertices = np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0.5, 0.5, -1]])\n\n# mesh faces\nfaces = np.hstack(\n [\n [4, 0, 1, 2, 3], # square\n [3, 0, 1, 4], # triangle\n [3, 1, 2, 4], # triangle\n ]\n)\n\nsurf = pv.PolyData(vertices, faces)\n\n# plot each face with a different color\nsurf.plot(\n scalars=np.arange(3),\n cpos=[-1, 1, 0.5],\n show_scalar_bar=False,\n show_edges=True,\n line_width=5,\n)"
"# mesh points\nvertices = np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0.5, 0.5, -1]])\n\n# mesh faces\nfaces = np.hstack(\n [\n [4, 0, 1, 2, 3], # square\n [3, 0, 1, 4], # triangle\n [3, 1, 2, 4], # triangle\n ],\n)\n\nsurf = pv.PolyData(vertices, faces)\n\n# plot each face with a different color\nsurf.plot(\n scalars=np.arange(3),\n cpos=[-1, 1, 0.5],\n show_scalar_bar=False,\n show_edges=True,\n line_width=5,\n)"
]
},
{
Expand Down Expand Up @@ -82,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-polydata-strips.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import numpy as np\n\nimport pyvista as pv\n\n# Create an array of points\npoints = np.array(\n [\n [1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0],\n [0.0, 1.0, 0.0],\n [1.0, 2.0, 0.0],\n [0.0, 2.0, 0.0],\n [1.0, 3.0, 0.0],\n [0.0, 3.0, 0.0],\n ]\n)"
"import numpy as np\n\nimport pyvista as pv\n\n# Create an array of points\npoints = np.array(\n [\n [1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0],\n [0.0, 1.0, 0.0],\n [1.0, 2.0, 0.0],\n [0.0, 2.0, 0.0],\n [1.0, 3.0, 0.0],\n [0.0, 3.0, 0.0],\n ],\n)"
]
},
{
Expand Down Expand Up @@ -154,7 +154,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/00-load/create-polyhedron.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Unstructured Grid with Polyhedra {#polyhedron_example}\n================================\n\nThis example shows how to build a simple\n`pyvista.UnstructuredGrid`{.interpreted-text role=\"class\"} using\npolyhedra. We will be using VTK types to determine which type of cells\nwe are building.\n\nFirst, we import the required libraries.\n"
"Unstructured Grid with Polyhedra {#polyhedron_example}\n================================\n\nThis example shows how to build a simple\n`pyvista.UnstructuredGrid`{.interpreted-text role=\"class\"} using\npolyhedra. We will be using VTK types to determine which type of cells\nwe are building. A list of cell types is given in\n`pyvista.CellType`{.interpreted-text role=\"class\"}.\n\nFirst, we import the required libraries.\n"
]
},
{
Expand Down Expand Up @@ -80,7 +80,7 @@
},
"outputs": [],
"source": [
"polyhedron_connectivity = [\n # NItems will go here\n 7, # number of faces\n 5, # number of points in face0\n 17, # point index 0\n 18, # point index 1\n 19, # point index 2\n 20, # point index 3\n 21, # point index 4\n 4, # number of points in face1\n 17, # point index ...\n 18,\n 23,\n 22,\n 4,\n 17,\n 21,\n 26,\n 22,\n 4,\n 21,\n 26,\n 25,\n 20,\n 4,\n 20,\n 25,\n 24,\n 19,\n 4,\n 19,\n 24,\n 23,\n 18,\n 5,\n 22,\n 23,\n 24,\n 25,\n 26,\n]\n\n# note how we retroactively add NItems\npolyhedron = [len(polyhedron_connectivity)] + polyhedron_connectivity"
"polyhedron_connectivity = [\n # NItems will go here\n 7, # number of faces\n 5, # number of points in face0\n 17, # point index 0\n 18, # point index 1\n 19, # point index 2\n 20, # point index 3\n 21, # point index 4\n 4, # number of points in face1\n 17, # point index ...\n 18,\n 23,\n 22,\n 4,\n 17,\n 21,\n 26,\n 22,\n 4,\n 21,\n 26,\n 25,\n 20,\n 4,\n 20,\n 25,\n 24,\n 19,\n 4,\n 19,\n 24,\n 23,\n 18,\n 5,\n 22,\n 23,\n 24,\n 25,\n 26,\n]\n\n# note how we retroactively add NItems\npolyhedron = [len(polyhedron_connectivity), *polyhedron_connectivity]"
]
},
{
Expand Down Expand Up @@ -172,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/00-load/create-spline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import numpy as np\n\nimport pyvista as pv"
"from __future__ import annotations\n\nimport numpy as np\n\nimport pyvista as pv"
]
},
{
Expand Down Expand Up @@ -201,7 +201,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions examples/00-load/create-structured-surface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creating a Structured Surface {#create_structured}\n=============================\n\nCreate a StructuredGrid surface from NumPy arrays\n"
"Creating a Structured Surface {#create_structured}\n=============================\n\nCreate a StructuredGrid surface from NumPy arrays using\n`pyvista.StructuredGrid`{.interpreted-text role=\"class\"}.\n"
]
},
{
Expand All @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples"
"from __future__ import annotations\n\nimport numpy as np\n\nimport pyvista as pv\nfrom pyvista import examples"
]
},
{
Expand Down Expand Up @@ -109,7 +109,7 @@
},
"outputs": [],
"source": [
"def make_point_set():\n \"\"\"Ignore the contents of this function. Just know that it returns an\n n by 3 numpy array of structured coordinates.\"\"\"\n n, m = 29, 32\n x = np.linspace(-200, 200, num=n) + np.random.uniform(-5, 5, size=n)\n y = np.linspace(-200, 200, num=m) + np.random.uniform(-5, 5, size=m)\n xx, yy = np.meshgrid(x, y)\n A, b = 100, 100\n zz = A * np.exp(-0.5 * ((xx / b) ** 2.0 + (yy / b) ** 2.0))\n points = np.c_[xx.reshape(-1), yy.reshape(-1), zz.reshape(-1)]\n foo = pv.PolyData(points)\n foo.rotate_z(36.6, inplace=True)\n return foo.points\n\n\n# Get the points as a 2D NumPy array (N by 3)\npoints = make_point_set()\npoints[0:5, :]"
"rng = np.random.default_rng(seed=0)\n\n\ndef make_point_set():\n \"\"\"Ignore the contents of this function. Just know that it returns an\n n by 3 numpy array of structured coordinates.\"\"\"\n n, m = 29, 32\n x = np.linspace(-200, 200, num=n) + rng.uniform(-5, 5, size=n)\n y = np.linspace(-200, 200, num=m) + rng.uniform(-5, 5, size=m)\n xx, yy = np.meshgrid(x, y)\n A, b = 100, 100\n zz = A * np.exp(-0.5 * ((xx / b) ** 2.0 + (yy / b) ** 2.0))\n points = np.c_[xx.reshape(-1), yy.reshape(-1), zz.reshape(-1)]\n foo = pv.PolyData(points)\n foo.rotate_z(36.6, inplace=True)\n return foo.points\n\n\n# Get the points as a 2D NumPy array (N by 3)\npoints = make_point_set()\npoints[0:5, :]"
]
},
{
Expand Down Expand Up @@ -194,7 +194,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 30cc373

Please sign in to comment.