Debian Codegraph @

examples/01-filter/surface_reconstruction.py

raw
1 """
2 .. _surface_reconstruction_example:
3
4 Surface Reconstruction
5 ~~~~~~~~~~~~~~~~~~~~~~
6
7 Surface reconstruction has a dedicated filter in PyVista and is
8 handled by :func:`pyvista.PolyDataFilters.reconstruct_surface`. This
9 tends to perform much better than :func:`pyvista.DataSetFilters.delaunay_3d`.
10
11 """
12
13 import pyvista as pv
14
15 # %%
16 # Create a point cloud from a sphere and then reconstruct a surface from it.
17
18 points = pv.wrap(pv.Sphere().points)
19 surf = points.reconstruct_surface()
20 surf
21
22 # %%
23 # Plot the point cloud and the reconstructed sphere.
24
25 pl = pv.Plotter(shape=(1, 2))
26 pl.add_mesh(points)
27 pl.add_title('Point Cloud of 3D Surface')
28 pl.subplot(0, 1)
29 pl.add_mesh(surf, color=True, show_edges=True)
30 pl.add_title('Reconstructed Surface')
31 pl.show()
32 # %%
33 # .. tags:: filter