]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_mass.cpp
Provide a fix for the MSVC/Cygwin GDI build problem
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_mass.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_mass.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  reads input data for specified aircraft and creates 
8                approporiate data storage space
9
10 ----------------------------------------------------------------------
11
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15
16  REFERENCES:   based on "menu reader" format of Michael Selig
17
18 ----------------------------------------------------------------------
19
20  HISTORY:      04/04/2003   initial release
21
22 ----------------------------------------------------------------------
23
24  AUTHOR(S):    Robert Deters      <rdeters@uiuc.edu>
25                Michael Selig      <m-selig@uiuc.edu>
26
27 ----------------------------------------------------------------------
28
29  VARIABLES:
30
31 ----------------------------------------------------------------------
32
33  INPUTS:       n/a
34
35 ----------------------------------------------------------------------
36
37  OUTPUTS:      n/a
38
39 ----------------------------------------------------------------------
40
41  CALLED BY:    uiuc_menu()
42
43 ----------------------------------------------------------------------
44
45  CALLS TO:     check_float() if needed
46                d_2_to_3() if needed
47                d_1_to_2() if needed
48                i_1_to_2() if needed
49                d_1_to_1() if needed
50
51  ----------------------------------------------------------------------
52
53  COPYRIGHT:    (C) 2003 by Michael Selig
54
55  This program is free software; you can redistribute it and/or
56  modify it under the terms of the GNU General Public License
57  as published by the Free Software Foundation.
58
59  This program is distributed in the hope that it will be useful,
60  but WITHOUT ANY WARRANTY; without even the implied warranty of
61  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
62  GNU General Public License for more details.
63
64  You should have received a copy of the GNU General Public License
65  along with this program; if not, write to the Free Software
66  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
67  USA or view http://www.gnu.org/copyleft/gpl.html.
68
69 **********************************************************************/
70
71 #include <simgear/compiler.h>
72
73 #if defined( __MWERKS__ )
74 // -dw- optimizer chokes (big-time) trying to optimize humongous
75 // loop/switch statements
76 #pragma optimization_level 0
77 #endif
78
79 #include <cstdlib>
80 #include <string>
81 #include STL_IOSTREAM
82
83 #include "uiuc_menu_mass.h"
84
85 SG_USING_STD(cerr);
86 SG_USING_STD(cout);
87 SG_USING_STD(endl);
88
89 #ifndef _MSC_VER
90 SG_USING_STD(exit);
91 #endif
92
93 void parse_mass( const string& linetoken2, const string& linetoken3,
94                  const string& linetoken4, const string& linetoken5, 
95                  const string& linetoken6, const string& linetoken7, 
96                  const string& linetoken8, const string& linetoken9,
97                  const string& linetoken10, const string& aircraft_directory,
98                  LIST command_line ) {
99     double token_value;
100     istrstream token3(linetoken3.c_str());
101     istrstream token4(linetoken4.c_str());
102     istrstream token5(linetoken5.c_str());
103     istrstream token6(linetoken6.c_str());
104     istrstream token7(linetoken7.c_str());
105     istrstream token8(linetoken8.c_str());
106     istrstream token9(linetoken9.c_str());
107     istrstream token10(linetoken10.c_str());
108
109     switch(mass_map[linetoken2])
110       {
111       case Weight_flag:
112         {
113           if (check_float(linetoken3))
114             token3 >> token_value;
115           else
116             uiuc_warnings_errors(1, *command_line);
117           
118           Weight = token_value;
119           Mass = Weight * INVG;
120           massParts -> storeCommands (*command_line);
121           break;
122         }
123       case Mass_flag:
124         {
125           if (check_float(linetoken3))
126             token3 >> token_value;
127           else
128             uiuc_warnings_errors(1, *command_line);
129           
130           Mass = token_value;
131           massParts -> storeCommands (*command_line);
132           break;
133         }
134       case I_xx_flag:
135         {
136           if (check_float(linetoken3))
137             token3 >> token_value;
138           else
139             uiuc_warnings_errors(1, *command_line);
140           
141           I_xx = token_value;
142           massParts -> storeCommands (*command_line);
143           break;
144         }
145       case I_yy_flag:
146         {
147           if (check_float(linetoken3))
148             token3 >> token_value;
149           else
150             uiuc_warnings_errors(1, *command_line);
151           
152           I_yy = token_value;
153           massParts -> storeCommands (*command_line);
154           break;
155         }
156       case I_zz_flag:
157         {
158           if (check_float(linetoken3))
159             token3 >> token_value;
160           else
161             uiuc_warnings_errors(1, *command_line);
162           
163           I_zz = token_value;
164           massParts -> storeCommands (*command_line);
165           break;
166         }
167       case I_xz_flag:
168         {
169           if (check_float(linetoken3))
170             token3 >> token_value;
171           else
172             uiuc_warnings_errors(1, *command_line);
173           
174           I_xz = token_value;
175           massParts -> storeCommands (*command_line);
176           break;
177         }
178       case Mass_appMass_ratio_flag:
179         {
180           if (check_float(linetoken3))
181             token3 >> token_value;
182           else
183             uiuc_warnings_errors(1, *command_line);
184           
185           Mass_appMass_ratio = token_value;
186           massParts -> storeCommands (*command_line);
187           break;
188         }
189       case I_xx_appMass_ratio_flag:
190         {
191           if (check_float(linetoken3))
192             token3 >> token_value;
193           else
194             uiuc_warnings_errors(1, *command_line);
195           
196           I_xx_appMass_ratio = token_value;
197           massParts -> storeCommands (*command_line);
198           break;
199         }
200       case I_yy_appMass_ratio_flag:
201         {
202           if (check_float(linetoken3))
203             token3 >> token_value;
204           else
205             uiuc_warnings_errors(1, *command_line);
206           
207           I_yy_appMass_ratio = token_value;
208           massParts -> storeCommands (*command_line);
209           break;
210         }
211       case I_zz_appMass_ratio_flag:
212         {
213           if (check_float(linetoken3))
214             token3 >> token_value;
215           else
216             uiuc_warnings_errors(1, *command_line);
217           
218           I_zz_appMass_ratio = token_value;
219           massParts -> storeCommands (*command_line);
220           break;
221         }
222       case Mass_appMass_flag:
223         {
224           if (check_float(linetoken3))
225             token3 >> token_value;
226           else
227             uiuc_warnings_errors(1, *command_line);
228           
229           Mass_appMass = token_value;
230           massParts -> storeCommands (*command_line);
231           break;
232         }
233       case I_xx_appMass_flag:
234         {
235           if (check_float(linetoken3))
236             token3 >> token_value;
237           else
238             uiuc_warnings_errors(1, *command_line);
239           
240           I_xx_appMass = token_value;
241           massParts -> storeCommands (*command_line);
242           break;
243         }
244       case I_yy_appMass_flag:
245         {
246           if (check_float(linetoken3))
247             token3 >> token_value;
248           else
249             uiuc_warnings_errors(1, *command_line);
250           
251           I_yy_appMass = token_value;
252           massParts -> storeCommands (*command_line);
253           break;
254         }
255       case I_zz_appMass_flag:
256         {
257           if (check_float(linetoken3))
258             token3 >> token_value;
259           else
260             uiuc_warnings_errors(1, *command_line);
261           
262           I_zz_appMass = token_value;
263           massParts -> storeCommands (*command_line);
264           break;
265         }
266       default:
267         {
268           if (ignore_unknown_keywords) {
269             // do nothing
270           } else {
271             // print error message
272             uiuc_warnings_errors(2, *command_line);
273           }
274           break;
275         }
276       };
277 }