Menu

Quadric edge collapse decimation - problems with skripting

Help
Felix H
2016-11-01
2020-08-12
  • Felix H

    Felix H - 2016-11-01

    Hey,

    for decimation of 3d-scandate I did some experiment with the scripting-function (meshlabserver). MeshLab works great with the exported mlx-script at default-configuration. As soon as I put some special requirements into my script (like ' preserve topology' or 'planar simplification') , the exported files won't be processed with these configuration, the file size correlates with the original files in my 'input' folder.

    Are these additional features excluded in the scripting-process?

    Thanks a lot for help.

    (MeshLab 1.3.3 Win 10 64bit)

     

    Last edit: Felix H 2016-11-01
  • Tim Ayres

    Tim Ayres - 2016-11-02

    Felix,

    Meshlabserver can certainly use these other parameters to the decimation filter. If you're having issues you may have an error in the mlx file or elsewhere in your process. Did the command line output indicate any errors or issues?

    Editing the mlx files by hand can be problematic and is no fun, so I've written a Python library to help generate and run scripts, MeshLabXML. If you have some basic Python skills you may want to check it out. A sample script to decimate a model would be similar to the following:

    import meshlabxml as mlx
    
    script = 'simplify.mlx' # script file
    original_mesh = 'file_in.ply' # input file
    simplified_mesh = 'file_out.ply' # output file
    
    mlx.begin(script=script, file_in=original_mesh) # Start writing the script to the script file
    mlx.remesh.simplify(script=script, texture=True, faces=25000,
                        target_perc=0.0, quality_thr=0.3, preserve_boundary=False,
                        boundary_weight=1.0, preserve_normal=False,
                        optimal_placement=True, planar_quadric=False,
                        selected=False, extra_tex_coord_weight=1.0,
                        preserve_topology=True, quality_weight=False,
                        autoclean=True)
    mlx.end(script=script) # Finish writing the script to the script file
    
    mlx.run(script=script, file_in=original_mesh, file_out=simplified_mesh) # Run the script file on the input and export the output.
    

    Note that I exclusively use version 1.3.4BETA on Windows 64, as some filters only work with meshlabserver in this version. Most filters should still work with version 1.3.3, but this hasn't been tested much.

     
    • Bimsara Pathiraja

      Thanks @Tim Ayres for the great explanation. Could you explain the way to use the same script for .obj files

       
  • Felix H

    Felix H - 2016-11-09

    Hey Tim,

    thank you very much for this helpful answer. There aren't any error messages while using the scripting function. It nice to know that the manual editing of script can be a problem.

    I will try out your MeshLabXML-Database, thanks!

    Felix

     
  • Gilad Les

    Gilad Les - 2018-03-04

    Hello Tim,

    I'm new to MeshLab and while trying to execute your script i'm keep receiving the following message:

    *Total 12 io plugins
    Opening a file with extention obj
    Mesh E:/Erez/server/4b2a36a144cf44ca93470df1c72a82cd.obj loaded has 243204 vn
    440832 fn
    output mesh E:/Erez/server/fileout.obj
    vertex color, vertex normals, face color, wedge tex coords, Apply FilterScript:
    'E:/Erez/server/simplify.mlx'
    FilterScript
    Reading filter with name Quadric Edge Collapse Decimation (with texture)
    Reading Param with name TargetFaceNum : RichInt
    Reading Param with name TargetPerc : RichFloat
    Reading Param with name QualityThr : RichFloat
    Reading Param with name PreserveBoundary : RichBool
    Reading Param with name BoundaryWeight : RichFloat
    Reading Param with name OptimalPlacement : RichBool
    Reading Param with name PreserveNormal : RichBool
    Reading Param with name PlanarQuadric : RichBool
    Reading Param with name Selected : RichBool
    Reading Param with name Extratcoordw : RichFloat
    Starting Script of 1 actionsfilter: Quadric Edge Collapse Decimation (with texture)
    filter Quadric Edge Collapse Decimation (with texture) not foundFailed
    to apply
    script file E:/Erez/server/simplify.mlx

    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 -i "4b2a36a144cf44ca93470df1c72a82cd.obj" -o "fileout.obj" -m vc vn fc wt -s "simplify.mlx""
    Where do we go from here?*

    Can you please help out?

    Thank you,
    Gilad.

     
    • Tim Ayres

      Tim Ayres - 2018-03-06

      Hi Gilad,

      The MeshLabXML API has changed somewhat after the new MeshLab release in 2016.12; it is now object-based. The reason the old script no longer works is that the "Quadric Edge Collapse Decimation (with texture)" filte'rs name was changed in 2016.12 to "Simplification: Quadric Edge Collapse Decimation (with texture)". I just pushed a new version to PIP which you may want to try. Below is a conversion of the simplification script above to the new API, I hope you agree that this is an improvement.

      import meshlabxml as mlx
      
      original_mesh = 'file_in.ply' # input file
      simplified_mesh = 'file_out.ply' # output file
      
      simplified_mesh = mlx.FilterScript(file_in=original_mesh, file_out=simplified_mesh, ml_version='2016.12') # Create FilterScript object 
      mlx.remesh.simplify(simplified_mesh, texture=True, faces=25000,
                          target_perc=0.0, quality_thr=0.3, preserve_boundary=False,
                          boundary_weight=1.0, preserve_normal=False,
                          optimal_placement=True, planar_quadric=False,
                          selected=False, extra_tex_coord_weight=1.0,
                          preserve_topology=True, quality_weight=False,
                          autoclean=True)
      simplified_mesh.run_script() # Run the script
      

      Please let me know if you have any other questions.

      Thanks,
      Tim

       
  • hb1987

    hb1987 - 2018-05-14

    Hi Tim

    Thanks for your comments and help but this did not work for me.
    Works like a charm!

     

    Last edit: hb1987 2018-05-14

Log in to post a comment.