Skip to content

Commit

Permalink
Decimate meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
verdakode committed Jan 24, 2025
1 parent dc7b898 commit 06ab415
Show file tree
Hide file tree
Showing 33 changed files with 840 additions and 0 deletions.
39 changes: 39 additions & 0 deletions public/cad/decimate_mesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import open3d as o3d
import shutil
from pathlib import Path


def decimate_mesh(input_path, output_path, target_faces=7500):
try:
mesh = o3d.io.read_triangle_mesh(str(input_path))
if len(mesh.triangles) > target_faces:
mesh = mesh.simplify_quadric_decimation(target_faces)
o3d.io.write_triangle_mesh(str(output_path), mesh)
print(f"Decimated {input_path.name}: {len(mesh.triangles)} faces")
return True
except Exception as e:
print(f"Could not decimate {input_path.name}, copying original: {e}")
return False
return False


def process_folder(folder_path, output_folder):
folder_path = Path(folder_path)
output_folder = Path(output_folder)
output_folder.mkdir(exist_ok=True)

mesh_files = list(folder_path.glob("*.stl")) + list(folder_path.glob("*.obj"))

for mesh_path in mesh_files:
output_path = output_folder / mesh_path.name
if not decimate_mesh(mesh_path, output_path):
shutil.copy2(mesh_path, output_path)
print(f"Copied original {mesh_path.name}")


if __name__ == "__main__":
zbot_path = Path("zbot")
mesh_folder = zbot_path / "meshes"
output_folder = zbot_path / "meshes_decimated"

process_folder(mesh_folder, output_folder)
Binary file added public/cad/zbot 2/meshes/3215_1Flange.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/3215_1Flange_2.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/3215_BothFlange.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/3215_BothFlange_2.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/3215_BothFlange_3.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/3215_BothFlange_4.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/3215_BothFlange_5.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/3215_BothFlange_6.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/FINGER_1.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/FINGER_1_2.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/FOOT.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/FOOT_2.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/L-ARM-MIRROR_1.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/R-ARM-MIRROR-1.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/U-HIP-L.stl
Binary file not shown.
Binary file added public/cad/zbot 2/meshes/U-HIP-R.stl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
242 changes: 242 additions & 0 deletions public/cad/zbot 2/z-bot2_fe_urdf.mjcf

Large diffs are not rendered by default.

559 changes: 559 additions & 0 deletions public/cad/zbot 2/z-bot2_fe_urdf.urdf

Large diffs are not rendered by default.

Binary file modified public/cad/zbot/meshes/3215_1Flange.stl
Binary file not shown.
Binary file modified public/cad/zbot/meshes/3215_1Flange_2.stl
Binary file not shown.
Binary file modified public/cad/zbot/meshes/3215_BothFlange.stl
Binary file not shown.
Binary file modified public/cad/zbot/meshes/3215_BothFlange_2.stl
Binary file not shown.
Binary file modified public/cad/zbot/meshes/3215_BothFlange_3.stl
Binary file not shown.
Binary file modified public/cad/zbot/meshes/3215_BothFlange_4.stl
Binary file not shown.
Binary file modified public/cad/zbot/meshes/3215_BothFlange_5.stl
Diff not rendered.
Binary file modified public/cad/zbot/meshes/3215_BothFlange_6.stl
Diff not rendered.
Binary file modified public/cad/zbot/meshes/L-ARM-MIRROR_1.stl
Diff not rendered.
Binary file modified public/cad/zbot/meshes/R-ARM-MIRROR-1.stl
Diff not rendered.
Binary file modified public/cad/zbot/meshes/Z-BOT2_MASTER-BODY-SKELETON.stl
Diff not rendered.

0 comments on commit 06ab415

Please sign in to comment.