3DLIRIOUS / MeshLabXML

Create and run MeshLab XML scripts with Python
GNU Lesser General Public License v2.1
202 stars 43 forks source link

Problem with script for smoothing #35

Open e-dub opened 2 years ago

e-dub commented 2 years ago

Hi, I have run into a problem (I had it working a couple years ago on another computer with another version of MeshLab, but now...) when trying to smooth an STL file with MeshLab controlled via MeshLabXML. Any ideas what I am doing wrong? Any help would be most appreciated!

My system: Ubuntu 21.10 Python 3.9.7 MeshLab 2020.09 MeshLabXML 2021.7

The following Python code with MeshLabXML:

import meshlabxml as mlx

SmoothFn = mlx.FilterScript(file_in=FileIn, file_out=FileOut)
mlx.smooth.laplacian(
    SmoothFn,
    iterations=5,
    boundary=True,
    cotangent_weight=True,
    selected=False,
)
SmoothFn.run_script()

writes the following script:

<!DOCTYPE FilterScript>
<FilterScript>
  <filter name="Merge Close Vertices">
    <Param name="Threshold" value="0.0" description="Merging distance" min="0" max="1" type="RichAbsPerc" />
  </filter>
  <filter name="Change the current layer">
    <Param name="mesh" value="0" description="Mesh" type="RichMesh" />
  </filter>
  <filter name="Laplacian Smooth">
    <Param name="stepSmoothNum" value="5" description="Smoothing steps" type="RichInt" />
    <Param name="Boundary" value="true" description="1D Boundary Smoothing" type="RichBool" />
    <Param name="cotangentWeight" value="true" description="Cotangent weighting" type="RichBool" />
    <Param name="Selected" value="false" description="Affect only selected faces" type="RichBool" />
  </filter>
</FilterScript>

Doing the smoothing by "hand" in MeshLab gives me the following script:

<!DOCTYPE FilterScript>
<FilterScript>
 <filter name="Laplacian Smooth">
  <Param value="10" type="RichInt" name="stepSmoothNum"/>
  <Param value="true" type="RichBool" name="Boundary"/>
  <Param value="false" type="RichBool" name="cotangentWeight"/>
  <Param value="false" type="RichBool" name="Selected"/>
 </filter>
</FilterScript>

There seems to be some major differences in the naming, i.e.

For the sake of completeness, I get the following output with the error message:

meshlabserver cmd = meshlabserver -i "FileIn.stl" -o "FileOut.stl"  -s "/tmp/tmpzhanjw91.mlx"
***START OF MESHLAB STDOUT & STDERR***
Loading Plugins:
Current Plugins Dir is: /usr/lib/x86_64-linux-gnu/meshlab/plugins 
Total 266 filtering actions
Total 13 io plugins
Opening a file with extension stl
Mesh FileIn.stl loaded has 5912 vn 10048 fn
output mesh  FileOut.stl
Apply FilterScript: '/tmp/tmpzhanjw91.mlx'
FilterScript
Reading filter with name Merge Close Vertices
Reading filter with name Change the current layer
Reading filter with name Laplacian Smooth
Starting Script of 3 actionsfilter: Merge Close Vertices
LOG: 2 Successfully merged 0 vertices
Successfully merged 0 vertices
filter: Change the current layer
meshlabserver: ./src/meshlabserver/mainserver.cpp:614: bool MeshLabServer::script(MeshDocument&, const QString&, FILE*): Assertion `parameterSet.size() == required.size()' failed.
Aborted (core dumped)

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 "FileIn.stl" -o "FileOut.stl"  -s "/tmp/tmpzhanjw91.mlx""
Where do we go from here?

Thanks for providing this library! Great stuff.

e-dub commented 2 years ago

see pull request

There is probably a better way though...