DFNgen  2.0
DFN Model Generator
readInputFunctions.h
Go to the documentation of this file.
1 #ifndef _readInputFunctions_h_
2 #define _readInputFunctions_h_
3 #include <fstream>
4 #include <vector>
5 #include <string>
6 #include <iostream>
7 #include "structures.h"
8 
9 //Note, Template functions (type t) are coded inside .h files
10 
11 // Function forward declarations/prototypes
12 // See readInputFunctions.cpp for descriptions and code
13 void searchVar(std::ifstream &stream, std::string search);
14 void checkIfOpen(std::ifstream &stream, std::string fileName);
15 void checkIfOpen(std::ofstream &stream, std::string fileName);
16 void getCords(std::ifstream & stream, double *outAry, int nPoly, int nVertices);
17 
18 
19 /*****************************************************************/
25 template <typename T>
26 void get2dAry(std::ifstream &stream, T *var, int rowSize){
27  int i;
28  char ch;
29  for (i = 0; i < rowSize; i++) {
30  int x = 3* i;
31  stream >> ch >> var[x] >> ch >> var[x+1] >> ch >> var [x+2] >>ch;
32  }
33 }
34 
35 
36 /*****************************************************************/
41 template <typename T>
42 void getInputAry(std::ifstream &stream, T *var, int nElements){
43  int i;
44  char ch;
45  for (i = 0; i < nElements; i++) {
46  stream >> ch >> var[i];
47  }
48 }
49 
50 
51 /*****************************************************************/
56 template <typename T>
57 void printAry(T *var, std::string varName, int nElements){
58  int i;
59  nElements += -1;
60  std::cout << varName << " = {";
61  for (i = 0; i < nElements; i++){
62  std::cout << var[i] << ", ";
63  }
64  std::cout << var[nElements] << "}\n";
65 }
66 
67 
68 /*****************************************************************/
74 template <typename T>
75 void print2dAry(T *var, std::string varName, int rowSize) {
76  int i;
77  std::cout << varName << " :\n";
78  for(i = 0; i<rowSize; i++) {
79  int x = 3 * i;
80  std::cout << "{" << var[x] << ", " << var[x+1] << ", " << var[x+2] << "}\n";
81  }
82 }
83 
84 
85 /*****************************************************************/
90 template <typename T>
91 void getElements(std::ifstream &stream, T *var, int nElements){
92  int i;
93  for(i=0; i<nElements; i++) {
94  stream >> var[i];
95  }
96 }
97 
98 void getRectCoords(std::ifstream &stream, double *var, int nRectangles);
99 void printRectCoords(double *var, std::string varName, int nRectangles);
100 void printInputVars();
101 void getInput(char* inputFile, std::vector<Shape> &shapeFamily);
102 unsigned int getTimeBasedSeed();
103 
104 #endif
void getInput(char *inputFile, std::vector< Shape > &shapeFamily)
Definition: readInput.cpp:485
void getInputAry(std::ifstream &stream, T *var, int nElements)
void getElements(std::ifstream &stream, T *var, int nElements)
void printRectCoords(double *var, std::string varName, int nRectangles)
void searchVar(std::ifstream &stream, std::string search)
void getCords(std::ifstream &stream, double *outAry, int nPoly, int nVertices)
unsigned int nPoly
Definition: readInput.cpp:15
void getRectCoords(std::ifstream &stream, double *var, int nRectangles)
void get2dAry(std::ifstream &stream, T *var, int rowSize)
void printInputVars()
Definition: readInput.cpp:1245
void checkIfOpen(std::ifstream &stream, std::string fileName)
unsigned int getTimeBasedSeed()
void print2dAry(T *var, std::string varName, int rowSize)
void printAry(T *var, std::string varName, int nElements)
short shapeFamily
Definition: structures.h:393