Debian Codegraph @

src/FDM/UIUCModel/uiuc_2DdataFileReader.cpp

raw symbols SCIP
1 /**********************************************************************
2
3 FILENAME: uiuc_2DdataFileReader.cpp
4
5 ----------------------------------------------------------------------
6
7 DESCRIPTION: Reads name of data file to be opened and reads data
8 into appropriate arrays or matrices
9
10 ----------------------------------------------------------------------
11
12 STATUS: alpha version
13
14 ----------------------------------------------------------------------
15
16 REFERENCES:
17
18 ----------------------------------------------------------------------
19
20 HISTORY: 02/29/2000 initial release
21 10/25/2001 (RD) Modified so that it recognizes a
22 blank line
23 06/30/2003 (RD) replaced istrstream with istringstream
24 to get rid of the annoying warning about
25 using the strstream header
26
27 ----------------------------------------------------------------------
28
29 AUTHOR(S): Jeff Scott <[email protected]>
30 Robert Deters <[email protected]>
31
32 ----------------------------------------------------------------------
33
34 VARIABLES:
35
36 ----------------------------------------------------------------------
37
38 INPUTS: -2D file name
39 -conversion factor for x data
40 -conversion factor for y data
41 -conversion factor for z data
42
43 ----------------------------------------------------------------------
44
45 OUTPUTS: -2D array of x data for each y case
46 -1D array of y data
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
50
51 ----------------------------------------------------------------------
52
53 CALLED BY: uiuc_menu.cpp
54
55 ----------------------------------------------------------------------
56
57 CALLS TO: specified 2D data file
58
59 ----------------------------------------------------------------------
60
61 COPYRIGHT: (C) 2000 by Michael Selig
62
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.
66
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.
71
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.
75
76 **********************************************************************/
77
78 #include "uiuc_2DdataFileReader.h"
79
80 using std::string;
81 using std::istringstream;
82
83 void uiuc_2DdataFileReader( string file_name,
84 double x[100][100],
85 double y[100],
86 double z[100][100],
87 int xmax[100],
88 int &ymax)
89 {
90 ParseFile *matrix;
91 double token_value1;
92 double token_value2;
93 int counter_y = 1, counter_x = 1;
94 string linetoken1;
95 string linetoken2;
96
97 stack command_list;
98
99 /* Read the file and get the list of commands */
100 matrix = new ParseFile(file_name);
101 command_list = matrix -> getCommands();
102
103 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
104 {
105 linetoken1 = matrix -> getToken(*command_line, 1); // gettoken(string,tokenNo);
106 linetoken2 = matrix -> getToken(*command_line, 2); // 2 represents token No 2
107
108 istringstream token1(linetoken1.c_str());
109 istringstream token2(linetoken2.c_str());
110
111 //reset token_value1 and token_value2 for first if statement
112 token_value1 = -999;
113 token_value2 = -999;
114
115 token1 >> token_value1;
116 token2 >> token_value2;
117
118 //chenk to see if it is a blank line
119 if (token_value1==-999 && token_value2==-999);
120 //check to see if only one value on line (token2 blank)
121 else if (token_value2 == -999)
122 {
123 y[counter_y] = token_value1 * convert_y;
124
125 ymax = counter_y;
126 counter_y++;
127 counter_x = 1;
128 }
129 else
130 {
131 x[counter_y-1][counter_x] = token_value1 * convert_x;
132 z[counter_y-1][counter_x] = token_value2 * convert_z;
133
134 xmax[counter_y-1] = counter_x;
135 counter_x++;
136 }
137 }
138 delete matrix;
139 return;
140 }
141
142 // end uiuc_2DdataFileReader.cpp