Meshlabserver:如何将STL转换为PLY并统一顶点?

Meshlabserver: How to convert STL to PLY and unify vertices?

我有几个 .stl 文件,我想通过从命令行调用 meshlabserver 将其转换为 .ply。当我走直路

> meshlabserver -i cube-binary.stl -o cube.ply

(其中 cube.stl 是下面给出的示例文件,有 12 个面),生成的网格有 12 个面和 36 个顶点。这意味着没有发生重复顶点的统一,尽管这正是我想要使用 .ply 而不是 .stl.

的原因

现在,我认为这是不可能的,原因与在 Meshlab GUI 中不可能将顶点统一设置为默认值的原因相同 (I about it some time ago, although it later turned out that such a question )。但也许有人知道一些技巧?在 -om 之后浏览可能的过滤器,我没有找到解决方案。

该行为已在 Open SU​​SE 上使用 Meshlab 2016 以及在 Ubuntu.

上使用 Meshlab v1.3.2_64bit 进行了测试

示例文件

(同样由 Meshlab 创建)

solid vcg
  facet normal  0.000000e+00  0.000000e+00  1.000000e+00
    outer loop
      vertex   5.000000e-01  5.000000e-01  5.000000e-01
      vertex  -5.000000e-01  5.000000e-01  5.000000e-01
      vertex   5.000000e-01 -5.000000e-01  5.000000e-01
    endloop
  endfacet
  facet normal  0.000000e+00  0.000000e+00  1.000000e+00
    outer loop
      vertex  -5.000000e-01 -5.000000e-01  5.000000e-01
      vertex   5.000000e-01 -5.000000e-01  5.000000e-01
      vertex  -5.000000e-01  5.000000e-01  5.000000e-01
    endloop
  endfacet
  facet normal  1.000000e+00  0.000000e+00  0.000000e+00
    outer loop
      vertex   5.000000e-01  5.000000e-01  5.000000e-01
      vertex   5.000000e-01 -5.000000e-01  5.000000e-01
      vertex   5.000000e-01  5.000000e-01 -5.000000e-01
    endloop
  endfacet
  facet normal  1.000000e+00  0.000000e+00  0.000000e+00
    outer loop
      vertex   5.000000e-01 -5.000000e-01 -5.000000e-01
      vertex   5.000000e-01  5.000000e-01 -5.000000e-01
      vertex   5.000000e-01 -5.000000e-01  5.000000e-01
    endloop
  endfacet
  facet normal  0.000000e+00  1.000000e+00  0.000000e+00
    outer loop
      vertex   5.000000e-01  5.000000e-01  5.000000e-01
      vertex   5.000000e-01  5.000000e-01 -5.000000e-01
      vertex  -5.000000e-01  5.000000e-01  5.000000e-01
    endloop
  endfacet
  facet normal  0.000000e+00  1.000000e+00  0.000000e+00
    outer loop
      vertex  -5.000000e-01  5.000000e-01 -5.000000e-01
      vertex  -5.000000e-01  5.000000e-01  5.000000e-01
      vertex   5.000000e-01  5.000000e-01 -5.000000e-01
    endloop
  endfacet
  facet normal  0.000000e+00  0.000000e+00 -1.000000e+00
    outer loop
      vertex  -5.000000e-01 -5.000000e-01 -5.000000e-01
      vertex  -5.000000e-01  5.000000e-01 -5.000000e-01
      vertex   5.000000e-01 -5.000000e-01 -5.000000e-01
    endloop
  endfacet
  facet normal -0.000000e+00 -0.000000e+00 -1.000000e+00
    outer loop
      vertex   5.000000e-01  5.000000e-01 -5.000000e-01
      vertex   5.000000e-01 -5.000000e-01 -5.000000e-01
      vertex  -5.000000e-01  5.000000e-01 -5.000000e-01
    endloop
  endfacet
  facet normal  0.000000e+00 -1.000000e+00  0.000000e+00
    outer loop
      vertex  -5.000000e-01 -5.000000e-01 -5.000000e-01
      vertex   5.000000e-01 -5.000000e-01 -5.000000e-01
      vertex  -5.000000e-01 -5.000000e-01  5.000000e-01
    endloop
  endfacet
  facet normal -0.000000e+00 -1.000000e+00 -0.000000e+00
    outer loop
      vertex   5.000000e-01 -5.000000e-01  5.000000e-01
      vertex  -5.000000e-01 -5.000000e-01  5.000000e-01
      vertex   5.000000e-01 -5.000000e-01 -5.000000e-01
    endloop
  endfacet
  facet normal -1.000000e+00  0.000000e+00  0.000000e+00
    outer loop
      vertex  -5.000000e-01 -5.000000e-01 -5.000000e-01
      vertex  -5.000000e-01 -5.000000e-01  5.000000e-01
      vertex  -5.000000e-01  5.000000e-01 -5.000000e-01
    endloop
  endfacet
  facet normal -1.000000e+00 -0.000000e+00 -0.000000e+00
    outer loop
      vertex  -5.000000e-01  5.000000e-01  5.000000e-01
      vertex  -5.000000e-01  5.000000e-01 -5.000000e-01
      vertex  -5.000000e-01 -5.000000e-01  5.000000e-01
    endloop
  endfacet
endsolid vcg

最简单的方法是使用应用 Remove Duplicate Vertices 过滤器的脚本。

尝试将其保存到名为 cleanVertex.mlx

的文件中
<!DOCTYPE FilterScript>
<FilterScript>
 <filter name="Remove Duplicate Vertices"/>
 <filter name="Remove Unreferenced Vertices"/>
</FilterScript>

然后使用命令:

> meshlabserver -i cube-binary.stl -o cube.ply -s cleanVertex.mlx