digeo.MeshBatch#

class digeo.MeshBatch(meshes)[source]#

Bases: Mesh

Allows batched operations of meshes. MeshPointsBatch must also be batched using the MeshBatch with batch_points and unbatch_points.

Paramseters#

meshes: List[Mesh]

A list of Mesh objects to batch together.

>>> mesh1 = load_mesh_from_file(path_to_mesh1, device=device)
>>> mesh2 = load_mesh_from_file(path_to_mesh2, device=device)
>>> start_points1 = uniform_sampling(mesh1, N).to(device)
>>> start_points2 = uniform_sampling(mesh2, N).to(device)
>>> mesh_batch = MeshBatch([mesh1, mesh2])
>>> start_batched_points = mesh_batch.batch_points(
...     [start_points1, start_points2]
... )
>>> start_dirs = torch.randn(
...     (2*N, 3), dtype=torch.float32
... ).to(device)
>>> end_batched_points, geodesic_info = trace_geodesics(
...     mesh_batch, start_batched_points, start_dirs
... )
>>> [end_points1, end_points2] = mesh_batch.unbatch_points(
...     end_batched_points
... )
batch_points(meshpoints)[source]#

Batch a list of MeshPointBatch objects into a single MeshPointBatch. The output MeshPointBatch will be detached from the original MeshPointBatch objects.

Parameters:

meshpoints (List[MeshPointBatch]) – A list of MeshPointBatch objects to batch together. Where meshpoints[i] corresponds to the points on mesh i in the MeshBatch.

Returns:

A single MeshPointBatch containing all the points from the input batches, with face indices adjusted to match the concatenated faces of the MeshBatch.

Return type:

MeshPointBatch

to(device: str | device) MeshBatch[source]#
to(dtype: dtype) MeshBatch
to(device: str | device, dtype: dtype) MeshBatch
to(tensor: Tensor) MeshBatch
to(*, device: str | device | None = ..., dtype: dtype | None = ...) MeshBatch

Move the mesh to a different device and/or dtype. Supports PyTorch-like overloads: - to(device) - to(dtype) - to(device, dtype) - to(device=…, dtype=…)

Return type:

MeshBatch

unbatch()[source]#

Unbatch the mesh batch into a list of Mesh objects.

Returns:

A list of Mesh objects corresponding to the original meshes used to create the batch.

Return type:

List[Mesh]

unbatch_points(meshpoints)[source]#

Unbatch a MeshPointBatch into a list of MeshPointBatch objects.

Parameters:

meshpoints (MeshPointBatch) – A MeshPointBatch containing points on the MeshBatch. The face indices in meshpoints should correspond to the concatenated faces of the MeshBatch.

Returns:

A list of MeshPointBatch objects, where the i-th batch contains the points corresponding to the i-th mesh in the MeshBatch. The face indices in each batch will be adjusted to correspond to the original faces of the individual meshes.

Return type:

List[MeshPointBatch]

Parameters:

meshes (List[Mesh])