My Project
LineParser.h
1 #include "stdafx.h"
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "Node.h"
5 #include "L3Element.h"
6 #include "L2Element.h"
7 #include <fstream>
8 #include <string>
9 #include <vector>
10 #pragma once
11 class LineParser
13 {
14 public:
15 
16  ~LineParser();
17 
18  static const int TWO_NODED_LINE = 1;
19  static const int THREE_NODED_LINE = 8;
20 
31  LineParser(std::string fileName, std::vector<LineElement*>& elements, std::vector<Node>& nodes);
32 
33  std::string line;
34 
41  void load_msh(std::ifstream&, std::vector<LineElement*>& elements, std::vector<Node>& nodes);
42 
43  bool readMeshFormat(std::ifstream&, double*);
44 
51  bool readElements(std::ifstream&, std::vector<LineElement*> *, std::vector<Node>& nodes);
52  bool readNodes(std::ifstream& in, std::vector<Node> *nodes);
53  void readInt(std::ifstream& in, int *number);
54  void readDouble(std::ifstream& in, double* number);
55  bool filePosEqualsLine(std::ifstream&, std::string);
56  void createTwoNodeLineElement(std::ifstream& in, std::vector<LineElement*> *elements, int type, std::vector<Node>& nodes);
57  void createThreeNodeLineElement(std::ifstream& in, std::vector<LineElement*> *elements, int type, std::vector<Node>& nodes);
58 
59 private:
60 
61 };
62 
bool filePosEqualsLine(std::ifstream &, std::string)
Verifies that the line from the file matches with .msh format version.
Definition: LineParser.cpp:75
LineParser(std::string fileName, std::vector< LineElement * > &elements, std::vector< Node > &nodes)
Constructor.
Definition: LineParser.cpp:12
void readDouble(std::ifstream &in, double *number)
Assigns a double value from the .msh file to the number argument.
Definition: LineParser.cpp:69
static const int TWO_NODED_LINE
Integer for selecting element type based on the .msh format.
Definition: LineParser.h:18
bool readMeshFormat(std::ifstream &, double *)
Verifies the mesh format of the file.
Definition: LineParser.cpp:161
void createThreeNodeLineElement(std::ifstream &in, std::vector< LineElement * > *elements, int type, std::vector< Node > &nodes)
Creates a six-node triangle and appends it to the element list.
Definition: LineParser.cpp:126
Parses .msh file.
Definition: LineParser.h:12
void createTwoNodeLineElement(std::ifstream &in, std::vector< LineElement * > *elements, int type, std::vector< Node > &nodes)
Creates a three-node triangle and appends it to the element list.
Definition: LineParser.cpp:81
std::string line
Data on line in current position in file.
Definition: LineParser.h:33
void load_msh(std::ifstream &, std::vector< LineElement * > &elements, std::vector< Node > &nodes)
Loads the .msh data into the elements and nodes vectors.
Definition: LineParser.cpp:29
void readInt(std::ifstream &in, int *number)
Assigns an integer value from the .msh file to the number argument.
Definition: LineParser.cpp:64
bool readNodes(std::ifstream &in, std::vector< Node > *nodes)
Reads the nodes from the .msh file.
Definition: LineParser.cpp:178
bool readElements(std::ifstream &, std::vector< LineElement * > *, std::vector< Node > &nodes)
Reads the elements from .msh file.
Definition: LineParser.cpp:202
static const int THREE_NODED_LINE
Integer for selecting element type based on the .msh format.
Definition: LineParser.h:19