Extrusion of a surface mesh¶
Let us load some example data.
In [1]:
Copied!
import pyvista as pv
from pyvista import examples
dem = examples.download_crater_topo()
surfmesh = dem.extract_subset((500, 900, 400, 800, 0, 0), (5, 5, 1))
surfmesh = surfmesh.warp_by_scalar()
pv.set_jupyter_backend('static')
surfmesh.plot(notebook=True, show_edges=True)
import pyvista as pv
from pyvista import examples
dem = examples.download_crater_topo()
surfmesh = dem.extract_subset((500, 900, 400, 800, 0, 0), (5, 5, 1))
surfmesh = surfmesh.warp_by_scalar()
pv.set_jupyter_backend('static')
surfmesh.plot(notebook=True, show_edges=True)
Now we define the thickness of the layers for extruding this surface mesh. Because the type of the example data is a structured grid and layersfromsurf()
requires an unstructured grid, we first cast the type of the surface mesh to an unstructured grid. Finally we can extrude the surface mesh to a volume mesh.
This example is quoted from this example in Pyvista, but layersfromsurf()
is a one-liner and works for meshes consisting of quads, triangles and polygons.
In [2]:
Copied!
from voromesh import geo
import numpy as np
thickness = np.array([25] * 5 + [35] * 3 + [50] * 2 + [75, 100])
volmesh = geo.layersfromsurf(surfmesh.cast_to_unstructured_grid(), thickness)
cpos = [
(1826736.796308761, 5655837.275274233, 4676.8405505181745),
(1821066.1790519988, 5649248.765538796, 943.0995128226014),
(-0.2797856225380979, -0.27966946337594883, 0.9184252809434081),
]
volmesh.plot(notebook=True, show_edges=True, lighting=False, cpos=cpos)
from voromesh import geo
import numpy as np
thickness = np.array([25] * 5 + [35] * 3 + [50] * 2 + [75, 100])
volmesh = geo.layersfromsurf(surfmesh.cast_to_unstructured_grid(), thickness)
cpos = [
(1826736.796308761, 5655837.275274233, 4676.8405505181745),
(1821066.1790519988, 5649248.765538796, 943.0995128226014),
(-0.2797856225380979, -0.27966946337594883, 0.9184252809434081),
]
volmesh.plot(notebook=True, show_edges=True, lighting=False, cpos=cpos)