{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Signed distance from mesh surface" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from vedo import *\n", "settings.default_backend = \"vtk\"" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
\n", "\n", "
\n", "vedo.mesh.Mesh
(...l.es/examples/data/panther.stl)\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
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
\n", "
" ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "msh = Mesh(dataurl + \"panther.stl\")\n", "msh" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
\n", "\n", "
\n", "vedo.mesh.Mesh\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
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
\n", "
" ], "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# create a Volume (3D Image) from a Mesh\n", "vol = msh.signed_distance(dims=[25,125,25])\n", "iso = vol.isosurface(0.0)\n", "iso" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "plt = Plotter()\n", "plt += iso.wireframe()\n", "\n", "for i in range(0, 25, 5):\n", " plt += vol.xslice(i).cmap(\"jet\")\n", "\n", "# vol.write(\"panther.tif\") #can save it this way.\n", "plt.show(axes=1)\n", "plt.close()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.10" } }, "nbformat": 4, "nbformat_minor": 2 }