Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************:::
- xyzrgb2yxzrgb
- 21/08/2016
- *******************************************************************************/
- #include <fstream>
- #include <iostream>
- #include<iomanip>
- #include<sstream>
- using namespace std;
- int main ( int argc, char *argv[] )
- {
- if ( argc != 3 ) // argc should be 2 for correct execution
- // We print argv[0] assuming it is the program name
- cout<<"usage: "<< argv[0] <<" <filename>\n";
- // else
- // {
- // We assume argv[1] is a filename to open
- // Always check to see if file opening succeeded
- // if ( !ifs.is_open() || !ofs.is_open() )
- // cout<<"Could not open file\n";
- // else
- // {
- // char x;
- // the_file.get ( x ) returns false if the end of the file
- // is reached or an error occurs
- // while ( the_file.get ( x ) )
- // ifs.get ( x );
- // cout<< "file is opened"<<endl;
- // }
- // the_file is closed implicitly here
- // }
- ifstream ifs ( argv[1] );
- ofstream ofs ( argv[2] );
- string line;
- while(getline(ifs,line))
- {
- double x,y,z;
- int r,g,b;
- istringstream is(line);
- is >> x >> y >> z >> r >> g >> b;
- ofs<<fixed<<showpoint;
- ofs<< setprecision( 3 )<<y <<" "<< x <<" "<<z<<" "<<r<<" "<<g<<" "<<b<<endl;
- //ofs<< setprecision( 3 )<<y <<" "<< x <<" "<<z;
- //ofs<<" "<<r<<" "<<g<<" "<<b<<endl;
- }
- ifs.close();
- ofs.close();
- cout << "-----finished------" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment