trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

Creating new mesh from sample of a mesh

Open rosar-ttt opened this issue 3 years ago • 3 comments
trafficstars

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

rosar-ttt avatar Jan 14 '22 18:01 rosar-ttt

Did you find the solution?

WeedsInML avatar Jan 18 '22 14:01 WeedsInML

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.

Norweig1an avatar May 09 '23 09:05 Norweig1an

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)

AntiLibrary5 avatar Jul 17 '23 14:07 AntiLibrary5