Signed distance from mesh surface#

from vedo import *
settings.default_backend = "vtk"
msh = Mesh(dataurl + "panther.stl")
msh

vedo.mesh.Mesh
(...l.es/examples/data/panther.stl)
bounds
(x/y/z)
-7.823 ... 18.48
-54.20 ... 53.85
0 ... 36.17
center of mass (4.40, -1.79, 15.8)
average size 33.409
nr. points / faces 287 / 570
# create a Volume (3D Image) from a Mesh
vol = msh.signed_distance(dims=[25,125,25])
iso = vol.isosurface(0.0)
iso

vedo.mesh.Mesh
bounds
(x/y/z)
-7.618 ... 17.43
-53.34 ... 52.99
0 ... 34.72
center of mass (4.05, -3.56, 19.5)
average size 27.064
nr. points / faces 8855 / 17508
point data array ImageScalars
plt = Plotter()
plt += iso.wireframe()

for i in range(0, 25, 5):
    plt += vol.xslice(i).cmap("jet")

# vol.write("panther.tif") #can save it this way.
plt.show(axes=1)
plt.close()