exchangecomp.cpp
Go to the documentation of this file.00001 #include <iostream>
00002 #include <fstream>
00003 #include <vector>
00004 #include <iterator>
00005 #include "TimeSeriesData.h"
00006
00007 using namespace std;
00008 using namespace gplib;
00009
00010 string version = "$Id: exchangecomp.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00011
00012 int main(int argc, char *argv[])
00013 {
00014 TimeSeriesData TsData;
00015
00016 string mtufilename, compfilename;
00017 cout
00018 << "This is exchangecomp: Exchange one component of MTU file by contents of ascii file"
00019 << endl << endl;
00020 cout
00021 << " Output will have the same name as MTU Input with '.rep' appended "
00022 << endl << endl;
00023 cout << " This is Version: " << version << endl << endl;
00024
00025 cout << "Mtu filename: ";
00026 cin >> mtufilename;
00027 TsData.GetData(mtufilename);
00028
00029 cout << "Component filename: ";
00030 cin >> compfilename;
00031 vector<double> compdata;
00032 ifstream compfile(compfilename.c_str());
00033 copy(istream_iterator<double> (compfile), istream_iterator<double> (),
00034 back_inserter(compdata));
00035 if (compdata.size() != TsData.GetData().GetEx().GetData().size())
00036 {
00037 std::cerr << "Number of points incompatible !";
00038 return 100;
00039 }
00040 int compindex;
00041 cout << "Enter target component number (Ex,Ey,Hx,Hy): ";
00042 cin >> compindex;
00043 std::vector<double>::iterator outit;
00044 switch (compindex)
00045 {
00046 case 1:
00047 outit = TsData.GetData().GetEx().GetData().begin();
00048 break;
00049 case 2:
00050 outit = TsData.GetData().GetEy().GetData().begin();
00051 break;
00052 case 3:
00053 outit = TsData.GetData().GetHx().GetData().begin();
00054 break;
00055 case 4:
00056 outit = TsData.GetData().GetHy().GetData().begin();
00057 break;
00058 default:
00059 std::cerr << "Invalid component selection !";
00060 return 100;
00061 break;
00062 }
00063 copy(compdata.begin(), compdata.end(), outit);
00064 TsData.WriteAsMtu(mtufilename + ".rep");
00065 }