Skip to content

Commit

Permalink
DOC: Add vtkUnstructuredGrid example
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Jul 23, 2019
1 parent b535523 commit 6c339b4
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -24,6 +24,7 @@ examples/emdata_janelia_822252.zip
examples/General_EduRes_Heart_BloodVessels_0.jpg
examples/cow.vtk
examples/Bunny.vtp
examples/uGridEx.vtk

js/lib/ZstdDecompress/web-build/
.pytest_cache/
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Expand Up @@ -40,6 +40,7 @@ point sets, and meshes.

- itk.Mesh
- vtk.vtkPolyData
- vtk.vtkUnstructuredGrid
- pyvista.PolyData

- Exquisite volume rendering
Expand Down Expand Up @@ -208,6 +209,7 @@ After installation, try the following examples that demonstrate how to visualize
- `NumPy array point sets <https://github.com/InsightSoftwareConsortium/itk-jupyter-widgets/blob/master/examples/NumPyArrayPointSet.ipynb>`_
- `ITK Mesh <https://github.com/InsightSoftwareConsortium/itk-jupyter-widgets/blob/master/examples/Mesh.ipynb>`_
- `VTK vtkPolyData <https://github.com/InsightSoftwareConsortium/itk-jupyter-widgets/blob/master/examples/vtkPolyData.ipynb>`_
- `VTK vtkUnstructuredGrid <https://github.com/InsightSoftwareConsortium/itk-jupyter-widgets/blob/master/examples/vtkUnstructuredGrid.ipynb>`_
- `pyvista PolyData <https://github.com/InsightSoftwareConsortium/itk-jupyter-widgets/blob/master/examples/pyvista.PolyData.ipynb>`_

or how to:
Expand Down
103 changes: 103 additions & 0 deletions examples/vtkUnstructuredGrid.ipynb
@@ -0,0 +1,103 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Install dependencies for this example\n",
"# Note: This does not include itk-jupyter-widgets, itself\n",
"import sys\n",
"!{sys.executable} -m pip install vtk"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" from urllib.request import urlretrieve\n",
"except ImportError:\n",
" from urllib import urlretrieve\n",
"import os\n",
"\n",
"import vtk\n",
"\n",
"from itkwidgets import view"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Download data\n",
"file_name = 'uGridEx.vtk'\n",
"if not os.path.exists(file_name):\n",
" url = 'https://data.kitware.com/api/v1/file/5d3752c2877dfcc9022724d9/download'\n",
" urlretrieve(url, file_name)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"reader = vtk.vtkUnstructuredGridReader()\n",
"reader.SetFileName(file_name)\n",
"reader.Update()\n",
"grid = reader.GetOutput()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e3a736c9242d44ec9d2de69d1b17df2d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[{'vtkClass': 'vtkPolyData', 'points': {'vtkClass': 'vtkPoints', 'name': '_points', 'numberO…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(geometries=grid)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 6c339b4

Please sign in to comment.