2

I would like to apply the Uniform Mesh Resampling filter automatically to a set of meshes, each with different geometry. I obtained a .mlx script for this by saving the output from Filters:Show current filter script. However, the parameters in the script seem to be set for the specific geometry of the mesh I used:

<filter name="Uniform Mesh Resampling">
  <Param type="RichAbsPerc" value="1.1632" min="0" name="CellSize" max="232.648"/>
  <Param type="RichAbsPerc" value="0.93059" min="-46.5296" name="Offset" max="46.5296"/>
  <Param type="RichBool" value="true" name="mergeCloseVert"/>
  <Param type="RichBool" value="false" name="discretize"/>
  <Param type="RichBool" value="true" name="multisample"/>
  <Param type="RichBool" value="true" name="absDist"/>
 </filter>

What I would like is to set the Cell size to 0.5% and the Offset to 51%, and get Meshlab to figure min and max from the geometry of each of the meshes I'm processing. How could I do it?

Thanks in advance!

4

1 回答 1

2

我找到了一个解决方案:首先,我使用我编写的命令行——meshgeometry——来获取网格的大小(meshgeometry 可在https://github.com/r03ert0/meshgeometry获得)。然后,我meshlabserver使用 bash 生成脚本,如下所示:

diag=$(meshgeometry -i $holes_surf -size|cut -d' ' -f 2|awk -F, '{print sqrt($1**2+$2**2+$3**2)}')
diag5=$(echo $diag|awk '{print $1/5}');
precision=$(echo $diag|awk '{print $1*0.005}');
offset=$(echo $diag|awk '{print $1/5*2*0.01}');

cat>"script.mlx"<<EOF
<!DOCTYPE FilterScript>
<FilterScript>
 <filter name="Uniform Mesh Resampling">
  <Param type="RichAbsPerc" value="$precision" min="0" name="CellSize" max="$diag"/>
  <Param type="RichAbsPerc" value="$offset" min="-$diag5" name="Offset" max="$diag5"/>
  <Param type="RichBool" value="false" name="mergeCloseVert"/>
  <Param type="RichBool" value="false" name="discretize"/>
  <Param type="RichBool" value="true" name="multisample"/>
  <Param type="RichBool" value="true" name="absDist"/>
 </filter>

</FilterScript>
EOF

之后,我可以像这样meshlabserver使用我的script.mlx文件调用:

meshlabserver -i source-mesh.ply -o dest-mesh.ply -s "script.mlx"
于 2017-04-20T19:44:09.510 回答