{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Surface Reconstruction {#surface_reconstruction_example}\n\nSurface reconstruction has a dedicated filter in PyVista and is handled\nby `pyvista.PolyDataFilters.reconstruct_surface`{.interpreted-text\nrole=\"func\"}. This tends to perform much better than\n`pyvista.DataSetFilters.delaunay_3d`{.interpreted-text role=\"func\"}.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pyvista as pv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a point cloud from a sphere and then reconstruct a surface from\nit.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "points = pv.wrap(pv.Sphere().points)\nsurf = points.reconstruct_surface()\nsurf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot the point cloud and the reconstructed sphere.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "pl = pv.Plotter(shape=(1, 2))\npl.add_mesh(points)\npl.add_title('Point Cloud of 3D Surface')\npl.subplot(0, 1)\npl.add_mesh(surf, color=True, show_edges=True)\npl.add_title('Reconstructed Surface')\npl.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.2" } }, "nbformat": 4, "nbformat_minor": 0 }