fast-simplification
fast-simplification copied to clipboard
IndexError in _map_isolated_points
I tried to simplify a mesh and maintrain its uv. However, I encounter this error:
File "/root/cvg/project/wcy/project/RemoteSensing/scripts/preprocess_data.py", line 58, in <module>
preprocess(src, dst)
File "/root/cvg/project/wcy/project/RemoteSensing/scripts/preprocess_data.py", line 19, in preprocess
_, _, vmap = replay_simplification(mesh_in.vertices.view(np.ndarray).astype(np.float32),
File "/root/miniforge3/envs/omages/lib/python3.10/site-packages/fast_simplification/utils.py", line 21, in wrapper
return func(*args, **kwargs)
File "/root/miniforge3/envs/omages/lib/python3.10/site-packages/fast_simplification/replay.py", line 198, in replay_simplification
mapping, points_to_merge, outliers = _map_isolated_points(
File "/root/miniforge3/envs/omages/lib/python3.10/site-packages/fast_simplification/replay.py", line 96, in _map_isolated_points
mapping[merged] = mapping[target]
IndexError: index 49234 is out of bounds for axis 0 with size 49234
My code(functon preprocess):
def preprocess(src, dst):
mesh_in = trimesh.load_mesh(src)
texture = mesh_in.visual
if isinstance(texture, trimesh.visual.ColorVisuals):
return
new_verts, new_faces, collapse = simplify(
points =mesh_in.vertices.view(np.ndarray),
triangles =mesh_in.faces.view(np.ndarray),
target_reduction= 0.75,
return_collapses=True
)
_, _, vmap = replay_simplification(mesh_in.vertices.view(np.ndarray).astype(np.float32),
mesh_in.faces.view(np.ndarray), collapse)
new_uv = np.take(texture.uv, vmap)
new_mesh = trimesh.Trimesh(
vertices=new_verts,
faces=new_faces,
visual=trimesh.visual.TextureVisuals(uv=new_uv, material=texture.material)
)
new_mesh.export(dst)
Could you help me out of this?