{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to load a mesh from a file?" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import tempfile\n", "\n", "import meshio\n", "\n", "from geomfum.dataset import NotebooksDataset\n", "from geomfum.shape import PointCloud, TriangleMesh" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(7207, 14410)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset = NotebooksDataset()\n", "path = dataset.get_filename(\"cat-00\") #Here you should use the path to your mesh file\n", "mesh = TriangleMesh.from_file(path)\n", "\n", "mesh.n_vertices, mesh.n_faces" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Imagine instead of a mesh, you want to handle point clouds.\n", "\n", "(We emulate this use case by writing the above mesh to disk.)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "filename = tempfile.NamedTemporaryFile(mode=\"w+t\", delete=True, suffix=\".ply\").name\n", "\n", "meshio.write(filename, meshio.Mesh(points=mesh.vertices, cells=[]))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "7207" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "point_cloud = PointCloud.from_file(filename)\n", "\n", "point_cloud.n_vertices" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Further reading\n", "\n", "* [How to compute the mesh Laplacian?](./01_mesh_laplacian.ipynb)\n", "\n", "* [How to compute the mesh Laplacian spectrum?](./02_mesh_laplacian_spectrum.ipynb)" ] } ], "metadata": { "kernelspec": { "display_name": "VENV", "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.12.3" } }, "nbformat": 4, "nbformat_minor": 2 }