# yt.utilities.lib.mesh_triangulation module¶

This file contains code for triangulating unstructured meshes. That is, for every element in the mesh, it breaks up the element into some number of triangles, returning a triangle mesh instead.

It also contains code for removing duplicate triangles from the resulting mesh using a hash-table approach, so that we don’t waste time rendering impossible-to-see triangles.

This code is currently used by the OpenGL-accelerated unstructured mesh renderer, as well as when annotating mesh lines on regular slices.

class yt.utilities.lib.mesh_triangulation.MeshInfoHolder

Bases: object

class yt.utilities.lib.mesh_triangulation.TriSet

Bases: object

This is a hash table data structure for rapidly identifying the exterior triangles in a polygon mesh. We loop over each triangle in each element and update the TriSet for each one. We keep only the triangles that appear once, as these make up the exterior of the mesh.

get_exterior_tris()

Returns two numpy arrays, one storing the exterior triangle indices and the other storing the corresponding element ids.

yt.utilities.lib.mesh_triangulation.cull_interior_triangles()

This is used to remove interior triangles from the mesh before rendering it on the GPU.

yt.utilities.lib.mesh_triangulation.get_vertex_data()

This converts the data array from the shape (num_elem, conn_length) to (num_verts, ).

yt.utilities.lib.mesh_triangulation.triangulate_indices()

This is like triangulate_mesh, except it only considers the connectivity information, instead of also copying the vertex coordinates and the data values.

yt.utilities.lib.mesh_triangulation.triangulate_mesh()

This converts a mesh into a flattened triangle array suitable for rendering on the GPU.