ait-survey

normal2rgb

Dec 4th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<iomanip>
  4. #include<sstream>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char** argv)
  9. {
  10.  
  11.     if(argc!=3)
  12.     {
  13.         fprintf(stderr,"Usage: %s\n(1)Input_filename\n(2)Output_filename\n",argv[0]);
  14.         //exit(1);
  15.     }
  16.    
  17.     ifstream ifs(argv[1]);
  18.     ofstream ofs(argv[2]);
  19.     string line;
  20.    
  21.     cout << "now converting....wait for a short time" <<endl;
  22.    
  23.     while(getline(ifs,line))
  24.     {
  25.         float x,y,z;
  26.         float rgb;
  27.         float cu;
  28.         float nx,ny,nz;
  29.         float fnx,fny,fnz;
  30.         int unx,uny,unz;
  31.         //int r,g,b;
  32.         //int r_down,g_down,b_down;
  33.  
  34.         istringstream is(line);
  35.        
  36.         is  >> nx >> ny >> nz >> cu >> x >> y >> z >> rgb;
  37.             //printf("%f %f %f\n",x,y,z);
  38.             fnx=(nx+1)*255/2;
  39.             fny=(ny+1)*255/2;
  40.             fnz=(nz+1)*255/2;
  41.             unx=(unsigned char)fnx;
  42.             uny=(unsigned char)fny;
  43.             unz=(unsigned char)fnz;
  44.  
  45.         //cout<< x <<" "<< y <<" "<<z<<" "<<r_down<<" "<<g_down<<" "<< b_down<<endl;
  46.         ofs<< x <<" "<< y <<" "<<z<<" "<<unx<<" "<<uny<<" "<<unz<<endl;
  47.  
  48.     }
  49.    
  50.     ifs.close();
  51.     ofs.close();
  52.    
  53.     cout << "finished" << endl;
  54.    
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment