1 data_handling.mesh_cache

data_handling.mesh_cache

Shared helpers for processing and caching GT meshes.

This module centralises mesh cropping/simplification and persistence so that both candidate generation (collision checks) and depth rendering can reuse the same processed mesh without duplicating logic.

1.1 Classes

Name Description
MeshProcessSpec Specification that uniquely defines a processed mesh artifact.
ProcessedMesh Container for processed mesh and cached tensors.

1.1.1 MeshProcessSpec

data_handling.mesh_cache.MeshProcessSpec(
    scene_id,
    crop,
    bounds_min,
    bounds_max,
    margin_m,
    simplify_ratio,
    crop_min_keep_ratio,
)

Specification that uniquely defines a processed mesh artifact.

1.1.1.1 Attributes

Name Description
scene_id Scene identifier used for cache-path resolution.
crop Whether the mesh should be cropped to snippet bounds.
bounds_min World-space minimum crop bounds.
bounds_max World-space maximum crop bounds.
margin_m Margin added to the crop bounds before clipping the mesh.
simplify_ratio Optional face-count ratio used for mesh simplification.
crop_min_keep_ratio Minimum face keep ratio tolerated during cropping.

1.1.1.2 Methods

Name Description
hash Stable short hash for filenames and cache keys.
1.1.1.2.1 hash
data_handling.mesh_cache.MeshProcessSpec.hash()

Stable short hash for filenames and cache keys.

1.1.2 ProcessedMesh

data_handling.mesh_cache.ProcessedMesh(
    mesh,
    bounds,
    verts,
    faces,
    cache_hit,
    path,
    spec_hash,
)

Container for processed mesh and cached tensors.

1.1.2.1 Attributes

Name Description
mesh Processed mesh object.
bounds World-space bounds associated with the processed mesh.
verts Cached vertex tensor for downstream tensor-based consumers.
faces Cached face tensor for downstream tensor-based consumers.
cache_hit Whether the processed mesh was loaded from disk cache.
path Filesystem path of the processed mesh artifact.
spec_hash Stable hash of the processing specification.

1.2 Functions

Name Description
load_or_process_mesh Crop/simplify a mesh once and persist the result on disk.

1.2.1 load_or_process_mesh

data_handling.mesh_cache.load_or_process_mesh(
    mesh,
    spec,
    paths,
    *,
    console=None,
)

Crop/simplify a mesh once and persist the result on disk.

1.2.1.1 Parameters

Name Type Description Default
mesh trimesh.Trimesh Raw scene mesh. required
spec MeshProcessSpec Processing specification (bounds, simplification, etc.). required
paths PathConfig PathConfig providing the processed-mesh directory. required
console Console | None Optional logger. None

1.2.1.2 Returns

Name Type Description
ProcessedMesh ProcessedMesh with trimesh object, bounds, torch tensors, and cache flag.
Back to top