Skip to content

Commit

Permalink
4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Sep 4, 2019
1 parent 23a0ff9 commit 078a184
Show file tree
Hide file tree
Showing 57 changed files with 1,027 additions and 502 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ git clone https://github.com/marcomusy/vtkplotter.git
cd vtkplotter/examples
python tutorial.py
```
**More than 260 working examples can be found in directories** _(scroll down to see the screenshots):_ <br>
**More than 270 working examples can be found in directories** _(scroll down to see the screenshots):_ <br>
[**examples/basic**](https://github.com/marcomusy/vtkplotter/blob/master/examples/basic)<br>
[**examples/advanced**](https://github.com/marcomusy/vtkplotter/blob/master/examples/advanced)<br>
[**examples/volumetric**](https://github.com/marcomusy/vtkplotter/blob/master/examples/volumetric)<br>
Expand Down
Binary file added docs/colors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions examples/advanced/convexHull.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5285de33fccc4d3aaae6e58bc6073e63",
"model_id": "55b0c3051fe148ab871dd715cb2b4fc2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[4.5, 4.5, 4.5, 0.0, 0.0, 0.0, 1.0, "
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[3.216620300034088, 3.21582040570120"
]
},
"metadata": {},
Expand Down Expand Up @@ -58,7 +58,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/pointsCutMesh1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

# pick a few points on the sphere
sc = s.getPoints()
pts = Points([sc[10], sc[15], sc[129], sc[165]])
pts = Points([sc[10], sc[15], sc[129], sc[165]], r=12)

#cut loop region identified by the points
scut = s.clone().cutWithPointLoop(pts, invert=False)
scut.c('blue').alpha(0.7).scale(1.05)
scut.c('blue').alpha(0.7).lw(0).scale(1.03)

show(s, pts, scut, Text(__doc__), axes=1, bg='w')

4 changes: 2 additions & 2 deletions examples/advanced/thinplate_grid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1cfaf36a1a86468cbdfc69fe444195fb",
"model_id": "ffc6683c339c4cd1be89955b841d1cbc",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -76,7 +76,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/acollection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "dad5375c7d9d4c0084680492821a8f34",
"model_id": "a48242b8aa9b4fcb99c5958a6e931394",
"version_major": 2,
"version_minor": 0
},
Expand Down
6 changes: 3 additions & 3 deletions examples/basic/align2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4b81d08fa1654d36a0c201d87be3a516",
"model_id": "c36f73641ab1421fab19091a99c5f175",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[2.2243577717515617, 5.1122307959748"
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[2.1504162283002834, 4.9575156559299"
]
},
"metadata": {},
Expand Down Expand Up @@ -76,7 +76,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/distance2mesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fa314ad9367e4f1392df32473830c431",
"model_id": "5e4c1eea599f41b6b5caa8912d84d4de",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(cmap='jet', geometries=[{'vtkClass': 'vtkPolyData', 'points': {'vtkClass': 'vtkPoints', 'name': '_point"
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[2.235852213410751, 1.98468658497752"
]
},
"metadata": {},
Expand All @@ -24,7 +24,7 @@
"\"\"\"Compute the (signed) distance from one mesh to another.\"\"\"\n",
"\n",
"from vtkplotter import *\n",
"embedWindow('itkwidgets') # or k3d\n",
"# embedWindow('itkwidgets') # or k3d\n",
"\n",
"s1 = Sphere().flat() # flat shading\n",
"s2 = Cube(pos=(1,0,0), c='white', alpha=0.2)\n",
Expand Down
3 changes: 2 additions & 1 deletion examples/basic/mesh_alphas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Create a set of transparencies which can be passed to method pointColors()
Create a set of transparencies
which can be passed to method pointColors()
"""
from vtkplotter import load, show, Text, datadir

Expand Down
4 changes: 2 additions & 2 deletions examples/basic/mirror.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "958bb7a12f1e4736bc34ab04e97e195d",
"model_id": "960eb18a41bf4e3fa97d9d9b29bdcc77",
"version_major": 2,
"version_minor": 0
},
Expand Down
23 changes: 23 additions & 0 deletions examples/basic/silhouette2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Make the silhouette of an object
move along with camera position.
"""
from vtkplotter import *
import vtk

plt = Plotter(bg='lightblue', interactive=False)

s = load(datadir+'shark.ply')
s.alpha(0.1).c('gray').lw(0.1).lc('red')
plt.show(s, Text(__doc__))

sil = vtk.vtkPolyDataSilhouette()
sil.SetInputData(s.polydata())
sil.SetCamera(plt.camera)
silMapper = vtk.vtkPolyDataMapper()
silMapper.SetInputConnection(sil.GetOutputPort())

actor = Actor()
actor.lw(4).c('black').SetMapper(silMapper)

plt.add(actor) # add() also renders the scene
interactive()
4 changes: 2 additions & 2 deletions examples/notebooks/draw_points.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9fe819e5ad91417ebbec2f4b5c5e8241",
"model_id": "a8e2360e74a34d08894358cb053e269b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Plot(antialias=3, axes=['\\\\sum_i x_i', 'y', 'z'], background_color=16777215, camera=[4.5, 4.5, 4.5, 0.0, 0.0, "
"Plot(antialias=3, axes=['\\\\sum_i x_i', 'y', 'z'], background_color=16777215, camera=[-0.02869224721489469, 0.3"
]
},
"metadata": {},
Expand Down
33 changes: 3 additions & 30 deletions examples/notebooks/sphere.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[4.0, 5.0, 9.458719903115217, 4.0, 5.0, 6.0, 0, 1, 0]\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4aa58b8bffef4c0bbf57334b0e5f449a",
"model_id": "62ea648105d74f76ac8d8d4bc9f8bb99",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[4.0, 5.0, 9.458719903115217, 4.0, 5"
"Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[4.034587199031153, 5.03458719903115"
]
},
"metadata": {},
Expand All @@ -40,26 +33,6 @@
"s.pointColors(scals, cmap='Set3').flat().show(axes=1)\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[4, 5, 8.147419209797084, 4, 5, 6, 0, 1, 0]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"settings.notebook_plotter.camera"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
14 changes: 7 additions & 7 deletions examples/notebooks/test_itkwidgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 9,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e8f6803e7f614f3785201ae2fbfa4bde",
"model_id": "6eb4c867b65746d6a476565a977866dd",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(cmap='jet', geometries=[], gradient_opacity=0.01, point_sets=[], rendered_image=<itkImagePython.itkImag"
"Viewer(cmap='jet', geometries=[{'vtkClass': 'vtkPolyData', 'points': {'vtkClass': 'vtkPoints', 'name': '_point"
]
},
"metadata": {},
Expand All @@ -25,18 +25,18 @@
"source": [
"from vtkplotter import *\n",
"\n",
"embedWindow('itkwidgets') # or k3d\n",
"embedWindow('itk') # or k3d\n",
"\n",
"plot = Plotter(axes=1)\n",
"plot = Plotter(axes=0)\n",
"\n",
"cyl = Cylinder().wireframe()\n",
"sph = Sphere().pos(1.5,1,1)\n",
"sph.pointColors(sph.getPoints()[:,2], cmap='jet')\n",
"\n",
"# plot += sph # test vtkActors\n",
"# plot += cyl\n",
"plot += cyl\n",
"# plot += cyl+sph # test vtkAssembly\n",
"plot += load(datadir+'embryo.slc') # test vtkVolume\n",
"#plot += load(datadir+'embryo.slc') # test vtkVolume\n",
"\n",
"plot.show()"
]
Expand Down
2 changes: 0 additions & 2 deletions examples/other/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ python example.py # on mac OSX try 'pythonw' instead
| | |
| [![maze](https://user-images.githubusercontent.com/32848391/56964055-afaba080-6b5a-11e9-99cf-3fac99df9878.jpg)](https://github.com/marcomusy/vtkplotter/blob/master/examples/other/value-iteration.py)<br/> `value-iteration.py` | Solve a random maze with Markovian Decision Process (by [N. Rougier](https://github.com/rougier/ML-Recipes)). |
| | |
| [![tf_learnvol](https://user-images.githubusercontent.com/32848391/53975600-79771500-4105-11e9-8741-4661c2f035d4.jpg)](https://github.com/marcomusy/vtkplotter/blob/master/examples/other/tf_learn_embryo.py)<br/> `tf_learn_embryo.py` | Use *TensorFlow* to learn the value of a scalar defined in a volume. |
| | |
| [![expo](https://user-images.githubusercontent.com/32848391/57160341-c6ffbd80-6de8-11e9-95ff-7215ce642bc5.jpg)](https://github.com/marcomusy/vtkplotter/blob/master/examples/other/export_x3d.py)<br/> `export_x3d.py` | Embed a 3D scene in a webpage with x3dom. |
28 changes: 28 additions & 0 deletions examples/other/animation1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
This example shows how to animate simultaneously various objects
by specifying event times and durations of the effects
"""
from vtkplotter import *

sp = Sphere(r=0.5).cutWithPlane(origin=(0.15,0,0)).lw(0.1)
cu = Cube().pos(-2,0,0)
tr = Torus().pos(1,0,0).rotateY(80)

vp = Animation()
vp.showProgressBar = True
vp.timeResolution = 0.025 # secs

vp.fadeIn([cu, tr], t=0, duration=0.2)
vp.fadeIn(sp, t=1, duration=2)

vp.move(sp, (2,0,0), style="linear")
vp.rotate(sp, axis="y", angle=180)

vp.fadeOut(sp, t=3, duration=2)
vp.fadeOut(tr, t=4, duration=1)

vp.scale(cu, 0.1, t=5, duration=1)

vp.totalDuration = 4 # can shrink/expand total duration

vp.play()
21 changes: 21 additions & 0 deletions examples/other/animation2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
This example shows how to animate simultaneously various objects
by specifying event times and durations of the visual effects.
"""
from vtkplotter import *

s = load(datadir+"bunny.obj").subdivide().normalize()

vp = Animation()
vp.timeResolution = 0.02 # secs

vp.switchOn(s)

# no need to repeat t=1, duration=3 in changeLighting and changeColor
vp.meshErode(corner=0, t=1, duration=3).changeLighting("glossy").changeColor("v")

cam1 = orientedCamera(backoffVector=(0, 0, -1), backoff=8)
cam2 = orientedCamera(backoffVector=(1, 1, 1), backoff=8)
vp.moveCamera(cam1, cam2, t=0, duration=4)

vp.play()
Loading

0 comments on commit 078a184

Please sign in to comment.