Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[])
- {
- //Decralation of variables
- FILE *fpi,*fpo;
- float x,y,z,nx,ny,nz;
- float fnx,fny,fnz;
- unsigned char unx,uny,unz,r,g,b;
- char point[4];
- //Open file
- if((fpi=fopen(argv[1],"r"))==NULL)
- {
- printf ("The file can't be opened. The program is exit.\n");
- return 0;
- }
- //Open VTK file for save
- if((fpo=fopen(argv[2],"w"))==NULL)
- {
- printf("The file can't be opened. The program is exit.\n");
- return 0;
- }
- while(fscanf(fpi,"%f %f %f %d %d %d %f %f %f",&x,&y,&z,&r,&g,&b,&nx,&ny,&nz)!=EOF)
- {
- //printf("%f %f %f\n",x,y,z);
- fnx=(nx+1)*255/2;
- fny=(ny+1)*255/2;
- fnz=(nz+1)*255/2;
- unx=(unsigned char)fnx;
- uny=(unsigned char)fny;
- unz=(unsigned char)fnz;
- fprintf(fpo,"%f %f %f %d %d %d\n",x,y,z,unx,uny,unz);
- }
- fclose(fpi);
- fclose(fpo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement