Skip to content

Commit

Permalink
reset plotter.load
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Aug 29, 2021
1 parent 51298fb commit 84687db
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
8 changes: 3 additions & 5 deletions examples/advanced/quadratic_morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
The fitting minimizes the distance to the target surface
using algorithms available in the scipy.optimize package.
"""
from __future__ import division, print_function

print(__doc__)

from vedo import *
import scipy.optimize as opt

print(__doc__)

settings.useDepthPeeling = True

plt = Plotter(shape=[1, 3], interactive=0, axes=1)

Expand Down Expand Up @@ -51,7 +50,6 @@ def _func(self, pars):
#calculate chi2
d2sum, n = 0.0, self.source.N()
srcpts = self.source.points()
mpts = self.msource.points()
rng = range(0, n, int(n / self.subsample))
for i in rng:
p1 = srcpts[i]
Expand Down
5 changes: 1 addition & 4 deletions examples/basic/closewindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
vp2.closeWindow()
printc('vp2.closeWindow() called')

vp3.show(Hyperboloid())

from vedo import closeWindow
closeWindow() # automatically find and close the current window
vp3.show(Hyperboloid()).close()

printc('done.')
31 changes: 30 additions & 1 deletion vedo/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,36 @@ def __iadd__(self, actors):
def __isub__(self, actors):
self.remove(actors, render=False)
return self


def load(self, filename, unpack=True, force=False):
"""
Load objects from file.
The output will depend on the file extension. See examples below.
:param bool unpack: only for multiblock data,
if True returns a flat list of objects.
:param bool force: when downloading a file ignore any previous
cached downloads and force a new one.
:Example:
.. code-block:: python
from vedo import *
# Return a list of 2 Mesh
g = load([dataurl+'250.vtk', dataurl+'290.vtk'])
show(g)
# Return a list of meshes by reading all files in a directory
# (if directory contains DICOM files then a Volume is returned)
g = load('mydicomdir/')
show(g)
# Return a Volume. Color/Opacity transfer function can be specified too.
g = load(dataurl+'embryo.slc')
g.c(['y','lb','w']).alpha((0.0, 0.4, 0.9, 1)).show()
"""
acts = vedo.io.load(filename, unpack, force)
if utils.isSequence(acts):
self.actors += acts
else:
self.actors.append(acts)
return acts

def add(self, actors, at=None, render=True, resetcam=False):
"""Append input object to the internal list of actors to be shown.
Expand Down

0 comments on commit 84687db

Please sign in to comment.