(mesh_coords: Tensor, filename: str)
| 11 | |
| 12 | |
| 13 | def process_mesh(mesh_coords: Tensor, filename: str): |
| 14 | mesh_coords = mesh_coords[~torch.isnan(mesh_coords[:, 0, 0])] # nvalid_face x 3 x 3 |
| 15 | vertices = mesh_coords.reshape(-1, 3) |
| 16 | vertices_index = np.arange(len(vertices)) # 0, 1, ..., 3 x face |
| 17 | triangles = vertices_index.reshape(-1, 3) |
| 18 | write_ply( |
| 19 | np.asarray(vertices.cpu()), |
| 20 | None, |
| 21 | np.asarray(triangles), |
| 22 | filename |
| 23 | ) |
| 24 | return vertices |
| 25 | |
| 26 | |
| 27 | @torch.no_grad() |