Skip to content

Commit

Permalink
4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Nov 21, 2019
1 parent 764d9e3 commit 884d8b0
Show file tree
Hide file tree
Showing 34 changed files with 2,142 additions and 169 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ on the desktop to *drag&drop* files to visualize.
## Documentation
Automatically generated documentation can be found [**here**](https://vtkplotter.embl.es).

#### Need help?
Have any question, or wish to suggest or ask for a missing feature?
Do not hesitate to open a [**issue**](https://github.com/marcomusy/vtkplotter/issues)
or send an [email](mailto:marco.musy@embl.es).

## Features

Intuitive and straightforward API which can be combined with VTK seamlessly
Expand Down
16 changes: 16 additions & 0 deletions docs/news.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
2019/11/19
- added PDV paraview file reading.
- PDB protein data bank file reader
- added error bars in plotxy()
- fast fitting of 2d circles with utils.fitCircle2D()
- added flag-style pop-up labels for meshes and volumes
- added settings for resolving polygonal clashes with mesh edges
- built in set of parametric surfaces in shapes.py module
- improved plotting2d with error bars
- added warpMeshToPoint() method
- improved texture control, can pass texture coords explicitly
- fix trimesh problem with coloring vertices
- can use "panel" backend in notebooks



4 changes: 2 additions & 2 deletions examples/advanced/fitspheres2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

vp += Points(pts1, c=cols)
vp += Lines(pts1, pts2, c="black 0.2")
vp += histogram(vals, title="values", bins=20, vrange=[0, 1])
vp += histogram(vals, bins=20, vrange=[0, 1]).pos(-1,1,-1)
vp += Text(__doc__, pos=1)

vp.show()
vp.show(axes=1)
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": "a833f7c22dc942edbe873727193e0c22",
"model_id": "4639a002733847bd8674f05b70c0cadb",
"version_major": 2,
"version_minor": 0
},
Expand Down
3 changes: 2 additions & 1 deletion examples/basic/align1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

vp = Plotter()

limb = vp.load(datadir + "270.vtk")
# flag() shows the filename when hovering with mouse
limb = vp.load(datadir + "270.vtk").flag()
rim = vp.load(datadir + "270_rim.vtk").c("r").lw(4)

arim = alignICP(rim, limb, rigid=True).c("g").lw(5)
Expand Down
6 changes: 4 additions & 2 deletions examples/basic/mirror.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""
Mirror a mesh along one of the Cartesian axes.
Hover mouse to see original and mirrored.
"""
from vtkplotter import Plotter, Text, datadir

vp = Plotter(axes=2)

myted1 = vp.load(datadir+"teddy.vtk")
myted1 = vp.load(datadir+"teddy.vtk").flag('original')

myted2 = myted1.clone().mirror("y").pos([0, 3, 0]).color("green")
myted2 = myted1.clone().mirror("y").pos([0, 3, 0]).c("green").flag('mirrored')

vp.show(myted1, myted2, Text(__doc__), viewup="z")
3 changes: 3 additions & 0 deletions examples/basic/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ python cutter.py
echo Running texturecubes.py
python texturecubes.py

echo Running texture_coords.py
python texture_coords.py

echo Running ribbon.py
python ribbon.py

Expand Down
26 changes: 26 additions & 0 deletions examples/basic/texture_coords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Assign texture coordinates to a polygon
"""
from vtkplotter import Actor, Text, datadir, show

# define a polygon of 4 vertices:
polygon_a = [
[(82, 92, 47), (87, 88, 47), # x,y,z of vertices
(93, 95, 47), (88, 99, 47)],
[[0, 1, 2, 3]], # vertex connectivity
]

# texture coordinates, one (u,v) pair for each vertex:
tc = [(0,0), (1,0), (1,1), (0,1)]
#tc = [(0,0), (2,0), (2,2), (0,2)]

# create the vtkActor
a = Actor(polygon_a)

a.texture(datadir+"images/dog.jpg",
tcoords=tc,
interpolate=True,
repeat=True, # when tcoords extend beyond [0,1]
edgeClamp=False, # only used when repeat is False
)

show(a, Text(__doc__), axes=8)
23 changes: 23 additions & 0 deletions examples/other/flag_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Hover mouse onto an object
to pop a flag-style label
"""
from vtkplotter import *

# Can modify default behaviour through settings:
#settings.flagDelay = 0 # popup delay in milliseconds
#settings.flagFont = "Courier" # font type ("Arial", "Courier", "Times")
#settings.flagFontSize = 18
#settings.flagJustification = 0
#settings.flagAngle = 0
#settings.flagBold = False
#settings.flagItalic = True
#settings.flagShadow = False
#settings.flagColor = 'black'
#settings.flagBackgroundColor = 'white'

s = load(datadir+'/bunny.obj').flag() # picks filename by default
c = Cube(side=0.2).x(0.3).flag('my cube\nlabel')

#s.flag(False) #disable

show(s, c, Text(__doc__))
3 changes: 3 additions & 0 deletions examples/other/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ python colorpalette.py
echo Running printc.py
python printc.py

echo Running flag_labels.py
python flag_labels.py

echo Running icon.py
python icon.py

Expand Down
4 changes: 3 additions & 1 deletion examples/other/trimesh/ray.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import trimesh
import numpy as np
from vtkplotter import show
from vtkplotter import show, settings

settings.useDepthPeeling = True

# test on a sphere mesh
mesh = trimesh.creation.icosphere()
Expand Down
4 changes: 3 additions & 1 deletion examples/plotting2d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ python example.py
| | |
| [![fxy](https://user-images.githubusercontent.com/32848391/50738863-bfccf800-11d8-11e9-882d-7b217aceb55a.jpg)](https://github.com/marcomusy/vtkplotter/blob/master/examples/plotting2d/fxy.py)<br/> `fxy.py` | Draw a surface representing a function _f(x, y)_ defined as a string/formula or as a reference to an external already existing function. <br/>Red points indicate where the function does not exist. |
| | |
| [![histo](https://user-images.githubusercontent.com/32848391/68141260-77cc4e00-ff2d-11e9-9280-0efc5b87314d.png)](https://github.com/marcomusy/vtkplotter/blob/master/examples/plotting2d/histogram.py)<br/> `histogram.py` | Draw a 2D histogram with error bars. |
| [![plotxy](https://user-images.githubusercontent.com/32848391/69158509-d6c1c380-0ae6-11ea-9dbf-ff5cd396a9a6.png)](https://github.com/marcomusy/vtkplotter/blob/master/examples/plotting2d/plotxy.py)<br/> `plotxy.py` | Draw a _x_ vs _y_ plot with optional error bars. |
| | |
| [![histo](https://user-images.githubusercontent.com/32848391/68141260-77cc4e00-ff2d-11e9-9280-0efc5b87314d.png)](https://github.com/marcomusy/vtkplotter/blob/master/examples/plotting2d/histogram.py)<br/> `histogram.py` | Draw a 2D histogram with optional error bars. |
| | |
| [![histo2d](https://user-images.githubusercontent.com/32848391/50738861-bfccf800-11d8-11e9-9698-c0b9dccdba4d.jpg)](https://github.com/marcomusy/vtkplotter/blob/master/examples/plotting2d/histoHexagonal.py)<br/> `histoHexagonal.py` | Make a histogram of two variables with hexagonal binning. |
| | |
Expand Down
8 changes: 8 additions & 0 deletions examples/plotting2d/axesStyle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from vtkplotter import *

Earth(r=1).x(3) # set position x=3

Sphere(r=.3).x(-3).texture('marble2')

printc('press keypad 1-9 to change axes style', box='-', invert=1)
show(..., axes=11, bg='db', bg2='k', verbose=0)
27 changes: 18 additions & 9 deletions examples/plotting2d/plotxy.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
from vtkplotter import plotxy, show
import numpy as np

x = np.arange(0, 10, 1)
y = np.sin(x)
x = np.arange(0, 10, 1)
y = np.sin(x)

# assign errors to both x and y
ye = np.random.rand(10)/2
xe = np.random.rand(10)

##############
plt1 = plotxy(
[x, y],
yscale=3, # set an optional scaling factor
[x, y], # accepts different formats
yscale=3, # set an optional y-scaling factor
xlimits=(-1, 11),
splined=False,
lc="r",
marker="*",
mc="dr",
lc="r", # line color
marker="*", # marker style
mc="dr", # marker color
)

##############
plt2 = plotxy(
[x+1, y+0.2],
yscale=3, # choose the same y-scale as above
xerrors=xe, # show error bars
yerrors=ye,
yscale=3, # choose the same y-scale as above!
splined=True,
xtitle="x variable (mm)",
ytitle="y(x)",
lc="b",
marker="D",
marker="s", # o, p, *, h, D, d , v, ^, s, x, a
)

##############
show(plt1, plt2, bg="w", axes=1)
3 changes: 3 additions & 0 deletions examples/plotting2d/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ echo
echo Running annotations.py
python annotations.py

echo Running axesStyle.py
python axesStyle.py

echo Running customAxes.py
python customAxes.py

Expand Down
14 changes: 7 additions & 7 deletions examples/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ vtkplotter


##################################### not run/ignored:
#basic/lights.py
#plotting2d/text_just.py
#other/makeVideo.py
#other/spherical_harmonics2.py
#other/remesh_ACVD.py
#other/tf_learn_embryo.py
#other/self_org_maps3d.py
# examples/basic/lights.py
# examples/plotting2d/text_just.py
# examples/other/makeVideo.py
# examples/other/spherical_harmonics2.py
# examples/other/remesh_ACVD.py
# examples/other/tf_learn_embryo.py
# examples/other/self_org_maps3d.py
2 changes: 1 addition & 1 deletion examples/simulations/hanoi3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def demo3d_hanoi(**kwargs):
}
for k in disks:
vp += disks[k]
vp += Box(pos=(3.0, 0, -0.05), length=12.0, width=4.0, height=0.1)
vp += Box(pos=(3.0, 0, -.5), length=12.0, width=4.0, height=0.1)
vp.show(zoom=1.2)

printc("\n Press q to continue, Esc to exit. ", c="y", invert=1)
Expand Down
2 changes: 1 addition & 1 deletion examples/volumetric/numpy2volume.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e2c9bea738bf4d44834a41fb1213eacb",
"model_id": "884bf91fb6dc4413add52b6dc0574aba",
"version_major": 2,
"version_minor": 0
},
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
verstrline = open(VERSIONFILE, "rt").read()
verstr = verstrline.split('=')[1].replace('\n','').replace("'","")
except:
verstr='unknown_version'
verstr='unknown'

##############################################################
setup(
Expand Down Expand Up @@ -50,11 +50,12 @@
# pip install .

# cd examples && ./run_all.sh
# python tutorial.py
# cd ~/Projects/vtkplotter/
# python tests/test_filetypes.py

# check vtkconvert:
# vtkconvert vtkplotter/data/290.vtk -to ply
# vtkconvert vtkplotter/data/290.vtk -to ply; vtkplotter vtkplotter/data/290.ply

# check on python2 the same stuff is ok
# cd ~/Projects/vtkplotter/
Expand All @@ -63,7 +64,7 @@

# check notebooks:
# cd ~/Projects/vtkplotter/
# jupyter notebook &
# jupyter notebook > /dev/null 2>&1
# remove trailing spaces

# cd ~/Projects/vtkplotter/
Expand All @@ -72,7 +73,7 @@
# rm examples/other/trimesh/featuretype.STL examples/other/trimesh/machinist.XAML
# rm examples/other/scene.npy examples/other/timecourse1d.npy vtkplotter/data/290.ply
# rm examples/other/voronoi3d.txt examples/other/voronoi3d.txt.vol
# rm examples/other/embryo.html examples/other/embryo.x3d timecourse1d.npy
# rm examples/other/embryo.html examples/other/embryo.x3d

# git status
# git add [files]
Expand Down
3 changes: 3 additions & 0 deletions vtkplotter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
- `examples/advanced <https://github.com/marcomusy/vtkplotter/blob/master/examples/advanced>`_ ,
- `examples/volumetric <https://github.com/marcomusy/vtkplotter/blob/master/examples/volumetric>`_,
- `examples/simulations <https://github.com/marcomusy/vtkplotter/blob/master/examples/simulations>`_
- `examples/plotting2d <https://github.com/marcomusy/vtkplotter/blob/master/examples/plotting2d>`_
- `examples/others <https://github.com/marcomusy/vtkplotter/blob/master/examples/other>`_.
- `examples/others/dolfin <https://github.com/marcomusy/vtkplotter/blob/master/examples/other/dolfin>`_.
- `examples/others/trimesh <https://github.com/marcomusy/vtkplotter/blob/master/examples/other/trimesh>`_.
Publications where ``vtkplotter`` has been used so far:
Expand Down
Loading

0 comments on commit 884d8b0

Please sign in to comment.