My Project
MSHParser.h
1 #include "stdafx.h"
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "Node.h"
5 #include "T3Element.h"
6 #include "T6Element.h"
7 #include "Q4Element.h"
8 #include "Q9Element.h"
9 #include <fstream>
10 #include <string>
11 #include <vector>
12 
13 #ifndef MSHPARSER
14 #define MSHPARSER
15 
17 class MSHParser
18 {
19 public:
20 
21  static const int THREE_NODED_TRIANGLE = 2;
22  static const int SIX_NODED_TRIANGLE = 9;
23  static const int FOUR_NODED_QUAD = 3;
24  static const int NINE_NODED_QUAD = 10;
25 
37  MSHParser(std::string fileName, std::vector<Element*>& elements, std::vector<Node>& nodes);
38 
39 
40 private:
41  std::string line;
42 
49  void load_msh(std::ifstream&, std::vector<Element*>& elements, std::vector<Node>& nodes);
50 
51  bool readMeshFormat(std::ifstream&, double*);
52 
59  bool readElements(std::ifstream&, std::vector<Element*> *, std::vector<Node>& nodes);
60  bool readNodes(std::ifstream& in, std::vector<Node> *nodes);
61  void readInt(std::ifstream& in, int *number);
62  void readDouble(std::ifstream& in, double* number);
63  bool filePosEqualsLine(std::ifstream&, std::string);
64  void createThreeNodeTriangleElement(std::ifstream& in, std::vector<Element*> *elements, int type, std::vector<Node>& nodes);
65  void createSixNodeTriangleElement(std::ifstream& in, std::vector<Element*> *elements, int type, std::vector<Node>& nodes);
66  void createFourNodeQuadElement(std::ifstream & in, std::vector<Element*> *elements, int type, std::vector<Node>& nodes);
67  void MSHParser::createNineNodeQuadElement(std::ifstream & in, std::vector<Element*> *elements, int type, std::vector<Node>& nodes);
68 
69 
70 };
71 
72 #endif
static const int THREE_NODED_TRIANGLE
Integer for selecting element type based on the .msh format.
Definition: MSHParser.h:21
static const int FOUR_NODED_QUAD
Integer for selecting element type based on the .msh format.
Definition: MSHParser.h:23
static const int SIX_NODED_TRIANGLE
Integer for selecting element type based on the .msh format.
Definition: MSHParser.h:22
static const int NINE_NODED_QUAD
Integer for selecting element type based on the .msh format.
Definition: MSHParser.h:24
Interprets meshes structured in the ".msh" format.
Definition: MSHParser.h:17
MSHParser(std::string fileName, std::vector< Element * > &elements, std::vector< Node > &nodes)
Constructor.
Definition: MSHParser.cpp:7