liblaf.melon.ext
¶
Wrappers around external mesh-processing tools.
Modules:
-
wrap–Faceform Wrap project helpers.
Functions:
-
annotate_landmarks–Open a Wrap project for editing corresponding landmarks.
-
delta_transfer– -
fast_wrapping–Run Faceform Wrap fast wrapping between floating and fixed surfaces.
-
meshfix–Repair a triangular surface with PyMeshFix.
-
select_polygons–Open a Wrap project that lets the user edit selected polygons.
-
tetwild–Tetrahedralize a surface with TetWild and repair winding.
annotate_landmarks
¶
annotate_landmarks(
left: Any,
right: Any,
*,
left_landmarks: Float[ArrayLike, "L 3"] | None = None,
right_landmarks: Float[ArrayLike, "L 3"] | None = None,
) -> tuple[Float[ndarray, "L 3"], Float[ndarray, "L 3"]]
Open a Wrap project for editing corresponding landmarks.
The left mesh is pre-aligned to the right mesh with either landmark Procrustes fitting or Trimesh mesh registration. Returned left landmarks are transformed back into the original left-mesh coordinate system.
Parameters:
-
left(Any) –Left mesh.
-
right(Any) –Right mesh.
-
left_landmarks(Float[ArrayLike, 'L 3'] | None, default:None) –Optional starting landmarks on
left. -
right_landmarks(Float[ArrayLike, 'L 3'] | None, default:None) –Optional starting landmarks on
right.
Returns:
-
tuple[Float[ndarray, 'L 3'], Float[ndarray, 'L 3']]–Updated
(left_landmarks, right_landmarks).
Raises:
-
CalledProcessError–If
Wrap.shfails.
Source code in src/liblaf/melon/ext/wrap/_annotate_landmarks.py
delta_transfer
¶
Source code in src/liblaf/melon/ext/wrap/_delta_transfer.py
fast_wrapping
¶
fast_wrapping(
floating: Any,
fixed: Any,
*,
floating_landmarks: Float[ArrayLike, "L 3"]
| None = None,
fixed_landmarks: Float[ArrayLike, "L 3"] | None = None,
free_polygons_floating: Integer[ArrayLike, " F"]
| None = None,
) -> PolyData
Run Faceform Wrap fast wrapping between floating and fixed surfaces.
Parameters:
-
floating(Any) –Mesh to deform.
-
fixed(Any) –Target mesh.
-
floating_landmarks(Float[ArrayLike, 'L 3'] | None, default:None) –Optional landmarks on the floating mesh.
-
fixed_landmarks(Float[ArrayLike, 'L 3'] | None, default:None) –Optional corresponding landmarks on the fixed mesh.
-
free_polygons_floating(Integer[ArrayLike, ' F'] | None, default:None) –Optional floating-mesh polygons left free during wrapping.
Returns:
-
PolyData–Wrapped floating mesh with attributes copied from the aligned input.
Raises:
-
CalledProcessError–If
WrapCmd.sh computefails.
Source code in src/liblaf/melon/ext/wrap/_fast_wrapping.py
meshfix
¶
meshfix(
mesh: PolyData,
*,
check: bool = True,
joincomp: bool = False,
remove_smallest_components: bool = True,
verbose: bool = False,
) -> PolyData
Repair a triangular surface with PyMeshFix.
The repaired mesh is normalized through Trimesh afterward so normals are consistently oriented.
Parameters:
-
mesh(PolyData) –Surface mesh to repair.
-
check(bool, default:True) –Assert that the repaired mesh is non-empty and volumetric.
-
joincomp(bool, default:False) –Forwarded to PyMeshFix.
-
remove_smallest_components(bool, default:True) –Forwarded to PyMeshFix.
-
verbose(bool, default:False) –Enable PyMeshFix logging.
Returns:
-
PolyData–Repaired surface with original field data copied back.
Source code in src/liblaf/melon/ext/_meshfix.py
select_polygons
¶
select_polygons(
mesh: Any,
polygons: Integer[ArrayLike, " N"] | None = None,
) -> Integer[ndarray, " N"]
Open a Wrap project that lets the user edit selected polygons.
Parameters:
-
mesh(Any) –Mesh to show in Wrap.
-
polygons(Integer[ArrayLike, ' N'] | None, default:None) –Initial selected polygon indices.
Returns:
-
Integer[ndarray, ' N']–Polygon indices saved by Wrap.
Raises:
-
CalledProcessError–If
Wrap.shfails.
Source code in src/liblaf/melon/ext/wrap/_select_polygons.py
tetwild
¶
Tetrahedralize a surface with TetWild and repair winding.
Positional and keyword arguments are forwarded to
[pytetwild.tetrahedralize_pv][]. Results are
cached with Joblib under the user cache directory.
Returns:
-
UnstructuredGrid–Tetrahedral mesh with non-negative cell volumes.