]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/UIUCModel/uiuc_1DdataFileReader.cpp
Sync. w. JSB CVS as of 15/01/2007
[flightgear.git] / src / FDM / UIUCModel / uiuc_1DdataFileReader.cpp
index 2f49199c1a913d48df3a55f3f94f8a7613f28392..03b7ba2ad771ccecce05433d9dc9a9c8e50ff58d 100644 (file)
 ----------------------------------------------------------------------
 
  HISTORY:      02/15/2000   initial release
+               09/01/2002   (RD) added second data file reader for
+                            integer case
+               06/30/2003   (RD) replaced istrstream with istringstream
+                            to get rid of the annoying warning about
+                            using the strstream header
 
 ----------------------------------------------------------------------
 
  AUTHOR(S):    Jeff Scott         <jscott@mail.com>
+               Robert Deters      <rdeters@uiuc.edu>
 
 ----------------------------------------------------------------------
 
 
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA or view http://www.gnu.org/copyleft/gpl.html.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 **********************************************************************/
 
 #include "uiuc_1DdataFileReader.h"
 
 int 
-uiuc_1DdataFileReader( string file_name, double convert_x, double convert_y, 
-                          double x[100], double y[100], int &xmax )
+uiuc_1DdataFileReader( string file_name,  
+                         double x[], double y[], int &xmax ) 
 {
 
   ParseFile *matrix;
@@ -81,6 +86,7 @@ uiuc_1DdataFileReader( string file_name, double convert_x, double convert_y,
   string linetoken1; 
   string linetoken2; 
   stack command_list;
+  static string uiuc_1DdataFileReader_error = " (from uiuc_1DdataFileReader.cpp) ";
 
   /* Read the file and get the list of commands */
   matrix = new ParseFile(file_name);
@@ -91,8 +97,8 @@ uiuc_1DdataFileReader( string file_name, double convert_x, double convert_y,
       linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
       linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
 
-      istrstream token1(linetoken1.c_str());
-      istrstream token2(linetoken2.c_str());
+      istringstream token1(linetoken1.c_str());
+      istringstream token2(linetoken2.c_str());
 
       token1 >> token_value1;
       token2 >> token_value2;
@@ -101,6 +107,50 @@ uiuc_1DdataFileReader( string file_name, double convert_x, double convert_y,
       y[counter] = token_value2 * convert_y;
       xmax = counter;
       counter++;
+      //(RD) will create error check later, we can have more than 100
+      //if (counter > 100)
+      //{      
+      //  uiuc_warnings_errors(6, uiuc_1DdataFileReader_error);
+      //};
+      data = 1;
+    }
+  return data;
+}
+
+//can't have conversions in this version since the numbers are
+//to stay as integers
+int 
+uiuc_1DdataFileReader( string file_name,  
+                         double x[], int y[], int &xmax ) 
+{
+
+  ParseFile *matrix;
+  int token_value1;
+  int token_value2;
+  int counter = 1, data = 0;
+  string linetoken1; 
+  string linetoken2; 
+  stack command_list;
+
+  /* Read the file and get the list of commands */
+  matrix = new ParseFile(file_name);
+  command_list = matrix -> getCommands();
+
+  for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
+    {
+      linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
+      linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
+
+      istringstream token1(linetoken1.c_str());
+      istringstream token2(linetoken2.c_str());
+
+      token1 >> token_value1;
+      token2 >> token_value2;
+
+      x[counter] = token_value1;
+      y[counter] = token_value2;
+      xmax = counter;
+      counter++;
       data = 1;
     }
   return data;