liblaf.melon.tri
¶
Triangular surface geometry helpers.
Functions:
-
contains– -
edge_length–Compute lengths for all extracted edges of a triangular surface.
-
extract_cells–Extract selected cells from a surface-like mesh.
-
extract_groups–Extract cells whose
GroupIdmatches numeric or named groups. -
fill_point– -
fix_normals–Orient triangle normals with Trimesh and return a Trimesh object.
-
geodesic_path–Find an edge-flip geodesic path between two surface vertices.
-
implicit_distance– -
query_ray– -
select_groups–Build a boolean mask for cells in selected groups.
contains
¶
contains(
mesh: Mesh,
points: Float[Tensor, "*p 3"],
max_dist: float = inf,
) -> Bool[Tensor, "*p"]
Source code in src/liblaf/melon/tri/_contains.py
edge_length
¶
Compute lengths for all extracted edges of a triangular surface.
Parameters:
-
mesh(PolyData) –Surface mesh.
Returns:
-
Float[ndarray, ' E']–Edge lengths reported by PyVista's cell-size filter.
Source code in src/liblaf/melon/tri/_edge.py
extract_cells
¶
extract_cells(
mesh: Any,
ind: int | VectorLike[int] | VectorLike[bool],
*,
invert: bool = False,
) -> PolyData
Extract selected cells from a surface-like mesh.
Parameters:
-
mesh(Any) –Object convertible to [
pyvista.PolyData][]. -
ind(int | VectorLike[int] | VectorLike[bool]) –Cell index, integer indices, or boolean cell mask.
-
invert(bool, default:False) –Extract all cells except the selected cells.
Returns:
-
PolyData–Extracted surface.
Source code in src/liblaf/melon/tri/_group.py
extract_groups
¶
extract_groups(
mesh: Any,
groups: int | str | Iterable[int | str],
*,
invert: bool = False,
) -> PolyData
Extract cells whose GroupId matches numeric or named groups.
Parameters:
-
mesh(Any) –Mesh with
GroupIdcell data and optionalGroupNamefield data. -
groups(int | str | Iterable[int | str]) –Group id, group name, or iterable of ids and names.
-
invert(bool, default:False) –Extract all cells outside the selected groups.
Returns:
-
PolyData–Extracted surface.
Source code in src/liblaf/melon/tri/_group.py
fill_point
¶
fill_point(
mesh: PolyData,
mask: Bool[ndarray, " P"],
names: Iterable[str] | None = None,
*,
limit: float = inf,
) -> PolyData
Source code in src/liblaf/melon/tri/_fill_point.py
fix_normals
¶
Orient triangle normals with Trimesh and return a Trimesh object.
Parameters:
-
mesh(Any) –Object convertible to [
trimesh.Trimesh][]. -
multibody(bool | None, default:None) –Forwarded to [
trimesh.Trimesh.fix_normals][].
Returns:
-
Trimesh–Mesh with repaired normal orientation.
Source code in src/liblaf/melon/tri/_repair.py
geodesic_path
¶
Find an edge-flip geodesic path between two surface vertices.
Parameters:
-
mesh(PolyData) –Triangular surface mesh.
-
v_start(int) –Start vertex index.
-
v_end(int) –End vertex index.
Returns:
-
PolyData–Polyline following the computed geodesic path.
Source code in src/liblaf/melon/tri/_geodestic.py
implicit_distance
¶
implicit_distance(
mesh: Mesh,
points: Float[Tensor, "*q 3"],
max_dist: float = inf,
) -> Float[Tensor, "*q"]
Source code in src/liblaf/melon/tri/_implicit_distance.py
query_ray
¶
query_ray(
mesh: Mesh,
start: Float[Tensor, "*q 3"],
direction: Float[Tensor, "*q 3"],
max_t: float = inf,
) -> Float[Tensor, "*q"]
Source code in src/liblaf/melon/tri/_query_ray.py
select_groups
¶
select_groups(
mesh: Any,
groups: int | str | Iterable[int | str],
*,
invert: bool = False,
preference: FieldAssociation = CELL,
) -> Bool[ndarray, " cells"]
Build a boolean mask for cells in selected groups.
Parameters:
-
mesh(Any) –Mesh with a group-id array.
-
groups(int | str | Iterable[int | str]) –Group id, group name, or iterable of ids and names.
-
invert(bool, default:False) –Invert the selection mask.
-
preference(FieldAssociation, default:CELL) –PyVista association used to resolve the
GroupIdarray.
Returns:
-
Bool[ndarray, ' cells']–Boolean mask over mesh cells.