Export of mesh fails to build a readable ply-file

1k views Asked by At

I wrote a little script, that has the task of loading a mesh (ply), then to apply some filters and finally export the whole thing back as a ply.

So far so good. But the resulting ply-file comes out unreadable. If I try to open it in MeshLab, it says: "Face with more than 3 vertices"

here is the code part that concerns pymeshlab (cleaned):

import pymeshlab as ml
ms = ml.MeshSet()
ms.load_new_mesh(path + mesh_name)
ms.apply_filter('convert_pervertex_uv_into_perwedge_uv')
ms.apply_filter('transfer_color_texture_to_vertex')
ms.save_current_mesh(path + 'AutomatedGeneration3.ply')

Did I miss something? There is actually no error message in executing this script. I also tried to use some parameters for the saving filter but it hadn't changed anything.

How do I get it right?

1

There are 1 answers

0
Rockcat On BEST ANSWER

This seems to be a bug in the .ply exporter used internally in the method ms.save_current_mesh().

The method is trying to save all the information stored in the mesh, which at this point is texture_per_vertex, texture_per_wedge and color_per_vertex, and something is going wrong there.

I have managed a workaround by disabling save the texture_per_wedge (which is necessary just for transfer_color_texture_to_vertex filter.

import pymeshlab as ml
ms = ml.MeshSet()
#Load a mesh with texture per wedge
ms.load_new_mesh('input_pervertex_uv.ply')
m = ms.current_mesh()

print("Input mesh has", m.vertex_number(), 'vertex and', m.face_number(), 'faces' )

ms.apply_filter('convert_pervertex_uv_into_perwedge_uv')
ms.apply_filter('transfer_color_texture_to_vertex')

#Export mesh with color_per_vertex but without texture
ms.save_current_mesh('output.ply',save_wedge_texcoord=False,save_vertex_coord=False )

The list of valid arguments for save_current_mesh can be read here https://pymeshlab.readthedocs.io/en/latest/filter_list.html#save-parameters

Please note that save_vertex_coord refers to Texture coordinates per vertex!!!