Skip to content

Instantly share code, notes, and snippets.

@pranavkantgaur
Last active August 29, 2015 14:14
Show Gist options
  • Save pranavkantgaur/7ae1cbb429e983e7a5ba to your computer and use it in GitHub Desktop.
Save pranavkantgaur/7ae1cbb429e983e7a5ba to your computer and use it in GitHub Desktop.
Minimal example for testing RPly's ply_write function
#include <iostream>
#include <stdlib.h>
#include "rply/rply.h"
using namespace std;
int main()
{
float p[5][3];
for (unsigned int k = 0; k < 5; k++)
{
p[k][0] = 1.0; // arbitrary values
p[k][1] = 2.0;
p[k][2] = 3.0;
}
p_ply pointArray;
if((pointArray = ply_create("output.ply", PLY_ASCII, NULL, 0, NULL)) == NULL)
{
cout << "\nCannot write Mesh output!!";
exit(0);
}
else
{
ply_add_element(pointArray, "vertex", 5);
ply_add_scalar_property(pointArray, "x", PLY_FLOAT);
ply_add_scalar_property(pointArray, "y", PLY_FLOAT);
ply_add_scalar_property(pointArray, "z", PLY_FLOAT);
if (!ply_write_header(pointArray))
cout << "\nHeader not writen" << flush;
for (unsigned int n = 0; n < 5; n++)
for (unsigned int m = 0; m < 3; m++)
ply_write(pointArray, p[n][m]);
ply_close(pointArray);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment