trimesh
trimesh copied to clipboard
Creating new mesh from sample of a mesh
Is it possible to create a new mesh from a sample of a mesh?
Here's what I did: get samples, find faces of sample mesh (bc sample function returns indices of faces), create a trimesh object using the vertices and faces found.
Code: sample_mesh_vertices, sample_mesh_faces_indices = trimesh.sample.sample_surface_even(mesh, 3000)
sample_mesh_faces = [] for k in range(len(sample_mesh_faces_indices)): key = sample_mesh_faces_indices[k] face = mesh.faces[key] sample_mesh_faces.append(face)
sample_mesh_faces = np.array(sample_mesh_faces)
sample_mesh = trimesh.Trimesh(sample_mesh_vertices, sample_mesh_faces)
Error: IndexError: index 3776 is out of bounds for axis 0 with size 3000
Did you find the solution?
Hey, have you find the method to solve this problem? I think it's relatively difficult cause you have to re-sort the face order.
I have similar use-case. GIven a trimesh object, and a set of vertex_ids, I want to "subsample" the trimesh object.
subsampled_mesh = mesh.vertices(vertex_ids)
But here I loose the face information. And there is no similar way to get corresponding faces since there is no 1-to-1 correspondence between vertices and faces (in my case I have >2x number of faces than number of vertices)