void write_ply_header(FILE* f, bool ascii, int npoints, int zone, bool hem, bool colors, bool normals) { if (!ascii) if (!test_little_endian()) fail("BINARY PLY NOT SUPPORTED ON BIG ENDIAN SYSTEMS!\n"); fprintf(f, "ply\n"); if (ascii) fprintf(f, "format ascii 1.0\n"); else fprintf(f, "format binary_little_endian 1.0\n"); fprintf(f, "comment created by S2P\n"); if (zone >= 0) fprintf(f, "comment projection: UTM %02d%s\n", zone, (hem ? "N" : "S")); fprintf(f, "element vertex %d\n", npoints); fprintf(f, "property double x\n"); fprintf(f, "property double y\n"); fprintf(f, "property double z\n"); if (normals) { fprintf(f, "property double nx\n"); fprintf(f, "property double ny\n"); fprintf(f, "property double nz\n"); } if (colors) { fprintf(f, "property uchar red\n"); fprintf(f, "property uchar green\n"); fprintf(f, "property uchar blue\n"); } fprintf(f, "end_header\n"); }
longs_to_file(char *filename, FILE *infile, int len, int *dsizep, int *usizep) { FILE *outfile; int val; int le; int i; if ((outfile = fopen(filename, "w")) == 0) { fprintf(stderr, "Can't open output file %s\n", filename); exit(1); } le = test_little_endian(); for (i=0; i<8; i++) { if (le) { val = (unsigned char)fgetc(infile); val |= ((unsigned char)fgetc(infile) << 8); val |= ((unsigned char)fgetc(infile) << 16); val |= ((unsigned char)fgetc(infile) << 24); } else { val = ((unsigned char)fgetc(infile) << 24); val |= ((unsigned char)fgetc(infile) << 16); val |= ((unsigned char)fgetc(infile) << 8); val |= (unsigned char)fgetc(infile); } if (i == 3) { *dsizep = val; } if (i == 5) { *usizep = val; } fprintf(outfile, "0x%08x, ", val); } fputc('\n', outfile); fclose(outfile); }