-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
I'm testing the simplifying function on Colab with installation code:
pip install meshlabxm
The whole code is like this:
import os
import sys
import inspect
import meshlabxml as mlx
import platform
import glob
import shutil
import time
'''
Description: It takes around 17 minutes with this script to decimate in bulk a 3M faces Model into 7 resolutions
[100K, 200K, 300K, 400K, 500K, 600K, 750K]. For improving this time, consider using simplifybulkthreaded.py
for a threaded implementation.
Usage: python3 simplifybulknothreading.py
You can of course include functionality to take arguments from command line/terminal like I did in simplify.py
DO NOT FORGET to change: Decimations_List, originalMesh (name of original mesh), SimplifiedMesh & Textures
Enjoy!
'''
MESHLABSERVER_PATH = 'C:\Program Files\VCG\MeshLab'
os.environ['PATH'] += os.pathsep + MESHLABSERVER_PATH
def simplify(originalMeshName, SimplifiedMeshName, NumberOfFaces, WithTexture):
# File names
FilterScript = 'SimplificationFilter.mlx' # script file
original_mesh = originalMeshName # input file
simplified_mesh = SimplifiedMeshName # output file
Num_Of_Faces = int(NumberOfFaces) # Final Number of Faces
# Check the input mesh number of faces (so that we do not decimate to a higher number of faces than original mesh)
MetricsMeshDictionary = {}
MetricsMeshDictionary = mlx.files.measure_topology(original_mesh)
# print (MetricsMeshDictionary)
print('\n Number of faces of original mesh is: ' + str(MetricsMeshDictionary['face_num'] ))
if(MetricsMeshDictionary['face_num'] <= Num_Of_Faces):
#exit the script and print a message about it
print("\n SORRY your decimated mesh can not have higher number of faces that the input mesh.....")
print("\n ......................................................................................")
sys.exit()
# Creating a folder named as the Number of faces: named '150000'
print('\n Creating a folder to store the decimated model ...........')
if not os.path.exists(str(Num_Of_Faces)):
os.makedirs(str(Num_Of_Faces))
simplified_meshScript = mlx.FilterScript(file_in=original_mesh, file_out=str(Num_Of_Faces) + '/' + simplified_mesh,
ml_version='2016.12') # Create FilterScript object
mlx.remesh.simplify(simplified_meshScript, texture=WithTexture, faces=Num_Of_Faces,
target_perc=0.0, quality_thr=1.0, preserve_boundary=True,
boundary_weight=1.0, preserve_normal=True,
optimal_placement=True, planar_quadric=True,
selected=False, extra_tex_coord_weight=1.0)
print('\n Beginning the process of Decimation ...........')
simplified_meshScript.run_script() # Run the script
os.chdir(str(Num_Of_Faces))
print('\n Process of Decimation Finished ...')
print('\n Copying textures (PNG and JPEG) into the folder of decimated model....')
#go back to parent directory so we can copy the textures to the 3D Model folder
os.chdir('..')
#Now checking for textures in the folder of the input mesh.... (plz change if needed)
allfilelist= os.listdir('.')
for Afile in allfilelist[:]:
if not(Afile.endswith(".png") or Afile.endswith(".PNG") or Afile.endswith(".jpg") or Afile.endswith(".JPG")):
allfilelist.remove(Afile)
print('\n Found the LIST of images in PNG and JPEG (textures): ')
print(allfilelist)
for file in allfilelist:
shutil.copy(file, str(Num_Of_Faces))
print('\n sleeping for 3 seconds.... ')
time.sleep(3)
Decimations_List = [100]
originalMesh = '/content/drive/MyDrive/DGCNN/airplane_0627.obj'
SimplifiedMesh = '/content/drive/MyDrive/DGCNN/airplane_simpliyed_0627.obj'
Textures = True
print("...........Starting timer for the decimation process............")
initial_time = time.time()
for decimation_resolution in Decimations_List:
simplify(originalMesh, SimplifiedMesh, decimation_resolution, Textures)
finish_time = time.time()
print("---Decimation Process took: %s seconds ---" % (finish_time - initial_time))
print("\n Done.... have a good day!")
Then when I run this code, I have this bug:
...........Starting timer for the decimation process............
meshlabserver cmd = meshlabserver -l TEMP3D_measure_topology_log.txt -i "/content/drive/MyDrive/DGCNN/airplane_0627.obj" -s "TEMP3D_measure_topology.mlx"
***START OF MESHLAB STDOUT & STDERR***
Houston, we have a problem.
MeshLab did not finish successfully. Review the log file and the input file(s) to see what went wrong.
MeshLab command: "meshlabserver -l TEMP3D_measure_topology_log.txt -i "/content/drive/MyDrive/DGCNN/airplane_0627.obj" -s "TEMP3D_measure_topology.mlx""
Where do we go from here?
r - retry running MeshLab (probably after you've fixed any problems with the input files)
c - continue on with the script (probably after you've manually re-run and generated the desired output file(s)
x - exit, keeping the TEMP3D files and log
xd - exit, deleting the TEMP3D files and log
Select r, c, x (default), or xd:
And the code shows that the bug happened in this line:
MetricsMeshDictionary = mlx.files.measure_topology(original_mesh)
Could you please tell me how to solve it? Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels