Skip to content

Commit

Permalink
jupiter support
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed May 28, 2019
2 parents 2c1a3b8 + c9df928 commit 0d852cd
Show file tree
Hide file tree
Showing 54 changed files with 244 additions and 219 deletions.
8 changes: 4 additions & 4 deletions examples/advanced/densifycloud.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Adds new points to an input point cloud.
"""Adds new points to an input point cloud.
The new points are created in such a way that
all points in any local neighborhood are
within a target distance of one another.
all points in any local neighborhood are
within a target distance of one another.
"""
from vtkplotter import *
import numpy as np
Expand All @@ -17,4 +17,4 @@
print(apts.N(), '->', densecloud.N())

ppp = Points(densecloud.coordinates())
show(apts, densecloud, Text(__doc__), axes=8)
show(apts, densecloud, Text(__doc__), axes=8)
2 changes: 1 addition & 1 deletion examples/advanced/fitplanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
For some of these point we show the fitting plane.
Black points are the N points used for fitting.
Green histogram is the distribution of residuals from the fitting.
Both plane center and normal can be accessed from the
Both plane center and normal can be accessed from the
attribute plane.info['center'] and plane.info['normal'].
"""
from vtkplotter import *
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/interpolateField.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Thin Plate Spline or Radial Basis Function.
Example shows how to share the same vtkCamera
Example shows how to share the same vtkCamera
between different Plotter windows.
"""
from vtkplotter import Plotter, thinPlateSpline, Points, Arrows, show, Text
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/moving_least_squares1D.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This example shows how to use a variant of a 1 dimensional
This example shows how to use a variant of a 1 dimensional
Moving Least Squares (MLS) algorithm to project a cloud
of unordered points to become a smooth line.
The parameter f controls the size of the local regression.
Expand Down
6 changes: 3 additions & 3 deletions examples/advanced/moving_least_squares2D.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
This example shows how to use a variant of the
Moving Least Squares (MLS) algorithm to project a cloud
This example shows how to use a variant of the
Moving Least Squares (MLS) algorithm to project a cloud
of points to become a smooth surface.
The parameter f controls the size of the local regression.
The input actor's polydata is modified by the method
so more than one pass is possible.
If showNPlanes>0 an actor is built demonstrating the
If showNPlanes>0 an actor is built demonstrating the
details of the regression for some random points
In the second window we show the error estimated for
each point in color scale (left) or in size scale (right).
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/quadratic_morphing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Takes 2 shapes, source and target, and morphs source on target
this is obtained by fitting 18 parameters of a non linear,
this is obtained by fitting 18 parameters of a non linear,
quadratic, transformation defined in transform()
The fitting minimizes the distance to the target surface
using algorithms available in the scipy.optimize package.
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/align2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Example usage of align() method:
generate two random sets of points as 2 actors
generate two random sets of points as 2 actors
and align them using the Iterative Closest Point algorithm.
"""
from __future__ import division
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/bgImage.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Set a jpeg background image on a
vtkRenderingWindow layer, after
the first rendering it can be
"""Set a jpeg background image on a
vtkRenderingWindow layer, after
the first rendering it can be
zoomed to fill the window."""
from vtkplotter import Plotter, load, Polygon, Text, datadir

doc = Text(__doc__, c="k", bg="w")

vp = Plotter(N=2, size=(400, 800), axes=4, sharecam=0,
vp = Plotter(N=2, size=(400, 800), axes=4, sharecam=0,
bg=datadir+"images/tropical.jpg")

a1 = load(datadir+"flamingo.3ds").rotateX(-90)
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/buildmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
print('getCells() format is :', a.getCells())
print('getConnectivity() format is:', a.getConnectivity())

show(a, Text(__doc__), viewup='z', axes=8)
show(a, Text(__doc__), viewup='z', axes=8)
10 changes: 5 additions & 5 deletions examples/basic/closewindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
mesh = Paraboloid()

vp1 = show(mesh, Text(__doc__), title='First Plotter instance')
# Now press 'q' to exit the window interaction,

# Now press 'q' to exit the window interaction,
# windows stays open but not reactive anymore.

# You can go back to interation mode by simpy calling:
# You can go back to interavtion mode by simply calling:
#show()

input('\nControl returned to terminal shell:\nwindow is now unresponsive (press Enter)')
Expand All @@ -23,7 +23,7 @@
# but mesh objects still exist in it:

print("First Plotter actors:", vp1.actors)
vp1.show() #THIS HAS NO EFFECT: window does not exist anymore. Cannot reopen.
vp1.show() # THIS HAS NO EFFECT: window does not exist anymore. Cannot reopen.

##################################################################
# Can now create a brand new Plotter and show the old object in it
Expand All @@ -40,6 +40,6 @@
vp3.show(Hyperboloid())

from vtkplotter import closeWindow
closeWindow() # automatically find and close the current window
closeWindow() # automatically find and close the current window

print('done.')
2 changes: 1 addition & 1 deletion examples/basic/clustering.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Example usage of removeOutliers()
Example usage of removeOutliers()
and cluster() methods.
"""
from vtkplotter import show, cluster, removeOutliers, Text
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/colormaps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Example usage of pointColors to assign a color to each mesh vertex
Example usage of pointColors to assign a color to each mesh vertex
by looking it up in matplotlib database of colormaps
"""
print(__doc__)
Expand Down
6 changes: 3 additions & 3 deletions examples/basic/connCells.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

s = actor.subdivide(sub).clean(tol)

coords = s.coordinates()
coords = s.coordinates()
pactor = Points(coords)

tomerge = []
for p in coords:
ipts = s.closestPoint(p, N=N, returnIds=True)
pts = coords[ipts]

d = delaunay2D(pts, mode='fit').c('blue').wire()

piece = d.connectedCells(0, returnIds=False)

show(pactor, d, piece, Point(p, c='r'), interactive=0)
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/connVtx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Find the vertices that are connected
Find the vertices that are connected
to a specific vertex in a mesh.
"""
from vtkplotter import *
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/flatarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
s, c = sin(i), cos(i)
l1 = [[sin(x)+c, -cos(x)+s, x] for x in arange(0,3, 0.1)]
l2 = [[sin(x)+c+0.1, -cos(x)+s + x/15, x] for x in arange(0,3, 0.1)]

FlatArrow(l1, l2, c=i, tipSize=1, tipWidth=1)

show(collection(), viewup="z", axes=1, bg="w")
2 changes: 1 addition & 1 deletion examples/basic/glyphs_arrows.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# get a list of random rgb colors
nrs = np.random.randint(0, 10, len(coords1))
cols = getColor(nrs)
cols = getColor(nrs)

a2 = Arrows(coords1, coords2, c=cols, scale=0.5)

Expand Down
2 changes: 1 addition & 1 deletion examples/basic/isolines.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Draw the isolines of the
Draw the isolines of the
active scalars on a surface
"""
from vtkplotter import *
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/keypress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This example shows how to implement a custom function that is triggered by
This example shows how to implement a custom function that is triggered by
pressing a keyboard button when the rendering window is in interactive mode.
Every time a key is pressed the picked point of the mesh is used
to add a sphere and some info is printed.
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/manyspheres.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Example that shows how to draw very large number of
Example that shows how to draw very large number of
spheres (same for Points, lines) with different colors
or different radius. Resolution (res) can be specified.
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/markpoint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Mark a specific point
Mark a specific point
on a mesh with some text.
"""
from vtkplotter import Sphere, Point, show, Text
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/mesh_coloring.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Example on how to specify a color for each individual cell
or point of an actor's mesh.
Example on how to specify a color for each individual cell
or point of an actor's mesh.
Last example also shows the usage of addScalarBar3D().
"""
print(__doc__)
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/mesh_map2cell.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""How to transform/map an array
"""How to transform/map an array
which is defined on the vertices of a mesh
to its cells with mapPointsToCells()
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/mesh_modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
dsc.setPoints(coords) # modify mesh
show(dsc, t, axes=8, resetcam=0, interactive=0)

interactive()
interactive()
2 changes: 1 addition & 1 deletion examples/basic/mesh_sharemap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
How to share the same color map
How to share the same color map
across different meshes.
"""
print(__doc__)
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/multiblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
filename = "multiblock.vtm"

mblock = write([poly, img], filename) #returns a vtkMultiBlockData
printc("~save wrote file", filename,
printc("~save wrote file", filename,
"and corresponding directory", c='g')

# load back from file into a list of actors/volumes
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/multiwindows.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Example of drawing objects on different windows
Example of drawing objects on different windows
and/or subwindows within the same window.
We split the main window in a 25 subwindows and draw something
in specific windows numbers.
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/pca.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Draw the PCA (Principal Component Analysis) ellipsoid that contains
Draw the PCA (Principal Component Analysis) ellipsoid that contains
50% of a cloud of Points, then check if points are inside the surface.
Extra info is stored in actor.info['sphericity'], 'va', 'vb', 'vc'.
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/silhouette.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
sx.silhouette(),
sy.silhouette(),
sz.silhouette(),
Text(__doc__), axes=1, viewup='z', bg='w')
Text(__doc__), axes=1, viewup='z', bg='w')
2 changes: 1 addition & 1 deletion examples/basic/sliders.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def slider2(widget, event):
vp.addSlider2D(slider1, -9, 9, value=0, pos=4, title="color number")

vp.addSlider2D(
slider2, xmin=0.01, xmax=0.99, value=0.5,
slider2, xmin=0.01, xmax=0.99, value=0.5,
pos=14, c="blue", title="alpha value (opacity)"
)
vp.show()
2 changes: 1 addition & 1 deletion examples/basic/trail.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Example usage of addTrail().
Example usage of addTrail().
Add a trailing line to a moving object.
"""
print(__doc__)
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/tube.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
A scalar array can be specified to vary
A scalar array can be specified to vary
radius and color of a line represented as a tube.
"""
print(__doc__)
Expand Down
7 changes: 5 additions & 2 deletions examples/notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
This functionality is still experimental.
It allows to embed a redering window into a jupyter notebook via
[K3D](https://github.com/K3D-tools/K3D-jupyter)
(or optionally with
[panel](https://github.com/pyviz/panel)).
(or optionally with [panel](https://github.com/pyviz/panel)).

On top of this K3D allows to export an interactive
[snapshot](https://vtkplotter.embl.es/examples/K3D_snapshot.html)
of the rendered scene.

`jupyter notebook examples/notebooks/embryo.ipynb`

Expand Down
6 changes: 3 additions & 3 deletions examples/other/export_x3d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Embed a 3D scene
in a webpage with
"""Embed a 3D scene
in a webpage with
x3dom and vtkplotter"""
from vtkplotter import *

Expand All @@ -10,7 +10,7 @@
t = Text(__doc__, pos=[3000., 2000., 4723], s=150, c='w', depth=0.1)
show(t, e)

# This exports the scene and generates 2 files:
# This exports the scene and generates 2 files:
# embryo.x3d and an example embryo.html to inspect in the browser
exportWindow('embryo.x3d')

4 changes: 2 additions & 2 deletions examples/other/icon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Make a icon actor to indicate orientation
and place it in one of the 4 corners
Make a icon actor to indicate orientation
and place it in one of the 4 corners
within the same renderer.
"""
from vtkplotter import *
Expand Down
2 changes: 1 addition & 1 deletion examples/other/makeVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

for i in range(80):
vp.show() # render the scene first
vp.camera.Elevation(1)
vp.camera.Elevation(1)
vp.camera.Azimuth(2) # rotate by 5 deg at each iteration
video.addFrame()

Expand Down
2 changes: 1 addition & 1 deletion examples/other/qt_embed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
A sort of minimal example of how to embed a rendering window
A sort of minimal example of how to embed a rendering window
into a qt application.
"""
print(__doc__)
Expand Down
2 changes: 1 addition & 1 deletion examples/other/remesh_ACVD.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Create clustering object
poly = amesh.clone().triangle().clean().polydata()
cobj = Clustering.Cluster(poly)
cobj = Clustering.Cluster(poly)

# Generate clusters
cobj.GenClusters(1000, max_iter=10000, subratio=10)
Expand Down
Loading

0 comments on commit 0d852cd

Please sign in to comment.