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
21 10/25/2001 (RD) Modified so that it recognizes a
23 06/30/2003 (RD) replaced istrstream with istringstream
24 to get rid of the annoying warning about
25 using the strstream header
27 ----------------------------------------------------------------------
29 AUTHOR(S): Jeff Scott <jscott@mail.com>
30 Robert Deters <rdeters@uiuc.edu>
32 ----------------------------------------------------------------------
36 ----------------------------------------------------------------------
39 -conversion factor for x data
40 -conversion factor for y data
41 -conversion factor for z data
43 ----------------------------------------------------------------------
45 OUTPUTS: -2D array of x data for each y case
47 -2D array of z data for each y case
48 -1D array of max number of x-z data sets for each y case
49 -max number of y data sets
51 ----------------------------------------------------------------------
53 CALLED BY: uiuc_menu.cpp
55 ----------------------------------------------------------------------
57 CALLS TO: specified 2D data file
59 ----------------------------------------------------------------------
61 COPYRIGHT: (C) 2000 by Michael Selig
63 This program is free software; you can redistribute it and/or
64 modify it under the terms of the GNU General Public License
65 as published by the Free Software Foundation.
67 This program is distributed in the hope that it will be useful,
68 but WITHOUT ANY WARRANTY; without even the implied warranty of
69 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70 GNU General Public License for more details.
72 You should have received a copy of the GNU General Public License
73 along with this program; if not, write to the Free Software
74 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
76 **********************************************************************/
78 #include "uiuc_2DdataFileReader.h"
81 void uiuc_2DdataFileReader( string file_name,
91 int counter_y = 1, counter_x = 1;
97 /* Read the file and get the list of commands */
98 matrix = new ParseFile(file_name);
99 command_list = matrix -> getCommands();
101 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
103 linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
104 linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
106 istringstream token1(linetoken1.c_str());
107 istringstream token2(linetoken2.c_str());
109 //reset token_value1 and token_value2 for first if statement
113 token1 >> token_value1;
114 token2 >> token_value2;
116 //chenk to see if it is a blank line
117 if (token_value1==-999 && token_value2==-999);
118 //check to see if only one value on line (token2 blank)
119 else if (token_value2 == -999)
121 y[counter_y] = token_value1 * convert_y;
129 x[counter_y-1][counter_x] = token_value1 * convert_x;
130 z[counter_y-1][counter_x] = token_value2 * convert_z;
132 xmax[counter_y-1] = counter_x;
140 // end uiuc_2DdataFileReader.cpp