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

PlyFile::read ignores order of requested properties #48

Open
PeterBowman opened this issue Dec 21, 2020 · 1 comment
Open

PlyFile::read ignores order of requested properties #48

PeterBowman opened this issue Dec 21, 2020 · 1 comment

Comments

@PeterBowman
Copy link

Let's assume I have the following dummy .ply file:

ply
format ascii 1.0
element vertex 3
property float x
property float y
property float z
property uchar blue
property uchar green
property uchar red
end_header
1 2 3 200 201 202
4 5 6 203 204 205
7 8 9 206 207 208

Please note the order of blue, green and red properties.

Then, I want to load this information into a pre-made structure an external library imposes on me, the peculiarity being that it represents color values encoded in memory in a specific order. You can read this issue in a twofold manner: either order is BGR in the .ply file and RGB in my custom structure, or order is RGB in the .ply and BGR in said structure.

In other words, the order of properties in the .ply file differs from the order of properties as represented in memory by the structure, let's name it float3 in the example below. My attempt to circumvent this scenario is to request said properties in the order expected by float3:

struct float3 { float red, green, blue; }; // RGB

tinyply::PlyFile file;
// boilerplate omitted, we open a .ply file with color properties encoded as BGR

auto rgb = file.request_properties_from_element("vertex", {"red", "green", "blue"});
// now load `rgb` into an instance of `float3`

I'd expect tinyply to parse the .ply in the order specified in request_properties_from_element, which is what I ultimately want to memcpy into my float3 structure. However, tinyply reads actual blue values as red and viceversa, simply following the order of properties in the .ply file.

@PeterBowman
Copy link
Author

As a workaround, I resorted to requesting individual color properties, i.e.:

auto r = file.request_properties_from_element("vertex", {"red"});
auto g = file.request_properties_from_element("vertex", {"green"});
auto b = file.request_properties_from_element("vertex", {"blue"});

// now, memcpy those values individually into the `float3` structure

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

1 participant