mesh_subdivide_tri

compas.datastructures.mesh_subdivide_tri(mesh, k=1)[source]

Subdivide a mesh using simple insertion of vertices.

Parameters
  • mesh (Mesh) – The mesh object that will be subdivided.

  • k (int, optional) – The number of levels of subdivision.

Returns

Mesh – A new subdivided mesh.

Examples

>>> from compas.geometry import Box
>>> from compas.datastructures import Mesh
>>> box = Box.from_corner_corner_height([0.0, 0.0, 0.0], [1.0, 1.0, 0.0], 1.0)
>>> mesh = Mesh.from_shape(box)
>>> k = 2
>>> subd = mesh_subdivide_tri(mesh, k=k)
>>> mesh is subd
False
>>> type(mesh) is type(subd)
True
>>> k1 = sum(len(mesh.face_vertices(fkey)) for fkey in mesh.faces())
>>> subd.number_of_faces() == (k1 if k == 1 else k1 * 3 ** (k - 1))
True