Skip to content

Commit

Permalink
3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed May 16, 2019
1 parent 91defa4 commit 52fe0fe
Show file tree
Hide file tree
Showing 41 changed files with 1,024 additions and 869 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ for all the following functionalities:
- Find the intersection of a mesh with a line (or with another mesh).
- Analysis of *Point Clouds*:
- *Moving Least Squares* smoothing of 2D, 3D and 4D clouds
- Fit lines, planes and spheres in space
- Perform PCA (Principal Component Analysis) on point coordinates
- Fit lines, planes and spheres and ellipses in space
- Identify outliers in a distribution of points
- Decimate a cloud to a uniform distribution.
- Basic histogramming and function plotting in 1D and 2D.
Expand Down
15 changes: 10 additions & 5 deletions bin/vtkplotter
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ elif args.slicer:
########################################################################
# normal mode for single VOXEL file with Isosurface Slider
elif nfiles == 1 and (".slc" in args.files[0] or ".vti" in args.files[0] or ".tif" in args.files[0]):
from vtkplotter import loadImageData, Actor, legosurface, printHistogram
from vtkplotter import Actor, legosurface
from vtkplotter.vtkio import loadImageData

image = loadImageData(args.files[0])
scrange = image.GetScalarRange()
Expand Down Expand Up @@ -392,7 +393,7 @@ elif nfiles == 1 and (".slc" in args.files[0] or ".vti" in args.files[0] or ".ti

cf.SetValue(0, threshold)
cf.Update()
act = Actor(cf.GetOutput(), ic, alpha=abs(args.alpha), wire=args.wireframe)
act = Actor(cf.GetOutput(), ic, alpha=abs(args.alpha)).wire(args.wireframe)
act.phong()

############################## threshold slider
Expand All @@ -403,7 +404,7 @@ elif nfiles == 1 and (".slc" in args.files[0] or ".vti" in args.files[0] or ".ti
cf.SetValue(0, widget.GetRepresentation().GetValue())
cf.Update()
poly = cf.GetOutput()
a = Actor(poly, ic, alpha=act.alpha(), wire=args.wireframe)
a = Actor(poly, ic, alpha=act.alpha()).wire(args.wireframe)
a.phong()
vp.actors = []
vp.renderer.RemoveActor(vp.getActors()[0])
Expand Down Expand Up @@ -461,7 +462,9 @@ elif (not args.scrolling_mode) or nfiles == 1:
if args.show_scalars:
ic = None

actor = vp.load(f, c=ic, alpha=alpha, wire=wire)
actor = vp.load(f, c=ic, alpha=alpha)
if hasattr(actor, 'wire'):
actor.wire(wire)

if leg:
actor.legend(os.path.basename(f))
Expand Down Expand Up @@ -509,7 +512,9 @@ else:
if args.show_scalars:
ic = None

actor = vp.load(f, c=ic, alpha=alpha, wire=wire)
actor = vp.load(f, c=ic, alpha=alpha)
if hasattr(actor, 'wire'):
actor.wire(wire)
actor.legend(leg)
actors.append(actor)
if args.point_size > 0:
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/fatlimb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

vp = Plotter(axes=0, verbose=0, bg="w")

s = vp.load(datadir+"290.vtk", c="red", bc="plum")
s = vp.load(datadir+"290.vtk", c="red")
c = s.centerOfMass()
vp.add(Point(c))

Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/mesh_smoothers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
vp = Plotter(shape=(1, 3), axes=4)

# Load a mesh and show it
a0 = vp.load(datadir+"embryo.tif", c="v")
a0 = vp.load(datadir+"embryo.tif", threshold=True, c="v")
vp.show(a0, at=0)

# Adjust mesh using Laplacian smoothing
Expand Down
3 changes: 2 additions & 1 deletion examples/advanced/quadratic_morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def draw_shapes(self):

mr = Morpher()
mr.source = vp.load(datadir+"270.vtk", c="g", alpha=0.4)
mr.target = vp.load(datadir+"290.vtk", c="b", alpha=0.3, wire=1)
mr.target = vp.load(datadir+"290.vtk", c="b", alpha=0.3)
mr.target.wireframe()
mr.allowScaling = True
mr.bound = 0.4 # limits the parameter value

Expand Down
18 changes: 18 additions & 0 deletions examples/basic/buildmesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Manually build a mesh.
"""
from vtkplotter import Actor, Text, show

verts = [(50,50,50), (70,40,50), (50,40,80), (80,70,50)]
faces = [(0,1,2), (2,1,3), (1,0,3)]
# (the first triangle face is formed by vertex 0, 1 and 2)

a = Actor([verts, faces])
a.backColor('violet').lineColor('black').lineWidth(1)

# the way vertices are assembled into polygons can be retrieved
# in two different formats:
print('getCells() format is :', a.getCells())
print('getConnectivity() format is:', a.getConnectivity())

show(a, Text(__doc__), viewup='z', axes=8)
17 changes: 0 additions & 17 deletions examples/basic/buildpolydata.py

This file was deleted.

10 changes: 5 additions & 5 deletions examples/basic/cutter.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
Load a vtkImageData (tif stack) and convert on the the fly to an isosurface.
Invoke a tool to cut off parts of a mesh
Press X to save the mesh or to add new cut planes
Load a Volume (atif stack).
Invoke a tool to cut off parts of it.
"""
print(__doc__)

from vtkplotter import Plotter, datadir


vp = Plotter(axes=4, bg="w")
vp = Plotter(axes=4)

act = vp.load(datadir+"embryo.tif", c="blue")
act = vp.load(datadir+"embryo.tif")

vp.addCutterTool(act)
vp.show()
2 changes: 1 addition & 1 deletion examples/basic/largestregion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from vtkplotter import *


act1 = load(datadir+"embryo.slc", c="y")
act1 = load(datadir+"embryo.slc", threshold=True, c="y")
printc("area1 =", act1.area(), c="y")

act2 = extractLargestRegion(act1).color("b")
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/manyspheres.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# all have same radius but different colors:
s0 = Spheres(pts, c=cols, r=0.1, res=3) # res= theta-phi resolution

# all have same color (texture) but different radius along y:
s1 = Spheres(pts, r=rads, c="lb", res=8).texture('marble')
# all have same color but different radius along y:
s1 = Spheres(pts, r=rads, c="lb", res=8)

print("..rendering spheres:", N * 2)
show(s0, at=0, N=2, axes=2, viewup=(-0.7, 0.7, 0))
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/multiblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
scals = cube.coordinates()[:,1]
poly = cube.addPointScalars(scals, 'scalsname').polydata()

img = loadImageData(datadir+'vase.vti')
img = load(datadir+'vase.vti').imagedata()

filename = "multiblock.vtm"

Expand All @@ -16,8 +16,8 @@
"and corresponding directory", c='g')

# load back from file into a list of actors/volumes
acts = loadMultiBlockData(filename)
mbacts = load(filename) # loads and unpacks a MultiBlockData obj

show(acts, Text('loadMultiBlockData("file.vtm")', c='k'), bg='w')
show(mbacts, Text('load("file.vtm") #MultiBlockData', c='k'), bg='w')

show(mblock, Text('show(multiblock)'), newPlotter=True, pos=(800,0))
show(mblock, Text('show(multiblock)', c='w'), newPlotter=True, pos=(800,0))
2 changes: 1 addition & 1 deletion examples/other/dolfin/elastodynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def local_project(v, V, u=None):
energies[i+1, :] = np.array([E_elas, E_kin, E_damp, E_tot])

plot(u, box, tex,
mode='warped mesh',
mode='displace',
style='matplotlib',
axes=0, # no axes
scalarbar=False,
Expand Down
4 changes: 2 additions & 2 deletions examples/other/dolfin/ex06_elasticity2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
~pin alpha=0.2, depthpeeling=True
~pin mode='mesh warp lines', lw=.05""", c='blue')

plot(u, mode='my warped mesh please!!', azimuth=45)
exportWindow('ex06_elasticity2.x3d')
plot(u, mode='my displaced mesh please!!', azimuth=45)
#exportWindow('ex06_elasticity2.x3d')

printc('~smile Thanks for using vtkplotter!', c='green')
2 changes: 1 addition & 1 deletion examples/other/export_x3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
x3dom and vtkplotter"""
from vtkplotter import *

e = load(datadir+'embryo.tif').decimate(0.5)
e = load(datadir+'embryo.tif', threshold=True).decimate(0.5)
ec = e.coordinates()
e.pointColors(ec[:,1]) # add dummy colors along y

Expand Down
4 changes: 2 additions & 2 deletions examples/other/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
and place it in one of the 4 corners
within the same renderer.
"""
from vtkplotter import Plotter, load, Text, datadir
from vtkplotter import *


vp = Plotter(axes=5, bg="white")
# axes type 5 builds an annotated orientation cube

vp.load(datadir+"270.vtk", c="blue", bc="v")
vp.load(datadir+'porsche.ply').lighting('metallic')

vp.show(interactive=0)

Expand Down
3 changes: 2 additions & 1 deletion examples/other/inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

vp = Plotter(axes=1, bg="white")

e = load(datadir+"embryo.tif").normalize().c("gold")
e = load(datadir+"embryo.tif", threshold=True) # automatic isosurfacing
e.normalize().c("gold")
msg = Text(__doc__)

vp.show(e, msg, viewup='z', interactive=0)
Expand Down
Loading

0 comments on commit 52fe0fe

Please sign in to comment.