IGLGeometry

Module: geometry

Represents a geometric object in an OpenGL-based viewer for graphics and FEA applications. This class encapsulates properties and methods for handling 3D geometry, including mesh data (nodes, triangles, edges), bounding boxes, display attributes, and serialization. It serves as a base class for specific geometry types like bodies and faces.

__init__

method
__init__(self, geom_id: int, name: str, selectable: bool)
Initializes an IGLGeometry instance.

Args

Name Type Description
geom_id Unique identifier for the geometry object. Defaults to 0.
name Human-readable name for the geometry. Defaults to an empty string.
selectable Whether the geometry can be selected in the viewer. Defaults to True.

ComputeBoundingBox

method
ComputeBoundingBox(self)
Computes the axis-aligned bounding box (AABB) for the geometry. This method calculates the minimum and maximum coordinates from the nodes and updates the viewBox. Override in derived classes for custom behavior.

GetBoundingBox

method
GetBoundingBox(self)
Retrieves the bounding box for the geometry.

Ensures the bounding box is up-to-date by calling ComputeBoundingBox.

Returns

The IGLBoundingBox instance representing the geometry's AABB.

GetType

method
GetType(self)
Gets the type of the geometry.

Returns

An integer representing the geometry type (e.g., from IGLShapeType enum).

GetID

method
GetID(self)
Gets the unique identifier of the geometry.

Returns

The geometry's ID as an integer.

SetID

method
SetID(self, geom_id: int)
Sets the unique identifier of the geometry.

Args

Name Type Description
geom_id The new ID to assign.

GetName

method
GetName(self)
Gets the name of the geometry.

Returns

The geometry's name as a string.

SetName

method
SetName(self, name: str)
Sets the name of the geometry.

Args

Name Type Description
name The new name to assign.

IsSelectable

method
IsSelectable(self)
Checks if the geometry is selectable.

Returns

True if the geometry is selectable, False otherwise.

SetSelectable

method
SetSelectable(self, flag: bool)
Sets the selectability of the geometry.

Args

Name Type Description
flag Boolean flag indicating if the geometry should be selectable.

__repr__

method
__repr__(self)
Returns a string representation of the geometry.

Returns

A string summarizing the geometry's ID, name, and selectability.

GetProperties

method
GetProperties(self)
Retrieves key properties of the geometry based on its type.

Returns

A dictionary of properties. For bodies, includes ID, Name, Material, and Volume. For faces, includes ID, Name, Material, and Surface Area. Empty dict for none type.

_generate_color

method
_generate_color(self)

GetNodes

method
GetNodes(self)
Gets the nodes (vertices) of the geometry mesh.

Returns

A NumPy array of shape (N, 3) with float32 values representing node coordinates, or None if not set.

Getfaces

method
Getfaces(self)
Gets the faces (triangles) of the geometry mesh.

Returns

A NumPy array of shape (M, 3) with uint32 values representing triangle indices, or None if not set.

Getedges

method
Getedges(self)
Gets the edges of the geometry mesh.

Returns

A NumPy array representing the edges, or None if not set.