Mesh.split_face

Mesh.split_face(fkey, u, v)[source]

Split a face by inserting an edge between two specified vertices.

Parameters:
meshcompas.datastructures.Mesh

Instance of a mesh

fkeyint

The face key.

uint

The key of the first split vertex.

vint

The key of the second split vertex.

Returns:
tuple[int, int]

Keys of the created faces.

Raises:
ValueError

If the split vertices does not belong to the split face or if the split vertices are neighbors.

Examples

>>> import compas
>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_obj(compas.get("faces.obj"))
>>> face = mesh.face_sample(size=1)[0]
>>> # u and v defines the new edge after splitting
>>> u = mesh.face_vertices(face)[0]
>>> v = mesh.face_vertex_descendant(face, u, n=2)
>>> mesh.number_of_faces()  # faces before split
25
>>> mesh_split_face(mesh, face, u, v)
(25, 26)
>>> mesh.number_of_faces()  # faces after split
26