newton.utils.MeshAdjacency#

class newton.utils.MeshAdjacency(indices, num_tris)[source]#

Bases: object

Builds and stores edge adjacency information for a triangle mesh.

This class processes triangle indices to create a mapping from edges to their adjacent triangles. Each edge stores references to both adjacent triangles (if they exist) along with the opposite vertices.

edges#

Dictionary mapping edge keys (min_vertex, max_vertex) to MeshEdge objects.

indices#

The original triangle indices used to build the adjacency.

__init__(indices, num_tris)#

Build edge adjacency from triangle indices.

Parameters:
  • indices – Array-like of triangle indices, where each element is a sequence of 3 vertex indices defining a triangle.

  • num_tris – Number of triangles (currently unused, kept for API compatibility).

add_edge(i0, i1, o, f)#

Add or update an edge in the adjacency structure.

If the edge already exists, updates it with the second adjacent triangle. If the edge would have more than two adjacent triangles, prints a warning (non-manifold edge).

Parameters:
  • i0 – Index of the first vertex of the edge.

  • i1 – Index of the second vertex of the edge.

  • o – Index of the opposite vertex in the triangle.

  • f – Index of the triangle containing this edge.