27 lines
1022 B
Python
27 lines
1022 B
Python
import pymeshlab
|
|
|
|
def simplify_mesh(input_file, output_file, target_faces):
|
|
ms = pymeshlab.MeshSet()
|
|
ms.load_new_mesh(input_file)
|
|
|
|
# Simplificação de malha com um número alvo de faces
|
|
ms.meshing_decimation_quadric_edge_collapse(targetfacenum=target_faces)
|
|
|
|
ms.save_current_mesh(output_file)
|
|
|
|
def main(input_file, output_file, target_faces, scale_factor):
|
|
intermediate_file = 'intermediate.stl'
|
|
|
|
# Reduz a quantidade de polígonos
|
|
simplify_mesh(input_file, intermediate_file, target_faces)
|
|
|
|
print(f'Malha processada salva em: {output_file}')
|
|
|
|
if __name__ == "__main__":
|
|
input_file = 'robo.stl' # Substitua pelo caminho do seu arquivo STL de entrada
|
|
output_file = 'robo_s4.stl' # Substitua pelo caminho do seu arquivo STL de saída
|
|
target_faces = 50000 # Número desejado de faces após a simplificação
|
|
scale_factor = 0.5 # Fator de escala (0.5 = reduzir para metade do tamanho original)
|
|
|
|
main(input_file, output_file, target_faces, scale_factor)
|