1 /**********************************************************************
3 FILENAME: uiuc_menu_mass.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: reads input data for specified aircraft and creates
8 approporiate data storage space
10 ----------------------------------------------------------------------
14 ----------------------------------------------------------------------
16 REFERENCES: based on "menu reader" format of Michael Selig
18 ----------------------------------------------------------------------
20 HISTORY: 04/04/2003 initial release
22 ----------------------------------------------------------------------
24 AUTHOR(S): Robert Deters <rdeters@uiuc.edu>
25 Michael Selig <m-selig@uiuc.edu>
27 ----------------------------------------------------------------------
31 ----------------------------------------------------------------------
35 ----------------------------------------------------------------------
39 ----------------------------------------------------------------------
41 CALLED BY: uiuc_menu()
43 ----------------------------------------------------------------------
45 CALLS TO: check_float() if needed
51 ----------------------------------------------------------------------
53 COPYRIGHT: (C) 2003 by Michael Selig
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.
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.
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.
69 **********************************************************************/
71 #include <simgear/compiler.h>
73 #if defined( __MWERKS__ )
74 // -dw- optimizer chokes (big-time) trying to optimize humongous
75 // loop/switch statements
76 #pragma optimization_level 0
83 #include "uiuc_menu_mass.h"
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,
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());
109 switch(mass_map[linetoken2])
113 if (check_float(linetoken3))
114 token3 >> token_value;
116 uiuc_warnings_errors(1, *command_line);
118 Weight = token_value;
119 Mass = Weight * INVG;
120 massParts -> storeCommands (*command_line);
125 if (check_float(linetoken3))
126 token3 >> token_value;
128 uiuc_warnings_errors(1, *command_line);
131 massParts -> storeCommands (*command_line);
136 if (check_float(linetoken3))
137 token3 >> token_value;
139 uiuc_warnings_errors(1, *command_line);
142 massParts -> storeCommands (*command_line);
147 if (check_float(linetoken3))
148 token3 >> token_value;
150 uiuc_warnings_errors(1, *command_line);
153 massParts -> storeCommands (*command_line);
158 if (check_float(linetoken3))
159 token3 >> token_value;
161 uiuc_warnings_errors(1, *command_line);
164 massParts -> storeCommands (*command_line);
169 if (check_float(linetoken3))
170 token3 >> token_value;
172 uiuc_warnings_errors(1, *command_line);
175 massParts -> storeCommands (*command_line);
178 case Mass_appMass_ratio_flag:
180 if (check_float(linetoken3))
181 token3 >> token_value;
183 uiuc_warnings_errors(1, *command_line);
185 Mass_appMass_ratio = token_value;
186 massParts -> storeCommands (*command_line);
189 case I_xx_appMass_ratio_flag:
191 if (check_float(linetoken3))
192 token3 >> token_value;
194 uiuc_warnings_errors(1, *command_line);
196 I_xx_appMass_ratio = token_value;
197 massParts -> storeCommands (*command_line);
200 case I_yy_appMass_ratio_flag:
202 if (check_float(linetoken3))
203 token3 >> token_value;
205 uiuc_warnings_errors(1, *command_line);
207 I_yy_appMass_ratio = token_value;
208 massParts -> storeCommands (*command_line);
211 case I_zz_appMass_ratio_flag:
213 if (check_float(linetoken3))
214 token3 >> token_value;
216 uiuc_warnings_errors(1, *command_line);
218 I_zz_appMass_ratio = token_value;
219 massParts -> storeCommands (*command_line);
222 case Mass_appMass_flag:
224 if (check_float(linetoken3))
225 token3 >> token_value;
227 uiuc_warnings_errors(1, *command_line);
229 Mass_appMass = token_value;
230 massParts -> storeCommands (*command_line);
233 case I_xx_appMass_flag:
235 if (check_float(linetoken3))
236 token3 >> token_value;
238 uiuc_warnings_errors(1, *command_line);
240 I_xx_appMass = token_value;
241 massParts -> storeCommands (*command_line);
244 case I_yy_appMass_flag:
246 if (check_float(linetoken3))
247 token3 >> token_value;
249 uiuc_warnings_errors(1, *command_line);
251 I_yy_appMass = token_value;
252 massParts -> storeCommands (*command_line);
255 case I_zz_appMass_flag:
257 if (check_float(linetoken3))
258 token3 >> token_value;
260 uiuc_warnings_errors(1, *command_line);
262 I_zz_appMass = token_value;
263 massParts -> storeCommands (*command_line);
268 if (ignore_unknown_keywords) {
271 // print error message
272 uiuc_warnings_errors(2, *command_line);