write mesh to .off file
| 322 | |
| 323 | // write mesh to .off file |
| 324 | void writeOFF( |
| 325 | const char* fpath, |
| 326 | McFloat* pVertices, |
| 327 | McUint32* pFaceIndices, |
| 328 | McUint32* pFaceSizes, |
| 329 | McUint32 numVertices, |
| 330 | McUint32 numFaces) |
| 331 | { |
| 332 | fprintf(stdout, "write: %s\n", fpath); |
| 333 | |
| 334 | FILE* file = fopen(fpath, "w"); |
| 335 | |
| 336 | if (file == NULL) { |
| 337 | fprintf(stderr, "error: failed to open `%s`", fpath); |
| 338 | exit(1); |
| 339 | } |
| 340 | |
| 341 | fprintf(file, "OFF\n"); |
| 342 | fprintf(file, "%d %d %d\n", numVertices, numFaces, 0 /*numEdges*/); |
| 343 | int i; |
| 344 | for (i = 0; i < (int)numVertices; ++i) { |
| 345 | McFloat* vptr = pVertices + (i * 3); |
| 346 | fprintf(file, "%f %f %f\n", vptr[0], vptr[1], vptr[2]); |
| 347 | } |
| 348 | |
| 349 | int faceBaseOffset = 0; |
| 350 | for (i = 0; i < (int)numFaces; ++i) { |
| 351 | McUint32 faceVertexCount = pFaceSizes[i]; |
| 352 | fprintf(file, "%d", (int)faceVertexCount); |
| 353 | int j; |
| 354 | for (j = 0; j < (int)faceVertexCount; ++j) { |
| 355 | McUint32* fptr = pFaceIndices + faceBaseOffset + j; |
| 356 | fprintf(file, " %d", *fptr); |
| 357 | } |
| 358 | fprintf(file, "\n"); |
| 359 | faceBaseOffset += faceVertexCount; |
| 360 | } |
| 361 | |
| 362 | fclose(file); |
| 363 | } |
nothing calls this directly
no outgoing calls
no test coverage detected