Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

question from:https://stackoverflow.com/questions/65846551/export-of-mesh-fails-to-build-a-readable-ply-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
668 views
Welcome To Ask or Share your Answers For Others

1 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 )

I had to do some research to find the valid arguments for save_current_mesh output. They are stored in a variable named saveCapabilitiesStrings, then converted to lowcase. The arguments can be set to True o False. I will let here those arguments for posterity:

  • binary -> For format that admit ascii or binary
  • save_vertex_quality
  • save_vertex_flag
  • save_vertex_color -> RGBA color per vertex
  • save_vertex_coord -> Texture coordinates per vertex!!!
  • save_vertex_normal
  • save_vertex_radius
  • save_face_quality
  • save_face_flag
  • save_face_color
  • save_face_normal
  • save_wedge_color -> RGBA color per wedge
  • save_wedge_texCoord -> Texture coordinates per wedge
  • save_wedge_normal
  • save_polygonal

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...