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

write variable length lists (tinyply 2.0) #17

Open
caselitz opened this issue Apr 26, 2018 · 14 comments
Open

write variable length lists (tinyply 2.0) #17

caselitz opened this issue Apr 26, 2018 · 14 comments

Comments

@caselitz
Copy link

Hi,
the readme of tinyply 2.0 states:

Version 2.0 is mostly an API re-write, although various bits of the implementation have been changed. In fact, the changes reduce the overall speed of the library around 5%, although at much greater flexibility for further improvements to support variable length lists. One notable change is that tinyply now produces and consumes untyped byte buffers, with type information held as metadata.

Unfortunately there is no example how to write (and read) a variable length list in the example. I wonder how this works. I would basically like to write/read this

ply
format ascii 1.0
comment author: Greg Turk
comment object: another cube
element vertex 8
property float x
property float y
property float z
property uchar red                   { start of vertex color }
property uchar green
property uchar blue
element face 7
property list uchar int vertex_index  { number of vertices for each face }
element edge 5                        { five edges in object }
property int vertex1                  { index to first vertex of edge }
property int vertex2                  { index to second vertex }
property uchar red                    { start of edge color }
property uchar green
property uchar blue
end_header
0 0 0 255 0 0                         { start of vertex list }
0 0 1 255 0 0
0 1 1 255 0 0
0 1 0 255 0 0
1 0 0 0 0 255
1 0 1 0 0 255
1 1 1 0 0 255
1 1 0 0 0 255
3 0 1 2                           { start of face list, begin with a triangle }
3 0 2 3                           { another triangle }
4 7 6 5 4                         { now some quadrilaterals }
4 0 4 5 1
4 1 5 6 2
4 2 6 7 3
4 3 7 4 0
0 1 255 255 255                   { start of edge list, begin with white edge }
1 2 255 255 255
2 3 255 255 255
3 0 255 255 255
2 0 0 0 0                         { end with a single black line }

where lists should be represented by a std::vector<std::vector<T>>. Is this supported by tinyply 2.0?

I also saw this was discussed here and here but this is quite old and it is not clear to me what ended up in upstream (branch 2.0) and what is only available in some forks etc.?

@caselitz
Copy link
Author

where lists should be represented by a std::vector<std::vector<T>>

Actually it would be nice if both was possible, variable-length (std::vector<std::vector<T>>) and flat fixed-length (std::vector<T>)

@ddiakopoulos
Copy link
Owner

Hi @caselitz variable length lists are fairly uncommon and so I haven't put much time towards supporting them in this library. I re-wrote some inner loops of tinyply 2.0 to better support these in the future (i.e. they do not work today) but I need to loop back and actually write the functionality. I believe @bchretien has a fork of tinyply which actually does work.

@caselitz
Copy link
Author

Thanks for your quick reply and the clarification (and of course for providing the library)!

I feel the description in the readme regarding the variable length lists might be a bit misleading (at least I misunderstood it). Anyhow, I think supporting them would be a great feature for the future since they are, even though possibly uncommon, part of the PLY format.

PS: I ended up using the old version with the stuff from bchretiens fork, seems to work nicely. :)

@ddiakopoulos
Copy link
Owner

Hi @caselitz -- It sounds like you're unblocked on this feature already from bchretien's fork, but if you're feeling adventurous I just pushed preliminary support for this feature on a branch: https://github.com/ddiakopoulos/tinyply/tree/variable-length

@svenevs
Copy link
Contributor

svenevs commented May 3, 2018

Out of pure curiosity, in what context do you use / need variable length lists? It sounds so exotic to me. It seems for quad support?

@ddiakopoulos
Copy link
Owner

@svenevs The only rational thing I can think of is given by the example in the PLY spec. Mixed uses of triangles and quads.

@caselitz
Copy link
Author

caselitz commented May 3, 2018

Hi @caselitz -- It sounds like you're unblocked on this feature already from bchretien's fork, but if you're feeling adventurous I just pushed preliminary support for this feature on a branch: https://github.com/ddiakopoulos/tinyply/tree/variable-length

That's great, thank's for your effort! I will try it, hope to find the time soon...

Out of pure curiosity, in what context do you use / need variable length lists? It sounds so exotic to me. It seems for quad support?

I'm saving a list of objects in the PLY and each object is a set of (arbitrary many) vertices whose vertex_indices I store - so in my code I have a std::vector<std::vector<uint32_t>> objects and basically use tinyply to serialize/deserialize the data along with a "normal" triangle mesh.

I think this is within the scope of the PLY format. Quote from here

The PLY format describes an object as a collection of vertices, faces and other elements,

@caselitz
Copy link
Author

caselitz commented May 9, 2018

I found the time to test @ddiakopoulos.

The reading works fine for me (only the debug output should be removed).

However, the writing does not work. Have you implemented/adapted that already? At least there is no adaption in the example and also the basic example fails (segfault, core dump).

@caselitz
Copy link
Author

I saw some recent activity in the repo. Any progress on this issue here @ddiakopoulos? Maybe it would be a nice thing to include in tinyply 2.1

Thanks,
Tim

@ddiakopoulos
Copy link
Owner

@caselitz working on it for 2.2 :)

Long tail is not the actual implementation itself but testing it adequately

@caselitz
Copy link
Author

@caselitz working on it for 2.2 :)

this is not included in 2.2, right? any chance for 2.3? :)

@ddiakopoulos
Copy link
Owner

@caselitz yes, 2.3 will entirely be dedicated to variable length!

@caselitz
Copy link
Author

caselitz commented Apr 3, 2019

Any hope for 2.3 @ddiakopoulos?

Thanks,
Tim

@caselitz
Copy link
Author

So now I'm hoping for 2.4 (saw a commit in the branch), great that you found time to work on the library again... thanks! :)

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

No branches or pull requests

3 participants