Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch Exception on Ascii Ply #59

Open
kzfile opened this issue Aug 16, 2022 · 3 comments
Open

Catch Exception on Ascii Ply #59

kzfile opened this issue Aug 16, 2022 · 3 comments

Comments

@kzfile
Copy link

kzfile commented Aug 16, 2022

Hello,Is there anythong wrong in the new commit?
I just clone the repository and run the example but got exception when reading example_cube-ascii.ply:

........................................................................
Now Reading: example_cube-ascii.ply
        [ply_header] Type: ascii
        [ply_header] Comment: generated by tinyply 2.3
        [ply_header] element: vertex (24)
        [ply_header]    property: x (type=float)
        [ply_header]    property: y (type=float)
        [ply_header]    property: z (type=float)
        [ply_header]    property: nx (type=float)
        [ply_header]    property: ny (type=float)
        [ply_header]    property: nz (type=float)
        [ply_header]    property: u (type=float)
        [ply_header]    property: v (type=float)
        [ply_header] element: face (12)
        [ply_header]    property: vertex_indices (type=uint) (list_type=uchar)
tinyply exception: the following property keys were not found in the header: red, green, blue, alpha,
tinyply exception: the following property keys were not found in the header: r, g, b, a,
tinyply exception: the element key was not found in the header: tristrips
Caught tinyply exception: unexpected EOF. malformed file?
........................................................................
Now Reading: example_cube-binary.ply
        [ply_header] Type: binary
        [ply_header] Comment: generated by tinyply 2.3
        [ply_header] element: vertex (24)
        [ply_header]    property: x (type=float)
        [ply_header]    property: y (type=float)
        [ply_header]    property: z (type=float)
        [ply_header]    property: nx (type=float)
        [ply_header]    property: ny (type=float)
        [ply_header]    property: nz (type=float)
        [ply_header]    property: u (type=float)
        [ply_header]    property: v (type=float)
        [ply_header] element: face (12)
        [ply_header]    property: vertex_indices (type=uint) (list_type=uchar)
tinyply exception: the following property keys were not found in the header: red, green, blue, alpha,
tinyply exception: the following property keys were not found in the header: r, g, b, a,
tinyply exception: the element key was not found in the header: tristrips
        parsing 0.001217mb in 4.04e-05 seconds [30.1238 MBps]
        Read 24 total vertices
        Read 24 total vertex normals
        Read 24 total vertex texcoords
        Read 12 total faces (triangles)

Same exception occured when I try another ascii ply.
I compiled the code on windows msvc/wsl2 and no one was spared.

@guban
Copy link

guban commented Oct 25, 2022

The "unexpected EOF. malformed file?" exception happens when opening a well-formed ASCII file, such as this file: https://people.sc.fsu.edu/~jburkardt/data/ply/airplane.ply.
The exception happens in tinyply 2.3.4, but not in tinyply 2.3.2. It is possible that the problem was introduced in 2.3.4 by the code that avoids crashes when reading incomplete files (the ones with less data than declared in the header).

ton added a commit to ton/PLYbench that referenced this issue Jan 2, 2023
Note; parsing of ASCII PLY files is not benchmarked as ASCII support in
tinyply 2.3 seems to be broken
(ddiakopoulos/tinyply#59).
@3Descape
Copy link
Contributor

Hello.
I stil get the exception "Caught tinyply exception: unexpected EOF. malformed file?" e.g. when reading files exported with Blender.
Intrestingly enough it works if the mesh is triangles only(e.g. applying a triangulate modifier before exporting). The same mesh with quads does not work. I the testfiles.zip file you'll find the same mesh, once triangulated and once with quads. The one with quads should trigger the exception.

testfiles.zip

@3Descape
Copy link
Contributor

okay, I have some more information:
It seems to be caused by a wrong user list hint. e.g.
faces = file.request_properties_from_element("face", { "vertex_indices" }, 3); when the list actually has 4 elements per list.
Setting faces = file.request_properties_from_element("face", { "vertex_indices" }, 0); works and the error disappears.
However, since it is called only "hint"(as to "try this value first and fall back to finding it out ourselfs it that didn't work"), shouldn't there be some validation/fallback, if the user provided hint does not correspond with the size of the actual list in the .ply file?
E.g. something along the lines of

try {
    parse_data(is, false);
} catch(Exception e) {
    parse_data(is, true);
}

in tinyply.h line 544...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants