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[100], double y[100], int &xmax )
80 int counter = 1, data = 0;
85 /* Read the file and get the list of commands */
86 matrix = new ParseFile(file_name);
87 command_list = matrix -> getCommands();
89 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
91 linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
92 linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
94 istrstream token1(linetoken1.c_str());
95 istrstream token2(linetoken2.c_str());
97 token1 >> token_value1;
98 token2 >> token_value2;
100 x[counter] = token_value1 * convert_x;
101 y[counter] = token_value2 * convert_y;
109 //can't have conversions in this version since the numbers are
110 //to stay as integers
112 uiuc_1DdataFileReader( string file_name,
113 double x[], int y[], int &xmax )
119 int counter = 1, data = 0;
124 /* Read the file and get the list of commands */
125 matrix = new ParseFile(file_name);
126 command_list = matrix -> getCommands();
128 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
130 linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
131 linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
133 istrstream token1(linetoken1.c_str());
134 istrstream token2(linetoken2.c_str());
136 token1 >> token_value1;
137 token2 >> token_value2;
139 x[counter] = token_value1;
140 y[counter] = token_value2;
148 // end uiuc_1DdataFileReader.cpp