File indexing completed on 2024-04-06 12:15:32
0001
0002 #include <fstream>
0003 #include <iostream>
0004 #include <sstream>
0005 #include <string>
0006 #include <vector>
0007 #include <cmath>
0008 #include <iomanip>
0009
0010 int main (int argc, char *argv[]) {
0011 std::string fname1, fname2;
0012
0013 if ( argc == 3 ) {
0014
0015 fname1 = argv[1];
0016 fname2 = argv[2];
0017
0018 } else {
0019 std::cout << "need two arguments (filenames) to compare dumpGeoHistory"
0020 << std::endl;
0021 return 1;
0022 }
0023
0024 std::ifstream f1(fname1.c_str());
0025 std::ifstream f2(fname2.c_str());
0026 std::string l1, l2, ts;
0027 std::vector<double> t1(3), t2(3), r1(9), r2(9);
0028
0029 while ( !f1.eof() && !f2.eof() ) {
0030 getline(f1, l1, ',');
0031 getline(f2, l2, ',');
0032 if ( l1 != l2 ) {
0033 std::cout << "Lines don't match or are out of synchronization."
0034 << " The difference is much bigger than just the numbers,"
0035 << " actual parts are missing or added. This program "
0036 << " does not handle this at this time... use diff first."
0037 << std::endl
0038 << "["<<l1 <<"]"<< std::endl
0039 << "["<<l2 <<"]"<< std::endl
0040 << std::endl;
0041 return 1;
0042 }
0043
0044
0045
0046
0047
0048 size_t i = 0;
0049 while ( i < 3 ) {
0050 ts.clear();
0051 getline(f1,ts,',');
0052
0053 std::istringstream s1 (ts);
0054 s1>>t1[i++];
0055 }
0056
0057 i=0;
0058 while ( i < 8 ) {
0059 ts.clear();
0060 getline(f1,ts,',');
0061
0062 std::istringstream s1 (ts);
0063 s1>>r1[i++];
0064 }
0065 ts.clear();
0066 getline(f1, ts);
0067 std::istringstream s2(ts);
0068 s2>>r1[8];
0069
0070 i=0;
0071 while ( i < 3 ) {
0072 ts.clear();
0073 getline(f2,ts,',');
0074
0075 std::istringstream s1 (ts);
0076 s1>>t2[i++];
0077 }
0078
0079 i=0;
0080 while ( i < 8 ) {
0081 ts.clear();
0082 getline(f2,ts,',');
0083
0084 std::istringstream s1 (ts);
0085 s1>>r2[i++];
0086 }
0087 ts.clear();
0088 getline(f2, ts);
0089 std::istringstream s3(ts);
0090 s3>>r2[8];
0091
0092
0093
0094
0095
0096
0097
0098 std::vector<bool> cerrorind;
0099 cerrorind.reserve(3);
0100 for (i=0; i < 3; i++) {
0101
0102
0103
0104
0105 if ( std::fabs(t1[i] - t2[i]) > 0.0000001 ) cerrorind[i] = true;
0106 else cerrorind[i] = false;
0107 }
0108 if ( cerrorind[0] || cerrorind[1] || cerrorind[2] ) std::cout << l1;
0109 for ( i=0; i<3; ++i ) {
0110 if ( cerrorind[i] ) {
0111 std::cout << " coordinate ";
0112 if ( i == 0 ) std::cout << "x ";
0113 else if ( i == 1 ) std::cout << "y ";
0114 else if ( i == 2 ) std::cout << "z ";
0115 std::cout << " is different by: " << std::setw(13)
0116 << std::setprecision(7) << std::fixed << t1[i] - t2[i]
0117 << " mm ";
0118 }
0119 }
0120 bool rerror(false);
0121 for (i=0; i < 9; i++) {
0122
0123
0124 if ( std::fabs(r1[i] - r2[i]) > 0.0000001 ) rerror = true;
0125 }
0126 if ( rerror && !cerrorind[0] && !cerrorind[1] && !cerrorind[2] ) {
0127 std::cout << l1 << " ";
0128 }
0129 if ( rerror ) {
0130 for (i=0; i < 9; i++) {
0131
0132
0133 if ( std::fabs(r1[i] - r2[i]) > 0.0000001 ) {
0134
0135 std::cout << " index " << i << " of rotation matrix differs by "
0136 << std::setw(13) << std::setprecision(7)
0137 << std::fixed << r1[i] - r2[i];
0138 }
0139 }
0140 std::cout << std::endl;
0141 } else if ( cerrorind[0] || cerrorind[1] || cerrorind[2]) {
0142 std::cout << std::endl;
0143 }
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160 }
0161 return 0;
0162 }