ddiakopoulos / tinyply

:earth_africa: C++11 ply 3d mesh format importer & exporter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What exactly does list_size_hint in request_properties_from_element refer to?

this-username-is-taken opened this issue · comments

Does it refer to the number of elements in a list or the size in number of bytes? Or something else?

For example, if I have a file with header like this:

ply
format ascii 1.0
element vertex 10
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
property float nx
property float ny
property float nz
end_header

and rows like this:

52.4691 1.49131 82.4518 108 81 62 -0.175547 0.335647 0.925486

Would the list_size_hint be 9 or 27 (6 x 4 + 3 x 1)?

Hi @this-username-is-taken list_size_hint is traditionally only used for face elements. Without faces, your header looks like it's a point cloud with per-vertex normals. The format is quite generic and face / vertex_index elements can support any number of vertices per face. e.g. 3 for triangles, 4 for quads, 5+ for n-gons, etc. Triangle strips are another use-case.

Most people stick with either triangles or quads (usually all of the same type, although rarely you'll see mixed tri/quad files). If you assume they're all either tris (list size hint 3) or quads (list size hint 4), then parsing the file into memory is considerably faster. If you generally don't know the format of the files you're importing (e.g. in an engine that can support arbitrary input), it's best to leave this value 0.

Hope that helps!