mesh_split_face

compas.datastructures.mesh_split_face(mesh, fkey, u, v)[source]

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

Parameters
  • mesh (Mesh) – Instance of a mesh

  • fkey (str) – The face key.

  • u (hashable) – The key of the first split vertex.

  • v (hashable) – The key of the second split vertex.

Returns

tuple of 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"))
>>> fkey = mesh.get_any_face()
>>> # u and v defines the new edge after splitting
>>> u = mesh.get_any_face_vertex(fkey)
>>> v = mesh.face_vertex_descendant(fkey, u, n=2)
>>> mesh.number_of_faces()  # faces before split
25
>>> mesh_split_face(mesh, fkey, u, v)
(25, 26)
>>> mesh.number_of_faces()  # faces after split
26