pyvista.PolyDataFilters.flip_faces

pyvista.PolyDataFilters.flip_faces#

PolyDataFilters.flip_faces(*, inplace: bool = False, progress_bar: bool = False)[source]#

Flip the orientation of the faces.

The flip is performed by reversing the order of indices in the cell connectivity list. In other libraries, this operation is sometimes referred to as “flip orientation”, “reverse cells”, “reverse face orientations”, or similar.

Note

Polygon cells have an implicitly-defined orientation, and reversing the ordering affects how normals are computed by filters like compute_normals().

Note

This filter does not modify any existing normals which may be present in the dataset. Use flip_normal_vectors() to flip the normal vectors.

Warning

This filter does not produce the correct output for TRIANGLE_STRIP cells, see https://gitlab.kitware.com/vtk/vtk/-/issues/18634. Use triangulate() to triangulate the mesh first.

Added in version 0.45.

Parameters:
inplacebool, default: False

Overwrites the original mesh in-place.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.PolyData

Mesh with flipped faces.

See also

pyvista.PolyDataFilters.flip_normal_vectors

Flip the direction of the point and cell normals.

pyvista.PolyDataFilters.compute_normals

Compute new normals. Includes the option to flip the normals.

pyvista.PolyData.point_normals

Returns the array of point normals.

pyvista.PolyData.cell_normals

Returns the array of cell normals.

Examples

Flip the faces of a sphere. Show the point ids of the first cell before and after the flip.

>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> sphere.regular_faces[0]
array([ 2, 30,  0])
>>> sphere_flipped = sphere.flip_faces()
>>> sphere_flipped.regular_faces[0]
array([ 0, 30,  2])

Note that the sphere also has pre-computed normals which have not been affected by this filter.

>>> sphere.point_data['Normals'][0]
pyvista_ndarray([0., 0., 1.], dtype=float32)
>>> sphere_flipped.point_data['Normals'][0]
pyvista_ndarray([0., 0., 1.], dtype=float32)

See Boolean Operations for more examples using this filter.