MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / exportPLY

Function exportPLY

Tools/MeshSkinning/main.cpp:1108–1148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1106}
1107
1108void exportPLY()
1109{
1110 std::string fileName = convertFileName(output, currentFrame);
1111 LOG_INFO << "Writing: " << fileName;
1112
1113 FileSystem::makeDir(FileSystem::getFilePath(FileSystem::normalizePath(output)));
1114
1115
1116 // Suppose these hold your data
1117 std::vector<std::array<double, 3>> meshVertexPositions;
1118 std::vector<std::vector<size_t>> meshFaceIndices;
1119
1120 const std::vector<Vector3r>& vertices = meshX;
1121 const std::vector<unsigned int>& faces = mesh.getFaces();
1122 int n_vertices = (int)vertices.size();
1123 int n_triangles = (int)faces.size() / 3;
1124
1125 meshVertexPositions.resize(n_vertices);
1126 for (int i = 0; i < n_vertices; i++)
1127 {
1128 meshVertexPositions[i] = { vertices[i][0], vertices[i][1], vertices[i][2] };
1129 }
1130
1131 meshFaceIndices.resize(n_triangles);
1132 for (int i = 0; i < n_triangles; i++)
1133 {
1134 meshFaceIndices[i].resize(3);
1135 meshFaceIndices[i] = { faces[3*i], faces[3 * i+1], faces[3 * i+2] };
1136 }
1137
1138 // Create an empty object
1139 happly::PLYData plyOut;
1140
1141 // Add mesh data (elements are created automatically)
1142 plyOut.addVertexPositions(meshVertexPositions);
1143 plyOut.addFaceIndices(meshFaceIndices);
1144
1145
1146 // Write the object to file
1147 plyOut.write(fileName, happly::DataFormat::Binary);
1148}
1149
1150void writeCurrentFrame()
1151{

Callers 1

writeCurrentFrameFunction · 0.85

Calls 6

addVertexPositionsMethod · 0.80
addFaceIndicesMethod · 0.80
convertFileNameFunction · 0.70
sizeMethod · 0.45
resizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected