]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_1DdataFileReader.cpp
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / UIUCModel / uiuc_1DdataFileReader.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_1DdataFileReader.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  Reads name of data file to be opened and reads data 
8                into appropriate arrays or matrices
9
10 ----------------------------------------------------------------------
11
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15
16  REFERENCES:   
17
18 ----------------------------------------------------------------------
19
20  HISTORY:      02/15/2000   initial release
21
22 ----------------------------------------------------------------------
23
24  AUTHOR(S):    Jeff Scott         <jscott@mail.com>
25
26 ----------------------------------------------------------------------
27
28  VARIABLES:
29
30 ----------------------------------------------------------------------
31
32  INPUTS:       -1D data file name
33                -conversion factor for y data
34                -conversion factor for x data
35
36 ----------------------------------------------------------------------
37
38  OUTPUTS:      -array of x data
39                -array of y data
40                -max number of data sets
41
42 ----------------------------------------------------------------------
43
44  CALLED BY:    uiuc_menu.cpp
45
46 ----------------------------------------------------------------------
47
48  CALLS TO:     specified 1D data file
49
50 ----------------------------------------------------------------------
51
52  COPYRIGHT:    (C) 2000 by Michael Selig
53
54  This program is free software; you can redistribute it and/or
55  modify it under the terms of the GNU General Public License
56  as published by the Free Software Foundation.
57
58  This program is distributed in the hope that it will be useful,
59  but WITHOUT ANY WARRANTY; without even the implied warranty of
60  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
61  GNU General Public License for more details.
62
63  You should have received a copy of the GNU General Public License
64  along with this program; if not, write to the Free Software
65  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
66  USA or view http://www.gnu.org/copyleft/gpl.html.
67
68 **********************************************************************/
69
70 #include "uiuc_1DdataFileReader.h"
71
72 int 
73 uiuc_1DdataFileReader( string file_name,  
74                          double x[100], double y[100], int &xmax ) 
75 {
76
77   ParseFile *matrix;
78   double token_value1;
79   double token_value2;
80   int counter = 1, data = 0;
81   string linetoken1; 
82   string linetoken2; 
83   stack command_list;
84
85   /* Read the file and get the list of commands */
86   matrix = new ParseFile(file_name);
87   command_list = matrix -> getCommands();
88
89   for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
90     {
91       linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
92       linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
93
94       istrstream token1(linetoken1.c_str());
95       istrstream token2(linetoken2.c_str());
96
97       token1 >> token_value1;
98       token2 >> token_value2;
99
100       x[counter] = token_value1 * convert_x;
101       y[counter] = token_value2 * convert_y;
102       xmax = counter;
103       counter++;
104       data = 1;
105     }
106   return data;
107 }
108
109 // end uiuc_1DdataFileReader.cpp