parq_blockmodel.mesh.types.TriangleMesh#

class parq_blockmodel.mesh.types.TriangleMesh(vertices, faces, vertex_attributes=None, face_attributes=None, vertex_ijk=None, face_ijk=None, metadata=None)[source]#

Representation of a triangle mesh with optional attributes.

This is the internal mesh format used by the mesh module. It can be serialized to PLY (lossless) or GLB (derived) formats.

vertices#

Vertex coordinates, shape (n_vertices, 3) in world space.

Type:

np.ndarray

faces#

Triangle face indices, shape (n_faces, 3). Each row is a CCW-ordered triangle when viewed from the exterior (right-handed coordinates).

Type:

np.ndarray

vertex_attributes#

Per-vertex scalar attributes, e.g. {“grade”: (n_vertices,), “density”: (n_vertices,)}.

Type:

dict[str, np.ndarray]

face_attributes#

Per-face scalar attributes, e.g. {“rock_type”: (n_faces,)}.

Type:

dict[str, np.ndarray]

vertex_ijk#

Logical (i, j, k) indices for each vertex, shape (n_vertices, 3). Useful for tracing back to block model.

Type:

Optional[np.ndarray]

face_ijk#

Logical (i, j, k) indices for each face (typically the block containing it), shape (n_faces, 3).

Type:

Optional[np.ndarray]

metadata#

Arbitrary metadata, e.g. CRS, units, author, etc.

Type:

dict

__init__(vertices, faces, vertex_attributes=None, face_attributes=None, vertex_ijk=None, face_ijk=None, metadata=None)#

Methods

__init__(vertices, faces[, ...])

validate()

Validate mesh integrity.

Attributes

face_attributes

face_ijk

metadata

n_faces

Number of faces (triangles).

n_vertices

Number of vertices.

vertex_attributes

vertex_ijk

vertices

faces

property n_faces: int#

Number of faces (triangles).

property n_vertices: int#

Number of vertices.

validate()[source]#

Validate mesh integrity.

Raises:

ValueError – If mesh is malformed (e.g., vertices not 3D, faces have invalid indices).

Return type:

None