Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<iomanip>
- #include<sstream>
- using namespace std;
- int main(int argc, char** argv)
- {
- if(argc!=3)
- {
- fprintf(stderr,"Usage: %s\n(1)Input_filename\n(2)Output_filename\n",argv[0]);
- //exit(1);
- }
- ifstream ifs(argv[1]);
- ofstream ofs(argv[2]);
- string line;
- cout << "now converting....wait for a short time" <<endl;
- while(getline(ifs,line))
- {
- float x,y,z;
- float rgb;
- float cu;
- float nx,ny,nz;
- float fnx,fny,fnz;
- int unx,uny,unz;
- //int r,g,b;
- //int r_down,g_down,b_down;
- istringstream is(line);
- is >> nx >> ny >> nz >> cu >> x >> y >> z >> rgb;
- //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;
- //cout<< x <<" "<< y <<" "<<z<<" "<<r_down<<" "<<g_down<<" "<< b_down<<endl;
- ofs<< x <<" "<< y <<" "<<z<<" "<<unx<<" "<<uny<<" "<<unz<<endl;
- }
- ifs.close();
- ofs.close();
- cout << "finished" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment