porenetwork reads input files

This commit is contained in:
James E McClure
2018-03-21 15:13:45 -04:00
parent 1a64dfea84
commit 19e1bf903a

View File

@@ -138,25 +138,47 @@ int main(int argc, char **argv)
DoubleArray spheres(4,nsph); // ( x, y, z, radius)
// Read from text file
printf("Reading spheres \n");
printf("Reading spheres \n");
ifstream SPHERES ( "spheres.csv" ); // declare file stream: http://www.cplusplus.com/reference/iostream/ifstream/
string value;
int index=0;
while ( SPHERES.good() )
{
while ( index < nsph ) {
getline ( SPHERES, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
spheres(0,index)=strtod(value.c_str(),NULL);
getline ( SPHERES, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
spheres(1,index)=strtod(value.c_str(),NULL);
getline ( SPHERES, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
spheres(2,index)=strtod(value.c_str(),NULL);
getline ( SPHERES, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
getline ( SPHERES, value ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
spheres(3,index)=strtod(value.c_str(),NULL);
printf("cx=%f,cy=%f,cz=%f,r=%f\n",spheres(0,index),spheres(1,index),spheres(2,index),spheres(3,index));
index++;
//cout << string( value, 1, value.length()-2 ); // display value removing the first and the last character from it
}
printf("Reading spheres \n");
ifstream CYLINDERS ( "cylinders.csv" ); // declare file stream: http://www.cplusplus.com/reference/iostream/ifstream/
index=0;
while ( index < ncyl ) {
getline ( CYLINDERS, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
cylinders(0,index)=strtod(value.c_str(),NULL);
getline ( CYLINDERS, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
cylinders(1,index)=strtod(value.c_str(),NULL);
getline ( CYLINDERS, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
cylinders(2,index)=strtod(value.c_str(),NULL);
getline ( CYLINDERS, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
cylinders(3,index)=strtod(value.c_str(),NULL);
getline ( CYLINDERS, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
cylinders(4,index)=strtod(value.c_str(),NULL);
getline ( CYLINDERS, value, ' ' ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
cylinders(5,index)=strtod(value.c_str(),NULL);
getline ( CYLINDERS, value ); // read a string until next comma: http://www.cplusplus.com/reference/string/getline/
cylinders(6,index)=strtod(value.c_str(),NULL);
printf("x=%f,y=%f,z=%f,r=%f\n",cylinders(0,index),cylinders(1,index),cylinders(2,index),cylinders(6,index));
index++;
//cout << string( value, 1, value.length()-2 ); // display value removing the first and the last character from it
}
sum=0;
for (k=0;k<Nz;k++){
for (j=0;j<Ny;j++){