1 /**********************************************************************
3 FILENAME: uiuc_1DdataFileReader.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/15/2000 initial release
22 ----------------------------------------------------------------------
24 AUTHOR(S): Jeff Scott <jscott@mail.com>
26 ----------------------------------------------------------------------
30 ----------------------------------------------------------------------
32 INPUTS: -1D data file name
33 -conversion factor for y data
34 -conversion factor for x data
36 ----------------------------------------------------------------------
38 OUTPUTS: -array of x data
40 -max number of data sets
42 ----------------------------------------------------------------------
44 CALLED BY: uiuc_menu.cpp
46 ----------------------------------------------------------------------
48 CALLS TO: specified 1D data file
50 ----------------------------------------------------------------------
52 COPYRIGHT: (C) 2000 by Michael Selig
54 This program is free software; you can redistribute it and/or
55 modify it under the terms of the GNU General Public License
56 as published by the Free Software Foundation.
58 This program is distributed in the hope that it will be useful,
59 but WITHOUT ANY WARRANTY; without even the implied warranty of
60 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61 GNU General Public License for more details.
63 You should have received a copy of the GNU General Public License
64 along with this program; if not, write to the Free Software
65 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
66 USA or view http://www.gnu.org/copyleft/gpl.html.
68 **********************************************************************/
70 #include "uiuc_1DdataFileReader.h"
73 uiuc_1DdataFileReader( string file_name,
74 double x[], double y[], int &xmax )
80 int counter = 1, data = 0;
84 static string uiuc_1DdataFileReader_error = " (from uiuc_1DdataFileReader.cpp) ";
86 /* Read the file and get the list of commands */
87 matrix = new ParseFile(file_name);
88 command_list = matrix -> getCommands();
90 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
92 linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
93 linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
95 istrstream token1(linetoken1.c_str());
96 istrstream token2(linetoken2.c_str());
98 token1 >> token_value1;
99 token2 >> token_value2;
101 x[counter] = token_value1 * convert_x;
102 y[counter] = token_value2 * convert_y;
105 //(RD) will create error check later, we can have more than 100
108 // uiuc_warnings_errors(6, uiuc_1DdataFileReader_error);
115 //can't have conversions in this version since the numbers are
116 //to stay as integers
118 uiuc_1DdataFileReader( string file_name,
119 double x[], int y[], int &xmax )
125 int counter = 1, data = 0;
130 /* Read the file and get the list of commands */
131 matrix = new ParseFile(file_name);
132 command_list = matrix -> getCommands();
134 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
136 linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
137 linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
139 istrstream token1(linetoken1.c_str());
140 istrstream token2(linetoken2.c_str());
142 token1 >> token_value1;
143 token2 >> token_value2;
145 x[counter] = token_value1;
146 y[counter] = token_value2;
154 // end uiuc_1DdataFileReader.cpp