ddiakopoulos / tinyply

:earth_africa: C++11 ply 3d mesh format importer & exporter
598 stars 118 forks source link

Failed to open a .ply file #31

Closed elenaVal closed 4 years ago

elenaVal commented 5 years ago

Hello,

I am trying to read a .ply file, however, i always get back the following message:

Caught tinyply exception: failed to open ... tinyply exception: header had no elements defined. malformed file? ...

I have read in the description, that you need only to add the header file, so i just add to my project the tinyply header and based on the example.cpp (read_ply_file method) file i wrote a method to my application which reads the .ply file.

Here you can find also the header of the ply file i am trying to read (i would like to point out that i tried to read different ply files but i always got back the previous errors).

ply
format binary_little_endian 1.0
comment MergePly generated
element vertex 2694360
property float x
property float y
property float z
property float nx
property float ny
property float nz
property uchar red
property uchar green
property uchar blue
element face 0
property list uchar int vertex_indices
end_header

Do you have any idea, what i am doing wrong? Thank you in advance, Elena.

ddiakopoulos commented 4 years ago

Hi @elenaVal - I just looked into this and changed the behavior so that parse_header will return false (meaning you probably shouldn't read the file). It's because element face has a size of zero - theoretically a malformed file, although I don't think strictly disallowed. This exception will no longer throw and you should be able to read the file without issue.