in src/SampleVisibleMeshSurface.cpp [23:49]
void SavePointsToPLY(const std::vector<Eigen::Vector3f>& verts, const std::string outputfile) {
const std::size_t num_verts = verts.size();
Eigen::Vector3f v;
std::ofstream plyFile;
plyFile.open(outputfile);
plyFile << "ply\n";
plyFile << "format ascii 1.0\n";
plyFile << "element vertex " << num_verts << "\n";
plyFile << "property float x\n";
plyFile << "property float y\n";
plyFile << "property float z\n";
plyFile << "element face " << (num_verts / 3) << "\n";
plyFile << "property list uchar int vertex_index\n";
plyFile << "end_header\n";
for (uint i = 0; i < num_verts; i++) {
v = verts[i];
plyFile << v[0] << " " << v[1] << " " << v[2] << "\n";
}
for (uint i = 0; i < num_verts; i += 3) {
plyFile << "3 " << i << " " << (i + 1) << " " << (i + 2) << "\n";
}
plyFile.close();
}