-
Notifications
You must be signed in to change notification settings - Fork 3
/
mesh_simplification.py
39 lines (24 loc) · 1.11 KB
/
mesh_simplification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pymeshlab as ml
import os
#6810
#13311
path ="Meshes"
move_path = "Simplified_Meshes"
os.mkdir(move_path)
# path ="/scratch/anton/template"
# move_path = "/scratch/anton/template_60000"
for subdir,dir,files in os.walk(path):
for file in files:
if(file.endswith(".obj")):
f_path=os.path.join(subdir,file)
m_path=os.path.join(move_path,file)
TARGET_Faces=2000
ms = ml.MeshSet()
ms.load_new_mesh(f_path)
m = ms.current_mesh()
print('input mesh has', m.vertex_number(), 'vertex and', m.face_number(), 'faces')
ms.apply_filter('simplification_quadric_edge_collapse_decimation', targetfacenum=TARGET_Faces, preservenormal=True)
print("Decimated to", TARGET_Faces, "faces mesh has", ms.current_mesh().vertex_number(), "vertex")
m = ms.current_mesh()
print('output mesh has', m.vertex_number(), 'vertex and', m.face_number(), 'faces')
ms.save_current_mesh(m_path)