1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iterator>
#include "matrix_12.h"
using namespace std;
int main(int argc, char *argv[])
{
// Command line argument goes like: out.txt in.txt
std::string file_in, file_out;
file_in = argv[1];
file_out= argv[2]; // Parameter File for Reading the Inputs
std::vector<matrix> traces;
if (argc !=3) { std::cout << "Please enter correct number of arguments.. Program exiting\n" << std::endl; return 1; }
else std::cout << "Correct Number of arguments. Running the program" << std::endl;
std::ifstream file_par(file_in.c_str());
std::ofstream fileout;
fileout.open(file_out.c_str(), std::ios_base::app);
long line_No=0;
std::cout << "Files read, starting the Code" << std::endl;
std::cout << "Input file name is " << file_in << std::endl;
std::cout << "Output file name is " << file_out << std::endl;
if (file_par.is_open())
{
while(!file_par.eof() )
{
std::string line,temp1,temp2,temp3,temp4;
std::stringstream linestring;
matrix temp;
linestring.clear();
getline(file_par,line);
linestring <<line;
linestring >> temp1 >> temp.tag >> temp3 >> temp4 >> temp(0,0) >> temp(0,1) >> temp(0,2) ;
if (temp3 == "Rotation")
{
linestring.clear();
linestring <<line;
getline(file_par,line);
linestring <<line;
linestring >> temp1 >> temp2 >> temp(1,0) >> temp(1,1) >> temp(1,2) ;
getline(file_par,line);
linestring <<line;
linestring >> temp1 >> temp2 >> temp(2,0) >> temp(2,1) >> temp(2,2) ;
temp.computeAngle();
temp.print(fileout);
temp.print (std::cout);
line_No+=2;
}
line_No++;
if (line_No > 10000) break;
}
}
fileout.close();
file_par.close();
return 0;
}
|