Spaces:
Running on Zero
Running on Zero
Download src/geometry/trimesh_util.py from guyPerry/scatteringnet: direct link, hf CLI and curl.
- Browser
- Download file 660 Bytes
-
https://huggingface.co/spaces/guyPerry/scatteringnet/resolve/main/src/geometry/trimesh_util.py
- Command line
-
hf download hf://spaces/guyPerry/scatteringnet/src/geometry/trimesh_util.py
-
curl -L -o trimesh_util.py https://huggingface.co/spaces/guyPerry/scatteringnet/resolve/main/src/geometry/trimesh_util.py
660 Bytes
| """Shared trimesh flatten. No Open3D — safe for train-side mesh_io.""" | |
| from __future__ import annotations | |
| from typing import Any | |
| import trimesh | |
| def as_trimesh(mesh: Any) -> trimesh.Trimesh: | |
| """Flatten a Trimesh or a Scene of triangle meshes to one Trimesh.""" | |
| if isinstance(mesh, trimesh.Scene): | |
| geoms = [g for g in mesh.geometry.values() if isinstance(g, trimesh.Trimesh)] | |
| if not geoms: | |
| raise ValueError("Scene contains no triangle meshes") | |
| mesh = trimesh.util.concatenate(geoms) | |
| if not isinstance(mesh, trimesh.Trimesh): | |
| raise TypeError(f"Unsupported mesh type: {type(mesh)!r}") | |
| return mesh | |