]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_2DdataFileReader.cpp
Add speed-brake and spoilers controlls
[flightgear.git] / src / FDM / UIUCModel / uiuc_2DdataFileReader.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_2DdataFileReader.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/29/2000   initial release
21                10/25/2001   (RD) Modified so that it recognizes a
22                             blank line
23
24 ----------------------------------------------------------------------
25
26  AUTHOR(S):    Jeff Scott         <jscott@mail.com>
27                Robert Deters      <rdeters@uiuc.edu>
28
29 ----------------------------------------------------------------------
30
31  VARIABLES:
32
33 ----------------------------------------------------------------------
34
35  INPUTS:       -2D file name
36                -conversion factor for x data
37                -conversion factor for y data
38                -conversion factor for z data
39
40 ----------------------------------------------------------------------
41
42  OUTPUTS:      -2D array of x data for each y case
43                -1D array of y data
44                -2D array of z data for each y case
45                -1D array of max number of x-z data sets for each y case
46                -max number of y data sets
47
48 ----------------------------------------------------------------------
49
50  CALLED BY:    uiuc_menu.cpp
51
52 ----------------------------------------------------------------------
53
54  CALLS TO:     specified 2D data file
55
56 ----------------------------------------------------------------------
57
58  COPYRIGHT:    (C) 2000 by Michael Selig
59
60  This program is free software; you can redistribute it and/or
61  modify it under the terms of the GNU General Public License
62  as published by the Free Software Foundation.
63
64  This program is distributed in the hope that it will be useful,
65  but WITHOUT ANY WARRANTY; without even the implied warranty of
66  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
67  GNU General Public License for more details.
68
69  You should have received a copy of the GNU General Public License
70  along with this program; if not, write to the Free Software
71  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
72  USA or view http://www.gnu.org/copyleft/gpl.html.
73
74 **********************************************************************/
75
76 #include "uiuc_2DdataFileReader.h"
77
78
79 void uiuc_2DdataFileReader( string file_name, 
80                             double x[100][100], 
81                             double y[100], 
82                             double z[100][100], 
83                             int xmax[100], 
84                             int &ymax)
85 {
86   ParseFile *matrix;
87   double token_value1;
88   double token_value2;
89   int counter_y = 1, counter_x = 1;
90   string linetoken1;
91   string linetoken2;
92
93   stack command_list;
94
95   /* Read the file and get the list of commands */
96   matrix = new ParseFile(file_name);
97   command_list = matrix -> getCommands();
98
99   for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
100     {
101       linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
102       linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
103
104       istrstream token1(linetoken1.c_str());
105       istrstream token2(linetoken2.c_str());
106
107       //reset token_value1 and token_value2 for first if statement
108       token_value1 = -999;
109       token_value2 = -999;
110
111       token1 >> token_value1;
112       token2 >> token_value2;
113
114       //chenk to see if it is a blank line
115       if (token_value1==-999 && token_value2==-999);
116       //check to see if only one value on line (token2 blank)
117       else if (token_value2 == -999)
118         {
119           y[counter_y] = token_value1 * convert_y;
120
121           ymax = counter_y;
122           counter_y++;
123           counter_x = 1;
124         }
125       else
126         {
127           x[counter_y-1][counter_x] = token_value1 * convert_x;
128           z[counter_y-1][counter_x] = token_value2 * convert_z;
129
130           xmax[counter_y-1] = counter_x;
131           counter_x++;
132         }
133     }
134   return;
135 }
136
137 // end uiuc_2DdataFileReader.cpp