1 /**********************************************************************
3 FILENAME: uiuc_2DdataFileReader.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: Reads name of data file to be opened and reads data
8 into appropriate arrays or matrices
10 ----------------------------------------------------------------------
14 ----------------------------------------------------------------------
18 ----------------------------------------------------------------------
20 HISTORY: 02/29/2000 initial release
22 ----------------------------------------------------------------------
24 AUTHOR(S): Jeff Scott <jscott@mail.com>
26 ----------------------------------------------------------------------
30 ----------------------------------------------------------------------
33 -conversion factor for x data
34 -conversion factor for y data
35 -conversion factor for z data
37 ----------------------------------------------------------------------
39 OUTPUTS: -2D array of x data for each y case
41 -2D array of z data for each y case
42 -1D array of max number of x-z data sets for each y case
43 -max number of y data sets
45 ----------------------------------------------------------------------
47 CALLED BY: uiuc_menu.cpp
49 ----------------------------------------------------------------------
51 CALLS TO: specified 2D data file
53 ----------------------------------------------------------------------
55 COPYRIGHT: (C) 2000 by Michael Selig
57 This program is free software; you can redistribute it and/or
58 modify it under the terms of the GNU General Public License
59 as published by the Free Software Foundation.
61 This program is distributed in the hope that it will be useful,
62 but WITHOUT ANY WARRANTY; without even the implied warranty of
63 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64 GNU General Public License for more details.
66 You should have received a copy of the GNU General Public License
67 along with this program; if not, write to the Free Software
68 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
69 USA or view http://www.gnu.org/copyleft/gpl.html.
71 **********************************************************************/
73 #include "uiuc_2DdataFileReader.h"
76 int uiuc_2DdataFileReader( string file_name,
89 int counter_y = 1, counter_x = 1, data = 0;
95 /* Read the file and get the list of commands */
96 matrix = new ParseFile(file_name);
97 command_list = matrix -> getCommands();
99 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
101 linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
102 linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
104 istrstream token1(linetoken1.c_str());
105 istrstream token2(linetoken2.c_str());
107 //reset token_value2 for first if statement
110 token1 >> token_value1;
111 token2 >> token_value2;
113 //check to see if only one value on line (token2 blank)
114 if (token_value2 == -999)
116 y[counter_y] = token_value1 * convert_y;
124 x[counter_y-1][counter_x] = token_value1 * convert_x;
125 z[counter_y-1][counter_x] = token_value2 * convert_z;
127 xmax[counter_y-1] = counter_x;
135 // end uiuc_2DdataFileReader.cpp