pycanha_core.gmm — Geometry and Mesh Classes#

The gmm submodule exposes the geometric primitives, meshes, and scene graph types used by the thermal model.

Primitives#

class Triangle(*args, **kwargs)#

Bases: object

Triangular flat surface defined by three 3D vertices.

__init__#

Create a triangle from three 3D vertex positions.

is_valid#

Whether the primitive geometry is valid.

normal_at_uv#

Outward surface normal at a 2D parametric (uv) point.

property p1#

First vertex.

property p2#

Second vertex.

property p3#

Third vertex.

surface_area#

Total surface area.

to_cartesian#

Map a 2D parametric (uv) point back to 3D space.

to_uv#

Project a 3D point onto the primitive’s 2D parametric (uv) space.

class Rectangle(*args, **kwargs)#

Bases: object

Rectangular flat surface defined by three vertices (the fourth is derived): p1->p2 is one edge, p1->p3 the adjacent edge.

__init__#

Create a rectangle from three corner positions.

is_valid#

Whether the primitive geometry is valid.

normal_at_uv#

Outward surface normal at a 2D parametric (uv) point.

property p1#

Origin vertex.

property p2#

Second vertex (first edge from p1).

property p3#

Third vertex (second edge from p1).

surface_area#

Total surface area.

to_cartesian#

Map a 2D parametric (uv) point back to 3D space.

to_uv#

Project a 3D point onto the primitive’s 2D parametric (uv) space.

class Quadrilateral(*args, **kwargs)#

Bases: object

General quadrilateral surface defined by four vertices (may be non-planar).

__init__#

Create a quadrilateral from four 3D vertex positions.

is_valid#

Whether the primitive geometry is valid.

normal_at_uv#

Outward surface normal at a 2D parametric (uv) point.

property p1#

First vertex.

property p2#

Second vertex.

property p3#

Third vertex.

property p4#

Fourth vertex.

surface_area#

Total surface area.

to_cartesian#

Map a 2D parametric (uv) point back to 3D space.

to_uv#

Project a 3D point onto the primitive’s 2D parametric (uv) space.

class Cylinder(*args, **kwargs)#

Bases: object

Cylindrical surface segment defined by axis, radius, and angular extent.

__init__#

Create a cylinder from axis points, reference, radius, and angles.

property end_angle#

End angle [rad].

is_valid#

Whether the primitive geometry is valid.

normal_at_uv#

Outward surface normal at a 2D parametric (uv) point.

property p1#

Base center position.

property p2#

Top center position.

property p3#

Reference point for the angle origin.

property radius#

Cylinder radius.

property start_angle#

Start angle [rad].

surface_area#

Total surface area.

to_cartesian#

Map a 2D parametric (uv) point back to 3D space.

to_uv#

Project a 3D point onto the primitive’s 2D parametric (uv) space.

class Disc(*args, **kwargs)#

Bases: object

Annular disc (flat ring) segment defined by center, normal, inner/outer radii, and angular extent.

__init__#

Create a disc from center, normal ref, radii, and angles.

property end_angle#

End angle [rad].

property inner_radius#

Inner radius (0 for a full disc).

is_valid#

Whether the primitive geometry is valid.

normal_at_uv#

Outward surface normal at a 2D parametric (uv) point.

property outer_radius#

Outer radius.

property p1#

Center position.

property p2#

Normal direction reference point.

property p3#

Reference point for the angle origin.

property start_angle#

Start angle [rad].

surface_area#

Total surface area.

to_cartesian#

Map a 2D parametric (uv) point back to 3D space.

to_uv#

Project a 3D point onto the primitive’s 2D parametric (uv) space.

class Cone(*args, **kwargs)#

Bases: object

Conical (frustum) surface segment defined by axis, two radii, and angular extent.

__init__#

Create a cone from axis points, reference, radii, and angles.

property end_angle#

End angle [rad].

is_valid#

Whether the primitive geometry is valid.

normal_at_uv#

Outward surface normal at a 2D parametric (uv) point.

property p1#

Base center position.

property p2#

Top center position.

property p3#

Reference point for the angle origin.

property radius1#

Radius at the base (p1 end).

property radius2#

Radius at the top (p2 end).

property start_angle#

Start angle [rad].

surface_area#

Total surface area.

to_cartesian#

Map a 2D parametric (uv) point back to 3D space.

to_uv#

Project a 3D point onto the primitive’s 2D parametric (uv) space.

class Sphere(*args, **kwargs)#

Bases: object

Spherical surface segment with optional base/apex truncation and angular extent.

__init__#

Create a sphere segment from center, axis, reference, radius, truncations, and angular extent.

property apex_truncation#

Apex truncation (0 = no truncation).

property base_truncation#

Base truncation (0 = no truncation).

property end_angle#

End angle [rad].

is_valid#

Whether the primitive geometry is valid.

normal_at_uv#

Outward surface normal at a 2D parametric (uv) point.

property p1#

Center position.

property p2#

Axis direction reference point.

property p3#

Reference point for the angle origin.

property radius#

Sphere radius.

property start_angle#

Start angle [rad].

surface_area#

Total surface area.

to_cartesian#

Map a 2D parametric (uv) point back to 3D space.

to_uv#

Project a 3D point onto the primitive’s 2D parametric (uv) space.

Meshes#

class ThermalMesh(*args, **kwargs)#

Bases: object

Per-primitive thermal discretization (UV cuts + per-side properties + tmm-node assignment).

__init__#

Overloaded function.

  1. __init__(self) -> None

Default unit square with one face pair.

  1. __init__(self, dir1_mesh: collections.abc.Sequence[float], dir2_mesh: collections.abc.Sequence[float]) -> None

Build directly from the two UV cut vectors.

property dir1_mesh#

UV cut positions along parametric direction 1.

property dir2_mesh#

UV cut positions along parametric direction 2.

is_valid#

Whether the mesh definition is valid.

property node1_start#

Front-side base node number (-1 = no node).

property node1_step#

Front-side per-cell node increment.

property node2_start#

Back-side base node number (-1 = no node).

property node2_step#

Back-side per-cell node increment.

node_of#

Node number for cell (i, j) on side 1 or 2.

property num_pair_faces#

(len(dir1_mesh) - 1) * (len(dir2_mesh) - 1) face pairs.

property side1_activity#

Front-side activity.

property side1_color#

Front-side color.

property side1_material#

Front-side bulk material (None if unassigned).

property side1_optical#

Front-side optical material (None if unassigned).

property side1_thick#

Front-side thickness [m].

property side2_activity#

Back-side activity.

property side2_color#

Back-side color.

property side2_material#

Back-side bulk material (None if unassigned).

property side2_optical#

Back-side optical material (None if unassigned).

property side2_thick#

Back-side thickness [m].

Transformations#

class CoordinateTransformation(*args, **kwargs)#

Bases: object

Rigid 3D transformation (translation + 3x3 rotation matrix).

__init__#

Overloaded function.

  1. __init__(self) -> None

Create an identity transformation.

  1. __init__(self, translation: numpy.ndarray[dtype=float64, shape=(3), order='C'], rotation: numpy.ndarray[dtype=float64, shape=(3, 3), order='F']) -> None

Create from a translation vector and a 3x3 rotation matrix.

apply#

Apply the full transformation to a 3D point.

apply_normal#

Apply only the rotation to a 3D direction/normal.

compose#

Compose with an outer transformation (outer applied after this).

from_euler = <nanobind.nb_func object>#
from_rotation = <nanobind.nb_func object>#
from_translation = <nanobind.nb_func object>#
inverse#

The inverse transformation.

is_identity#

Whether this is the identity transformation.

linear#

The linear (rotation) part as a 3x3 matrix.

property rotation#

3x3 rotation matrix.

property translation#

Translation vector [x, y, z].

Geometry hierarchy#

class Geometry#

Bases: object

Abstract base of the scene tree (GeometryItem, GeometryGroup, GeometryGroupCutted).

__init__(*args, **kwargs)#
property children#

Immediate children (empty for a GeometryItem).

create_mesh#

Force a rebuild of this object’s subtree mesh.

property id#

Ephemeral process-wide-unique runtime id (uint64).

property mesh#

Subtree mesh (TriMeshD) in the parent frame; lazily built.

property name#

Unique name within the model.

property owning_model#

The GeometryModel this object is registered with, or None.

property transform#

Coordinate transformation in the parent frame.

class GeometryItem(*args, **kwargs)#

Bases: Geometry

A single meshable primitive plus its ThermalMesh (a scene-tree leaf).

__init__#

Create a geometry item.

property mesh_options_override#

Per-item MeshOptions override (None to use model default).

property primitive#

The wrapped primitive.

property thermal_mesh#

The thermal mesh.

class GeometryGroup(*args, **kwargs)#

Bases: Geometry

A transform applied to a collection of child geometries.

__init__#

Create a geometry group.

add#

Append a child (rejects nullptr, registered, or duplicate nodes).

remove_child#

Remove a child; returns True if it was present.

class GeometryGroupCutted(*args, **kwargs)#

Bases: Geometry

Boolean-subtract group: every target is cut by the union of all cutters (each cutter must be a closed-solid GeometryItem).

__init__#

Create a cut group from targets and cutters.

cut_with#

Add another cutter (must be a closed-solid GeometryItem).

property cutters#

The cutter geometry items.

property targets#

The target geometries being cut.

class GeometryModel(*args, **kwargs)#

Bases: object

Top-level scene container: registers geometry, resolves names, owns the world mesh.

__init__#

Create a named geometry model.

add#

Register an object (and its subtree) under parent_name (root when empty).

property children#

Immediate children of the root group.

children_recursive#

All geometries in the tree (depth-first).

contains#

Overloaded function.

  1. contains(self, name: str) -> bool

Whether a geometry with this name is registered.

  1. contains(self, object: pycanha_core.pycanha_core.gmm.Geometry) -> bool

Whether this object is registered.

create_mesh#

Force a full rebuild of the world mesh.

property default_mesh_options#

Default MeshOptions applied to items without an override.

faces_of_node#

Face ids assigned to a node number (built at mesh build).

get#

Get a geometry by name (None if absent).

get_cut_group#

Get a GeometryGroupCutted by name (None if absent or wrong kind).

get_group#

Get a GeometryGroup by name (None if absent or wrong kind).

get_item#

Get a GeometryItem by name (None if absent or wrong kind).

get_structure_version#

Monotonic version bumped on every structural / content change.

invalidate_mesh#

Mark the world mesh dirty without rebuilding.

property mesh#

World mesh as float32 (TriMeshF); lazily built and cached.

property name#

Model name.

notify_content_changed#

Mark caches dirty after an external content edit.

remove#

Overloaded function.

  1. remove(self, name: str) -> None

Remove a geometry (and its subtree) by name.

  1. remove(self, object: pycanha_core.pycanha_core.gmm.Geometry) -> None

Remove a geometry (and its subtree).

rename#

Rename a registered geometry.

reparent#

Move a geometry under a new parent group.

property root_group#

The root GeometryGroup.

property root_group_mesh#

Float64 root-group mesh (TriMeshD), before float32 cast.

Mesh utility functions#