Advertisement
ait-survey

nornal2rgb

Jan 26th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.     //Decralation of variables
  7.     FILE *fpi,*fpo;
  8.     float x,y,z,nx,ny,nz;
  9.     float fnx,fny,fnz;
  10.    
  11.     unsigned char unx,uny,unz,r,g,b;
  12.     char point[4];
  13.  
  14.     //Open file
  15.     if((fpi=fopen(argv[1],"r"))==NULL)
  16.     {
  17.         printf ("The file can't be opened. The program is exit.\n");
  18.  
  19.         return 0;
  20.     }
  21.  
  22.     //Open VTK file for save
  23.     if((fpo=fopen(argv[2],"w"))==NULL)
  24.     {
  25.         printf("The file can't be opened. The program is exit.\n");
  26.  
  27.         return 0;
  28.     }
  29.  
  30.     while(fscanf(fpi,"%f %f %f %d %d %d %f %f %f",&x,&y,&z,&r,&g,&b,&nx,&ny,&nz)!=EOF)
  31.     {
  32.             //printf("%f %f %f\n",x,y,z);
  33.             fnx=(nx+1)*255/2;
  34.             fny=(ny+1)*255/2;
  35.             fnz=(nz+1)*255/2;
  36.             unx=(unsigned char)fnx;
  37.             uny=(unsigned char)fny;
  38.             unz=(unsigned char)fnz;
  39.             fprintf(fpo,"%f %f %f %d %d %d\n",x,y,z,unx,uny,unz);
  40.  
  41.     }
  42.  
  43.         fclose(fpi);
  44.         fclose(fpo);
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement