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 Primitive#
Bases:
objectBase class for geometric primitives.
- __init__(*args, **kwargs)#
- distance#
Signed distance from a point to the surface.
- distance_jacobian_cutted_surface#
Distance Jacobian w.r.t. the cutted surface parameters.
- distance_jacobian_cutting_surface#
Distance Jacobian w.r.t. the cutting surface parameters.
- from_2d_to_3d#
Map a 2D parametric point to 3D space.
- from_3d_to_2d#
Project a 3D point onto the 2D parametric space.
- is_valid#
Check whether the primitive geometry is valid.
- class Triangle(*args, **kwargs)#
Bases:
PrimitiveTriangular flat surface defined by three 3D vertices.
- __init__#
Create a triangle from three 3D vertex positions.
- create_mesh#
Create a triangular mesh of this primitive.
- distance#
- distance_jacobian_cutted_surface#
- distance_jacobian_cutting_surface#
- from_2d_to_3d#
- from_3d_to_2d#
- is_valid#
- property p1#
First vertex position.
- property p2#
Second vertex position.
- property p3#
Third vertex position.
- v1#
Edge vector p2 - p1.
- v2#
Edge vector p3 - p1.
- class Rectangle(*args, **kwargs)#
Bases:
PrimitiveRectangular flat surface defined by three vertices.
The fourth vertex is derived automatically. p1-p2 defines one edge, p1-p3 the adjacent edge.
- __init__#
Create a rectangle from three corner positions.
- create_mesh#
Create a triangular mesh of this primitive.
- distance#
- distance_jacobian_cutted_surface#
- distance_jacobian_cutting_surface#
- from_2d_to_3d#
- from_3d_to_2d#
- is_valid#
- property p1#
Origin vertex position.
- property p2#
Second vertex (defines first edge from p1).
- property p3#
Third vertex (defines second edge from p1).
- v1#
Edge vector p2 - p1.
- v2#
Edge vector p3 - p2.
- class Quadrilateral(*args, **kwargs)#
Bases:
PrimitiveGeneral quadrilateral surface defined by four vertices (may be non-planar).
- __init__#
Create a quadrilateral from four 3D vertex positions.
- create_mesh#
Create a triangular mesh of this primitive.
- distance#
- distance_jacobian_cutted_surface#
- distance_jacobian_cutting_surface#
- from_2d_to_3d#
- from_3d_to_2d#
- is_valid#
- property p1#
First vertex position.
- property p2#
Second vertex position.
- property p3#
Third vertex position.
- property p4#
Fourth vertex position.
- v1#
Edge vector p2 - p1.
- v2#
Edge vector p3 - p2.
- class Cylinder(*args, **kwargs)#
Bases:
PrimitiveCylindrical surface segment defined by axis, radius, and angular extent.
- __init__#
Create a cylinder from axis points, reference, radius, and angles.
- create_mesh#
Create a triangular mesh of this primitive.
- distance#
- distance_jacobian_cutted_surface#
- distance_jacobian_cutting_surface#
- property end_angle#
End angle [rad].
- from_2d_to_3d#
- from_3d_to_2d#
- is_valid#
- property p1#
Base center position.
- property p2#
Top center position.
- property p3#
Reference point for angle origin.
- property radius#
Cylinder radius.
- property start_angle#
Start angle [rad].
- class Disc(*args, **kwargs)#
Bases:
PrimitiveAnnular disc (flat ring) surface segment defined by center, normal, inner/outer radii, and angular extent.
- __init__#
Create a disc from center, normal ref, radii, and angles.
- create_mesh#
Create a triangular mesh of this primitive.
- distance#
- distance_jacobian_cutted_surface#
- distance_jacobian_cutting_surface#
- property end_angle#
End angle [rad].
- from_2d_to_3d#
- from_3d_to_2d#
- property inner_radius#
Inner radius (0 for a full disc).
- is_valid#
- property outer_radius#
Outer radius.
- property p1#
Center position.
- property p2#
Normal direction reference point.
- property p3#
Reference point for angle origin.
- property start_angle#
Start angle [rad].
- class Cone(*args, **kwargs)#
Bases:
PrimitiveConical (frustum) surface segment defined by axis, two radii, and angular extent.
- __init__#
Create a cone from axis points, reference, radii, and angles.
- create_mesh#
Create a triangular mesh of this primitive.
- distance#
- distance_jacobian_cutted_surface#
- distance_jacobian_cutting_surface#
- property end_angle#
End angle [rad].
- from_2d_to_3d#
- from_3d_to_2d#
- is_valid#
- property p1#
Base center position.
- property p2#
Top center position.
- property p3#
Reference point for angle origin.
- property radius1#
Radius at the base (p1 end).
- property radius2#
Radius at the top (p2 end).
- property start_angle#
Start angle [rad].
- class Sphere(*args, **kwargs)#
Bases:
PrimitiveSpherical surface segment with optional truncation at base and apex, and angular extent control.
- __init__#
Create a sphere segment from center, axis, reference, radius, truncation fractions, and angular extent.
- property apex_truncation#
Apex truncation fraction (0 = no truncation).
- property base_truncation#
Base truncation fraction (0 = no truncation).
- create_mesh#
Create a triangular mesh of this primitive.
- create_mesh2#
Create a triangular mesh (alternative algorithm).
- distance#
- distance_jacobian_cutted_surface#
- distance_jacobian_cutting_surface#
- property end_angle#
End angle [rad].
- from_2d_to_3d#
- from_3d_to_2d#
- is_valid#
- property p1#
Center position.
- property p2#
Axis direction reference point.
- property p3#
Reference point for angle origin.
- property radius#
Sphere radius.
- property start_angle#
Start angle [rad].
Meshes#
- class ThermalMesh(*args, **kwargs)#
Bases:
objectThermal and mesh properties for a geometry surface.
Defines two-sided surface properties (activity, thickness, color, bulk material, optical material) and mesh discretization in two parametric directions.
- __init__#
Create a ThermalMesh with default properties.
- property dir1_mesh#
Mesh division points in direction 1 (list from 0 to 1).
- property dir2_mesh#
Mesh division points in direction 2 (list from 0 to 1).
- is_valid#
Check whether the thermal mesh configuration is valid.
- property side1_activity#
Whether side 1 is thermally active.
- property side1_color#
RGB color of side 1.
- property side1_material#
Bulk material (density, specific heat, conductivity) of side 1.
- property side1_optical#
Optical material (emissivity/absorptivity) of side 1.
- property side1_thick#
Thickness of side 1.
- property side2_activity#
Whether side 2 is thermally active.
- property side2_color#
RGB color of side 2.
- property side2_material#
Bulk material (density, specific heat, conductivity) of side 2.
- property side2_optical#
Optical material (emissivity/absorptivity) of side 2.
- property side2_thick#
Thickness of side 2.
- class TriMesh(*args, **kwargs)#
Bases:
objectTriangulated surface mesh storing vertices, triangles, face IDs, edges, and per-surface colors.
- __init__#
Create a TriMesh from all mesh data arrays.
- property edges#
Edge list (vertex index pairs).
- property face_ids#
Face ID per triangle.
- property faces_edges#
Edges grouped by face.
- get_edges#
Get the edge list (vertex index pairs).
- get_face_cumareas#
Get cumulative area per triangle (requires sorted triangles).
- get_face_ids#
Get the face ID array.
- get_faces_edges#
Get edges grouped by face.
- get_perimeter_edges#
Get the perimeter edge indices.
- get_triangles#
Get triangle vertex indices as a numpy array (Nt x 3).
- get_vertices#
Get vertex coordinates as a numpy array (Nv x 3).
- property perimeter_edges#
Perimeter edge indices.
- set_edges#
Set the edge list.
- set_face_ids#
Set the face ID for each triangle.
- set_faces_edges#
Set edges grouped by face.
- set_perimeter_edges#
Set the perimeter edge indices.
- property surface1_color#
RGB color of surface side 1.
- property surface2_color#
RGB color of surface side 2.
- property triangles#
Triangle vertex indices (Nt x 3).
- property vertices#
Vertex coordinates (Nv x 3).
- class TriMeshModel(*args, **kwargs)#
Bases:
objectCompacted triangle mesh aggregating all geometry items into a single cache-friendly structure for rendering and ray-tracing.
- __init__#
Create an empty TriMeshModel.
- add_mesh#
Append a TriMesh to the unified model.
- property back_colors#
Back-side RGB colors per geometry.
- clear#
Remove all mesh data.
- property edges#
All edge vertex index pairs.
- property face_activity#
Face activity flags (-1=inactive, 0=both, 1/2=one side).
- property face_ids#
Face index per triangle.
- property faces_edges#
Edges grouped by face.
- property front_colors#
Front-side RGB colors per geometry.
- property geometries_edges#
Edge index ranges per geometry (Ng+1).
- property geometries_id#
Unique ID per geometry.
- property geometries_perimeter_edges#
Perimeter edge index ranges per geometry (Ng+1).
- property geometries_triangles#
Triangle index ranges per geometry (Ng+1).
- property geometries_vertices#
Vertex index ranges per geometry (Ng+1).
- get_face_cumareas#
Get cumulative area per triangle.
- get_geometry_mesh#
Extract a TriMesh for a single geometry by index.
- property n_faces#
Total number of distinct faces.
- property n_geometries#
Number of geometry items in the model.
- property opticals#
Optical properties per face (Nf x 6).
- property perimeter_edges#
All perimeter edge vertex index pairs.
- property triangles#
All triangle vertex indices (Nt x 3).
- property vertices#
All vertex coordinates (Nv x 3, float).
Transformations#
- class CoordinateTransformation(*args, **kwargs)#
Bases:
object3D coordinate transformation combining translation and rotation, with configurable application order.
- __init__#
Overloaded function.
__init__(self) -> None
Create an identity transformation.
__init__(self, translation: numpy.ndarray[dtype=float64, shape=(3), order='C'] = array([0., 0., 0.]), rotation: numpy.ndarray[dtype=float64, shape=(3), order='C'] = array([0., 0., 0.]), order: pycanha_core.pycanha_core.gmm.TransformOrder = TransformOrder.TRANSLATION_THEN_ROTATION) -> None
Create a transformation from translation vector, rotation angles (XYZ Euler), and application order.
- property order#
Order of translation and rotation operations.
- property rotation#
3x3 rotation matrix.
- transform_point#
Apply the transformation to a 3D point.
- property translation#
Translation vector [x, y, z].
Geometry hierarchy#
- class Geometry(*args, **kwargs)#
Bases:
objectBase class for all geometry elements.
Each geometry has a unique ID, a name, an optional coordinate transformation, and an optional parent group.
- __init__#
Overloaded function.
__init__(self) -> None
Create a geometry with auto-generated name.
__init__(self, name: str) -> None
Create a geometry with the given name.
__init__(self, name: str, transformation: pycanha_core.pycanha_core.gmm.CoordinateTransformation) -> None
Create a geometry with name and transformation.
- property name#
Geometry name.
- property parent#
Parent GeometryGroup (weak reference).
- property transformation#
Coordinate transformation applied to this geometry.
- class GeometryItem(*args, **kwargs)#
Bases:
GeometryGeometry element holding a single Primitive.
- __init__#
Overloaded function.
__init__(self) -> None
Create an empty geometry item.
__init__(self, name: str, primitive: pycanha_core.pycanha_core.gmm.Primitive, transformation: pycanha_core.pycanha_core.gmm.CoordinateTransformation) -> None
Create a geometry item with a primitive and transformation.
- property primitive#
The geometric Primitive of this item.
- class GeometryMeshedItem(*args, **kwargs)#
Bases:
GeometryItemGeometry item with thermal mesh properties and a generated triangle mesh.
- __init__#
Overloaded function.
__init__(self) -> None
Create an empty meshed geometry item.
__init__(self, name: str, primitive: pycanha_core.pycanha_core.gmm.Primitive, transformation: pycanha_core.pycanha_core.gmm.CoordinateTransformation, thermal_mesh: pycanha_core.pycanha_core.gmm.ThermalMesh) -> None
Create a meshed item with primitive, transform, and thermal mesh.
- property thermal_mesh#
ThermalMesh defining surface properties and mesh divisions.
- property tri_mesh#
Generated TriMesh (triangle mesh data).
- triangulate_post_processed_cutted_mesh#
Triangulate the mesh after cutting post-processing.
- class GeometryGroup(*args, **kwargs)#
Bases:
GeometryHierarchical container of GeometryMeshedItems, sub-groups, and cutted groups. Applies a shared transformation to all children.
- __init__#
Overloaded function.
__init__(self) -> None
Create an empty geometry group.
__init__(self, name: str) -> None
Create a geometry group with the given name.
__init__(self, name: str, geometry_items: collections.abc.Sequence[pycanha_core.pycanha_core.gmm.GeometryMeshedItem | pycanha_core.pycanha_core.gmm.GeometryGroup | pycanha_core.pycanha_core.gmm.GeometryGroupCutted], transformation: pycanha_core.pycanha_core.gmm.CoordinateTransformation) -> None
Create a group with items and a shared transformation.
- add_geometry_group#
Add a child GeometryGroup.
- add_geometry_item#
Add a GeometryMeshedItem to this group.
- property geometry_groups#
List of child GeometryGroups.
- property geometry_groups_cutted#
List of child GeometryGroupCutted objects.
- property geometry_items#
List of child GeometryMeshedItems.
- remove_geometry_group#
Remove a child GeometryGroup.
- remove_geometry_item#
Remove a GeometryMeshedItem from this group.
- class GeometryGroupCutted#
Bases:
GeometryGroupGeometry group where child meshes are cut by cutting primitives (boolean subtraction).
- __init__(*args, **kwargs)#
- add_cutting_geometry_item#
Add a geometry item as a cutting tool.
- create_cutted_mesh#
Perform the cutting operation and generate cut meshes.
- property cutted_geometry_meshed_items#
List of resulting cut GeometryMeshedItems.
- property cutting_geometry_items#
List of geometry items used as cutting tools.
- remove_cutting_geometry_item#
Remove a cutting geometry item.
- class GeometryModel(*args, **kwargs)#
Bases:
objectTop-level container for the complete geometry model.
Manages a hierarchy of geometry items and groups, provides factory methods for creating them, and generates the unified TriMeshModel for analysis.
- __init__#
Overloaded function.
__init__(self) -> None
Create an empty geometry model.
__init__(self, name: str) -> None
Create a geometry model with the given name.
- callback_primitive_changed#
Notify the model that a primitive has been modified.
- copy_mesh#
Copy meshes into the unified TriMeshModel.
- create_geometry_group#
Create and register a GeometryGroup.
- create_geometry_group_cutted#
Create and register a GeometryGroupCutted.
- create_geometry_item#
Create and register a GeometryMeshedItem.
- create_mesh#
Generate triangle meshes for all geometry items.
- get_root_geometry_group#
Get the root GeometryGroup of the hierarchy.
- get_trimesh_model#
Get the unified TriMeshModel for rendering/analysis.
Mesh utility functions#
- cdt_trimesher(trimesh: pycanha_core.pycanha_core.gmm.TriMesh) None#
Refine a TriMesh using constrained Delaunay triangulation.
- create_2d_rectangular_mesh(arg0: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg1: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg2: float, arg3: float, /) pycanha_core.pycanha_core.gmm.TriMesh#
Generate a 2D rectangular mesh.
- create_2d_quadrilateral_mesh(arg0: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg1: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg2: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg3: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg4: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg5: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg6: float, arg7: float, /) pycanha_core.pycanha_core.gmm.TriMesh#
Generate a 2D quadrilateral mesh.
- create_2d_triangular_mesh(arg0: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg1: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg2: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg3: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg4: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg5: float, arg6: float, /) pycanha_core.pycanha_core.gmm.TriMesh#
Generate a 2D triangular mesh.
- create_2d_triangular_only_mesh(arg0: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg1: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg2: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg3: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg4: float, arg5: float, /) pycanha_core.pycanha_core.gmm.TriMesh#
Generate a 2D mesh with triangles only.
- create_2d_disc_mesh(arg0: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg1: numpy.ndarray[dtype=float64, shape=(*), order='C'], arg2: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg3: numpy.ndarray[dtype=float64, shape=(2), order='C'], arg4: float, arg5: float, /) pycanha_core.pycanha_core.gmm.TriMesh#
Generate a 2D disc mesh.