IGLStdPrs

Module: graphics

GPU mesh wrapper for creating model presentations in OpenGL. Supports rendering of triangles (non-indexed) and lines (non-indexed), with optional attributes for face IDs (integer, for picking) and values (float, for contouring).

__init__

method
__init__(self, vertices, indices, face_ids, values, primitive)
Initializes the IGLStdPrs object with mesh data and prepares for GPU rendering.

Args

Name Type Description
vertices Array-like of vertex positions, shape (N, 3), where N is the number of vertices.
indices Optional array-like of triangle indices, shape (M, 3) or flattened (M*3,), for indexed meshes.
face_ids Optional array-like of face IDs, shape (M,), for picking support.
values Optional array-like of scalar values, shape (M,), for contouring.
primitive Rendering primitive type, either "triangles" or "lines". Defaults to "triangles".

_build

method
_build(self)

build_expanded_vertices

method
build_expanded_vertices(self)
Converts an indexed mesh to an expanded vertex array for glDrawArrays rendering.

Expands vertices, face_ids, and values based on triangle indices to support
non-indexed drawing. Updates self.vertices, self.face_ids, and self.count.

Returns

None

compute_triangle_normals

method
compute_triangle_normals(self, vertices)
Computes per-vertex normals for triangle meshes from expanded vertex positions.

Args

Name Type Description
vertices Expanded vertex array, shape (N, 3), where N is a multiple of 3.

Returns

numpy.ndarray: Per-vertex normals, shape (N, 3), as float32.

draw

method
draw(self)
Renders the mesh using OpenGL draw calls. Builds VAOs and VBOs if not already created. Supports triangles and lines primitives.

delete

method
delete(self)
Cleans up OpenGL resources by deleting VAOs and VBOs.