# Extract Surface#

You can extract the surface of nearly any object within `pyvista` using the `extract_surface` filter.

```import numpy as np

import pyvista as pv
from pyvista import CellType
```

# Create a quadratic cell and extract its surface#

Here we create a single quadratic hexahedral cell and then extract its surface to demonstrate how to extract the surface of an UnstructuredGrid.

```lin_pts = np.array(
[
[-1, -1, -1],  # point 0
[1, -1, -1],  # point 1
[1, 1, -1],  # point 2
[-1, 1, -1],  # point 3
[-1, -1, 1],  # point 4
[1, -1, 1],  # point 5
[1, 1, 1],  # point 6
[-1, 1, 1],  # point 7
],
np.double,
)

# these are the "midside" points of a quad cell.  See the definition of a
[
(lin_pts + lin_pts) / 2,  # between point 0 and 1
(lin_pts + lin_pts) / 2,  # between point 1 and 2
(lin_pts + lin_pts) / 2,  # and so on...
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
(lin_pts + lin_pts) / 2,
]
)

# introduce a minor variation to the location of the mid-side points

# create the grid

# If you are using vtk>=9, you do not need the offset array
offset = np.array()
cells = np.hstack((20, np.arange(20))).astype(np.int64, copy=False)
grid = pv.UnstructuredGrid(offset, cells, celltypes, pts)

# finally, extract the surface and plot it
surf = grid.extract_surface()
surf.plot(show_scalar_bar=False)
``` ```/home/runner/work/pyvista/pyvista/examples/01-filter/extract-surface.py:69: UserWarning: VTK 9 no longer accepts an offset array
grid = pv.UnstructuredGrid(offset, cells, celltypes, pts)
```

# Nonlinear Surface Subdivision#

Should your UnstructuredGrid contain quadratic cells, you can generate a smooth surface based on the position of the “mid-edge” nodes. This allows the plotting of cells containing curvature. For additional reference, please see: https://prod.sandia.gov/techlib-noauth/access-control.cgi/2004/041617.pdf

```surf_subdivided = grid.extract_surface(nonlinear_subdivision=5)
surf_subdivided.plot(show_scalar_bar=False)
``` Total running time of the script: ( 0 minutes 0.457 seconds)

Gallery generated by Sphinx-Gallery