]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGTable.cpp
Latest JSBSim changes.
[flightgear.git] / src / FDM / JSBSim / FGTable.cpp
index 48c4877b17c19cb7e7a817bf872abc18e4ab203b..3f81558936d3e020562eeb27e0b0aaf3b753ca6c 100644 (file)
@@ -115,7 +115,8 @@ double FGTable::GetValue(double key)
   int r;
 
   for (r=1; r<=nRows; r++) if (Data[r][0] >= key) break;
-  r = r < 2 ? 2 : (r > nRows ? nRows : r);
+  r   = Clamp(2, r, nRows);
+  key = Clamp(Data[1][0], key, Data[nRows][0]);
 
   // make sure denominator below does not go to zero.
 
@@ -140,10 +141,12 @@ double FGTable::GetValue(double rowKey, double colKey)
   int r, c;
 
   for (r=1;r<=nRows;r++) if (Data[r][0] >= rowKey) break;
-  for (c=1;c<=nCols;c++) if (Data[0][c] >= colKey) break;
+  r = Clamp(2, r, nRows);
+  rowKey = Clamp(Data[1][0], rowKey, Data[nRows][0]);
 
-  c = c < 2 ? 2 : (c > nCols ? nCols : c);
-  r = r < 2 ? 2 : (r > nRows ? nRows : r);
+  for (c=1;c<=nCols;c++) if (Data[0][c] >= colKey) break;
+  c = Clamp(2, c, nCols);
+  colKey = Clamp(Data[0][1], colKey, Data[0][nCols]);
 
   rFactor = (rowKey - Data[r-1][0]) / (Data[r][0] - Data[r-1][0]);
   cFactor = (colKey - Data[0][c-1]) / (Data[0][c] - Data[0][c-1]);
@@ -211,7 +214,12 @@ void FGTable::Print(void)
   if (Type == tt1D) startRow = 1;
   else startRow = 0;
 
-  cout.setf(ios::fixed); // set up output stream
+#if defined (sgi) && !defined(__GNUC__)
+  unsigned long flags = cout.setf(ios::fixed);
+#else
+  ios::fmtflags flags = cout.setf(ios::fixed); // set up output stream
+#endif
+
   cout.precision(4);
 
   for (int r=startRow; r<=nRows; r++) {
@@ -225,7 +233,7 @@ void FGTable::Print(void)
     }
     cout << endl;
   }
-  cout.setf((ios_base::fmtflags)0, ios::floatfield); // reset
+  cout.setf(flags); // reset
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%