trimesh_subdivide_loop

compas.datastructures.trimesh_subdivide_loop(mesh, k=1, fixed=None)[source]

Subdivide a triangle mesh using the Loop algorithm.

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

  • k (int) – Optional. The number of levels of subdivision. Default is 1.

  • fixed (list) – Optional. A list of fixed vertices. Default is None.

Returns

Mesh – A new subdivided mesh.

Examples

Make a low poly mesh from a box shape. Triangulate the faces.

>>> 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)
>>> mesh.quads_to_triangles()

Subdivide 2 times.

>>> k = 2
>>> subd = trimesh_subdivide_loop(mesh, k=k)

Compare low-poly cage with subdivision mesh.

>>> mesh is subd
False
>>> type(mesh) is type(subd)
True
>>> subd.number_of_faces() == mesh.number_of_faces() * (3 + 1) ** k
True